/**
  * Constructor.
  *
  * We tweak Field UI here, as contents are polymorphic we need to dynamically
  * change `$_manageTable` property according to `content_type`.
  *
  * @param \Cake\Network\Request $request Request object for this controller. Can
  *  be null for testing, but expect that features that use the request
  *  parameters will not work.
  * @param \Cake\Network\Response $response Response object for this controller.
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     $validTypes = quickapps('content_types');
     if (!isset($request->query['type']) || !in_array($request->query['type'], $validTypes)) {
         $this->redirect(['plugin' => 'System', 'controller' => 'dashboard', 'prefix' => 'admin']);
     } else {
         // allows to manage polymorphic entities
         $this->_bundle = $request->query['type'];
         // Make $_GET['type'] persistent
         Router::addUrlFilter(function ($params, $request) {
             if (isset($request->query['type'])) {
                 $params['type'] = $request->query['type'];
             }
             return $params;
         });
     }
 }
Esempio n. 2
0
 /**
  * Initilize
  */
 public function initialize()
 {
     parent::initialize();
     $this->Content = new Content();
 }