diff --git a/.travis.yml b/.travis.yml index b2748c1..580ed9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php php: - - 7.0 - 7.1 - 7.2 - master diff --git a/application/modules/media/config.php b/application/configs/default/module.media.php similarity index 100% rename from application/modules/media/config.php rename to application/configs/default/module.media.php diff --git a/application/models/Media/Grid.php b/application/models/Media/Grid.php index 1fd293e..e6b6ec5 100644 --- a/application/models/Media/Grid.php +++ b/application/models/Media/Grid.php @@ -21,11 +21,9 @@ class Grid extends \Bluz\Grid\Grid protected $uid = 'options'; /** - * init - * - * @return self + * {@inheritdoc} */ - public function init() + public function init() : void { // Array $adapter = new SqlSource(); @@ -41,7 +39,5 @@ public function init() $this->setDefaultLimit(25); $this->setAllowOrders(['id', 'login', 'title', 'type', 'created', 'deleted']); $this->setAllowFilters(['userId', 'title', 'file']); - - return $this; } } diff --git a/application/models/Media/Manager.php b/application/models/Media/Manager.php index cdff2c1..935e65c 100644 --- a/application/models/Media/Manager.php +++ b/application/models/Media/Manager.php @@ -9,8 +9,8 @@ namespace Application\Media; use Application\Users; -use Bluz\Application\Exception\BadRequestException; use Bluz\Config\ConfigException; +use Bluz\Http\Exception\BadRequestException; use Bluz\Proxy\Auth; use Bluz\Proxy\Config; use Image\Thumbnail; @@ -62,7 +62,7 @@ public function __construct($media, $file) { $this->media = $media; $this->media->module = $this->media->module ?: 'users'; - $this->media->userId = $this->media->userId ?: Auth::getIdentity()->id ?: Users\Table::SYSTEM_USER; + $this->media->userId = $this->media->userId ?: Auth::getIdentity()->getId() ?: Users\Table::SYSTEM_USER; $this->file = $file; $this->name = $media->title ?? pathinfo($file->getClientFilename(), PATHINFO_FILENAME); @@ -81,7 +81,7 @@ public function __construct($media, $file) */ public function moveToDir($directory) { - $uploadPath = Config::getModuleData('media', 'upload_path'); + $uploadPath = Config::get('module.media', 'upload_path'); if (empty($uploadPath)) { throw new ConfigException('Upload path is not configured'); diff --git a/application/models/Media/Row.php b/application/models/Media/Row.php index bf6bb1d..8d07125 100644 --- a/application/models/Media/Row.php +++ b/application/models/Media/Row.php @@ -37,7 +37,7 @@ class Row extends \Bluz\Db\Row /** * {@inheritdoc} */ - protected function beforeSave() + protected function beforeSave() : void { $this->addValidator('title') ->required() @@ -49,7 +49,7 @@ protected function beforeSave() * * @return void */ - protected function beforeInsert() + protected function beforeInsert() : void { $this->created = gmdate('Y-m-d H:i:s'); @@ -59,7 +59,7 @@ protected function beforeInsert() } // set user ID if ($user = Auth::getIdentity()) { - $this->userId = $user->id; + $this->userId = $user->getId(); } else { $this->userId = Users\Table::SYSTEM_USER; } @@ -70,7 +70,7 @@ protected function beforeInsert() * * @return void */ - protected function beforeUpdate() + protected function beforeUpdate() : void { $this->updated = gmdate('Y-m-d H:i:s'); } @@ -80,7 +80,7 @@ protected function beforeUpdate() * * @return void */ - protected function afterDelete() + protected function afterDelete() : void { $this->deleteFiles(); } diff --git a/application/models/Media/Table.php b/application/models/Media/Table.php index f7ce7e8..7d5e337 100644 --- a/application/models/Media/Table.php +++ b/application/models/Media/Table.php @@ -32,7 +32,7 @@ class Table extends \Bluz\Db\Table * Primary key(s) * @var array */ - protected $primary = array('id'); + protected $primary = ['id']; /** * Get images of current user @@ -42,12 +42,12 @@ class Table extends \Bluz\Db\Table */ public function getImages() { - /** @var Row $user */ + /* @var \Application\Users\Row $user */ if (!$user = Auth::getIdentity()) { throw new Exception('User not found'); } - return $this->getImagesByUserId($user->id); + return $this->getImagesByUserId($user->getId()); } /** diff --git a/application/modules/media/controllers/crud.php b/application/modules/media/controllers/crud.php index da45044..da415ed 100644 --- a/application/modules/media/controllers/crud.php +++ b/application/modules/media/controllers/crud.php @@ -57,7 +57,7 @@ $result = $crudController->run(); // back to grid after create or update media file - if (Request::isPost() || Request::isPut()) { + if ((Request::isPost() || Request::isPut()) && !Request::isXmlHttpRequest()) { Response::reload(); } diff --git a/application/modules/media/controllers/upload.php b/application/modules/media/controllers/upload.php index 3925b80..02d9280 100644 --- a/application/modules/media/controllers/upload.php +++ b/application/modules/media/controllers/upload.php @@ -11,7 +11,7 @@ */ namespace Application; -use Bluz\Application\Exception\BadRequestException; +use Bluz\Http\Exception\BadRequestException; use Bluz\Config\ConfigException; use Bluz\Controller\Controller; use Bluz\Proxy\Request; diff --git a/application/modules/media/views/crud.phtml b/application/modules/media/views/crud.phtml index 90e7fef..6cb9268 100644 --- a/application/modules/media/views/crud.phtml +++ b/application/modules/media/views/crud.phtml @@ -4,7 +4,9 @@ */ ?> -