use Bluz\Proxy\Session; use Bluz\Request\AbstractRequest; return function () use($view) { /** * @var Bootstrap $this * @var \Bluz\View\View $view */ Session::start(); $this->useLayout('dashboard.phtml'); Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('Media', ['media', 'grid']), __('Upload')]); if (!$this->user()) { throw new Exception('User not found'); } $userId = $this->user()->id; $crud = Media\Crud::getInstance(); // get path from config $path = Config::getModuleData('media', 'upload_path'); if (empty($path)) { throw new Exception('Upload path is not configured'); } $crud->setUploadDir($path . '/' . $userId . '/media'); $crudController = new Controller\Crud(); $crudController->setCrud($crud); $result = $crudController(); // FIXME: workaround if (($crudController->getMethod() == AbstractRequest::METHOD_POST or $crudController->getMethod() == AbstractRequest::METHOD_PUT) && !$result) { // all ok, go to grid $this->redirectTo('media', 'grid'); } return $result; };