Example #1
0
<?php

/**
 * Example of Crud Controller
 *
 * @author   Anton Shevchuk
 * @created  04.09.12 11:21
 */
namespace Application;

use Application\Test;
use Bluz\Controller;
/**
 * @accept HTML
 * @accept JSON
 */
return function () {
    $crudController = new Controller\Crud();
    $crudController->setCrud(Test\Crud::getInstance());
    return $crudController();
};
Example #2
0
<?php

/**
 * Created by PhpStorm.
 * User: gunko
 * Date: 9/11/15
 * Time: 5:33 PM
 */
/**
 * @namespace
 */
namespace Application;

use Application\Media;
use Bluz\Controller;
use Bluz\Proxy\Config;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Session;
use Bluz\Request\AbstractRequest;
return function () {
    $crud = Musician\Crud::getInstance();
    $path = Config::getModuleData('musician', 'upload_path');
    if (empty($path)) {
        throw new Exception('Upload_path is not configured');
    }
    $crud->setUploadDir($path . "/musician");
    $crudController = new Controller\Crud();
    $crudController->setCrud(Musician\Crud::getInstance());
    return $crudController();
};
Example #3
0
use Bluz\Proxy\Request;
use Bluz\Proxy\Config;
use Bluz\Proxy\Session;
/**
 *@SWG\Resource(resourcePath="/upload")
 * @SWG\API(
 *  path = "/api/upload/",
 *  @SWG\Operation(
 *      method = "POST",
 *      nickname = "Upload image",
 *      summary = "Upload images",
 *      @SWG\Parameter(
 *          name = "files",
 *          paramType = "form",
 *          consumes = "multipart/form-data",
 *          description = "Upload images",
 *          required = true,
 *          type="File"
 *      ),
 *      @SWG\ResponseMessage(code=400, message="Invalid file type"),
 *      @SWG\ResponseMessage(code=200, message="File was uploaded")
 *  )
 * )
 */
return function () {
    $this->useJson();
    $crudController = new Controller\Crud();
    $crudController->setCrud(Menu\FileCrud::getInstance());
    $fileObjects = $crudController();
    return $fileObjects;
};
Example #4
0
<?php

/**
 * @author   Anton Shevchuk
 * @created  30.10.12 09:29
 */
namespace Application;

use Application\Users;
use Bluz\Controller;
return function () {
    /**
     * @var Bootstrap $this
     */
    $crudController = new Controller\Crud();
    $crudController->setCrud(Users\Crud::getInstance());
    return $crudController();
};
Example #5
0
<?php

/**
 * @author   Viacheslav Nogin
 * @created  25.11.12 09:29
 */
/**
 * @namespace
 */
namespace Application;

use Application\Categories;
use Bluz\Controller;
return function ($parentId = null) use($view) {
    /**
     * @var Bootstrap $this
     */
    $view->parentId = $parentId;
    $crudController = new Controller\Crud();
    $crudController->setCrud(Categories\Crud::getInstance());
    return $crudController();
};
Example #6
0
 /**
  * Process Crud
  *
  * @return mixed
  */
 protected function processCrud()
 {
     $crudController = new Controller\Crud();
     $crudController->setCrud(Crud::getInstance());
     return $crudController();
 }
Example #7
0
<?php

/**
 * @author   Anton Shevchuk
 * @created  04.09.12 11:21
 */
/**
 * @namespace
 */
namespace Application;

use Application\Roles;
use Bluz\Controller;
return function () {
    /**
     * @var Bootstrap $this
     */
    $crudController = new Controller\Crud();
    $crudController->setCrud(Roles\Crud::getInstance());
    return $crudController();
};
Example #8
0
<?php

/**
 * CRUD for options
 */
/**
 * @namespace
 */
namespace Application;

use Application\Options;
use Bluz\Controller;
return function () {
    /**
     * @var Bootstrap $this
     */
    $crudController = new Controller\Crud();
    $crudController->setCrud(Options\Crud::getInstance());
    return $crudController();
};
Example #9
0
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;
};