/**
  * Handles the optional setting of view vars within the component.
  *
  * @param boolean|string $viewVar
  * @param \Cake\Datesource\EntityInterface
  * @return void
  */
 protected function _setViewVar($viewVar, $entity)
 {
     if ($viewVar === false) {
         return;
     }
     $this->_controller->set($viewVar, $entity);
 }
 /**
  * Handles the redirect options.
  *
  * @param string $type Prefix for the array key, mostly "success" or "error"
  * @param array $options Options
  * @return mixed
  */
 protected function _handleRedirect($type, $options)
 {
     if (isset($options[$type . 'RedirectUrl']) && $options[$type . 'RedirectUrl'] !== false) {
         $result = $this->_controller->redirect($options[$type . 'RedirectUrl']);
         return $this->_redirectResponse = $result;
     }
     return false;
 }
Пример #3
0
 public function startup(Event $event)
 {
     if ($this->config('use_session_salt')) {
         if (!$this->controller->request->session()->check('Alaxos.SpamFilterComponent.salt')) {
             $this->controller->request->session()->write('Alaxos.SpamFilterComponent.salt', String::uuid());
         }
     } elseif ($this->controller->request->session()->check('Alaxos.SpamFilterComponent.salt')) {
         $this->controller->request->session()->delete('Alaxos.SpamFilterComponent.salt');
     }
     $salt = $this->get_session_salt();
     $this->controller->components()->load('Security')->config('unlockedFields', [SecurityTool::get_today_fieldname($salt)]);
     $this->controller->components()->load('Security')->config('unlockedFields', [SecurityTool::get_yesterday_fieldname($salt)]);
     /*
      * Pass Session salt to view in order to be available in AlaxosFormHelper
      */
     $this->controller->set('_alaxos_spam_filter_salt', $salt);
 }
Пример #4
0
 /**
  * Prepare Entity used to display search filters in the view
  * @param array $options
  * @return void
  */
 public function prepareSearchEntity(array $options = array())
 {
     $options['modelClass'] = isset($options['modelClass']) ? $options['modelClass'] : $this->controller->modelClass;
     $search_entity = $this->controller->{$options['modelClass']}->newEntity();
     $search_entity->accessible('*', true);
     $this->controller->{$options['modelClass']}->patchEntity($search_entity, $this->request->data);
     $this->controller->set(compact('search_entity'));
 }