コード例 #1
0
 /**
  * Set the route destination after the mail is sent
  */
 protected function setAfterSendRoute()
 {
     if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) {
         $this->afterSendRouteUrl = array('action' => $this->routeAction);
         $keys = $this->model->getKeys();
         if (count($keys) == 1) {
             $key = reset($keys);
             if (isset($this->formData[$key])) {
                 $this->afterSendRouteUrl[\MUtil_Model::REQUEST_ID] = $this->formData[$key];
             }
         } else {
             $i = 1;
             foreach ($keys as $key) {
                 if (isset($this->formData[$key])) {
                     $this->afterSendRouteUrl[\MUtil_Model::REQUEST_ID . $i] = $this->formData[$key];
                 }
                 $i++;
             }
         }
         $this->afterSendRouteUrl['controller'] = $this->request->getControllerName();
         $find['action'] = $this->afterSendRouteUrl['action'];
         $find['controller'] = $this->afterSendRouteUrl['controller'];
         if (null == $this->menu->find($find)) {
             $this->afterSendRouteUrl['action'] = 'index';
             $this->resetRoute = true;
         }
     }
 }
コード例 #2
0
 protected function findAllowedMenuItem($action)
 {
     $actions = \MUtil_Ra::args(func_get_args());
     $controller = $this->_getParam('controller');
     foreach ($actions as $action) {
         $menuItem = $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true));
         if ($menuItem) {
             return $menuItem;
         }
     }
 }
コード例 #3
0
 /**
  * Finds a specific active menu item
  *
  * @param string $defaultController
  * @param string|array $actions
  * @return array of \Gems_Menu_SubMenuItem
  */
 protected function findMenuItems($defaultController, $actions = array('index'))
 {
     $output = array();
     foreach ((array) $actions as $key => $action) {
         $controller = is_int($key) ? $defaultController : $key;
         $item = $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true));
         if ($item) {
             $output[] = $item;
         }
     }
     return $output;
 }
コード例 #4
0
 /**
  * If menu item does not exist or is not allowed, redirect to index
  *
  * @return \Gems_Snippets_ModelFormSnippetAbstract
  */
 protected function setAfterSaveRoute()
 {
     parent::setAfterSaveRoute();
     if (is_array($this->afterSaveRouteUrl)) {
         // Make sure controller is set
         if (!array_key_exists('controller', $this->afterSaveRouteUrl)) {
             $this->afterSaveRouteUrl['controller'] = $this->request->getControllerName();
         }
         // Search array for menu item
         $find['controller'] = $this->afterSaveRouteUrl['controller'];
         $find['action'] = $this->afterSaveRouteUrl['action'];
         // If not allowed, redirect to index
         if (null == $this->menu->find($find)) {
             $this->afterSaveRouteUrl['action'] = 'index';
             $this->resetRoute = true;
         }
     }
     // \MUtil_Echo::track($this->routeAction, $this->resetRoute);
     return $this;
 }
 /**
  * Finds a specific active menu item
  *
  * @param string $controller
  * @param string $action
  * @return \Gems_Menu_SubMenuItem
  */
 protected function findMenuItem($controller, $action = 'index')
 {
     return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true));
 }