/** * Create a new ViewModel. * * @param array $params Parameters to pass to ViewModel constructor. * * @return \Zend\View\Model\ViewModel */ protected function createViewModel($params = null) { $view = parent::createViewModel($params); $this->layout()->searchClassId = $view->searchClassId = $this->searchClassId; if (!is_null($this->driver)) { $view->driver = $this->driver; } return $view; }
/** * Use preDispatch event to block access when appropriate. * * @param MvcEvent $e Event object * * @return void */ public function validateAccessPermission(MvcEvent $e) { // Disable search box in Admin module: $this->layout()->searchbox = false; // If we're using the "disabled" action, we don't need to do any further // checking to see if we are disabled!! $routeMatch = $e->getRouteMatch(); if (strtolower($routeMatch->getParam('action')) == 'disabled') { return; } // Block access to everyone when module is disabled: $config = $this->getConfig(); if (!isset($config->Site->admin_enabled) || !$config->Site->admin_enabled) { $pluginManager = $this->getServiceLocator()->get('Zend\\Mvc\\Controller\\PluginManager'); $redirectPlugin = $pluginManager->get('redirect'); return $redirectPlugin->toRoute('admin/disabled'); } // Call parent method to do permission checking: parent::validateAccessPermission($e); }
/** * Register the default events for this controller * * @return void */ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'preDispatch'], 1000); }
/** * Create a new ViewModel. * * @param array $params Parameters to pass to ViewModel constructor. * * @return ViewModel */ protected function createViewModel($params = null) { $view = parent::createViewModel($params); $view->searchClassId = $this->searchClassId; return $view; }
/** * Constructor */ public function __construct() { parent::__construct(); $this->session = new SessionContainer('cart_followup'); }
/** * Create a new ViewModel. * * @param array $params Parameters to pass to ViewModel constructor. * * @return \Zend\View\Model\ViewModel */ protected function createViewModel($params = null) { $view = parent::createViewModel($params); $this->layout()->searchClassId = $view->searchClassId = $this->searchClassId; $view->driver = $this->loadRecord(); return $view; }
/** * Constructor * * @param \Zend\Session\Container $container Session container */ public function __construct(\Zend\Session\Container $container) { parent::__construct(); $this->session = $container; }
/** * Create a new ViewModel with title. * * @param array $params Parameters to pass to ViewModel constructor. * * @return ViewModel */ protected function createViewModel($params = null) { $view = parent::createViewModel($params); $view->title = $this->getVuDLConfig()->General->title; return $view; }
/** * Create a new ViewModel. * * @param array $params Parameters to pass to ViewModel constructor. * * @return \Zend\View\Model\ViewModel */ protected function createViewModel($params = null) { $view = parent::createViewModel($params); // Set the current action. $currentAction = $this->getCurrentAction(); if (!empty($currentAction)) { $view->currentAction = $currentAction; } // Initialize the array of top-level browse options. $browseOptions = []; // First option: tags -- is it enabled in config.ini? If no setting is // found, assume it is active. Note that this setting is disabled if tags // are universally turned off. if ((!isset($this->config->Browse->tag) || $this->config->Browse->tag) && $this->tagsEnabled()) { $browseOptions[] = $this->buildBrowseOption('Tag', 'Tag'); $view->tagEnabled = true; } // Read configuration settings for LC / Dewey call number display; default // to LC only if no settings exist in config.ini. if (!isset($this->config->Browse->dewey) && !isset($this->config->Browse->lcc)) { $lcc = true; $dewey = false; } else { $lcc = isset($this->config->Browse->lcc) && $this->config->Browse->lcc; $dewey = isset($this->config->Browse->dewey) && $this->config->Browse->dewey; } // Add the call number options as needed -- note that if both options exist, // we need to use special text to disambiguate them. if ($dewey) { $browseOptions[] = $this->buildBrowseOption('Dewey', $lcc ? 'browse_dewey' : 'Call Number'); $view->deweyEnabled = true; } if ($lcc) { $browseOptions[] = $this->buildBrowseOption('LCC', $dewey ? 'browse_lcc' : 'Call Number'); $view->lccEnabled = true; } // Loop through remaining browse options. All may be individually disabled // in config.ini, but if no settings are found, they are assumed to be on. $remainingOptions = ['Author', 'Topic', 'Genre', 'Region', 'Era']; foreach ($remainingOptions as $current) { $option = strToLower($current); if (!isset($this->config->Browse->{$option}) || $this->config->Browse->{$option} == true) { $browseOptions[] = $this->buildBrowseOption($current, $current); $option .= 'Enabled'; $view->{$option} = true; } } // CARRY if ($findby = $this->params()->fromQuery('findby')) { $view->findby = $findby; } if ($query = $this->params()->fromQuery('query')) { $view->query = $query; } if ($category = $this->params()->fromQuery('category')) { $view->category = $category; } $view->browseOptions = $browseOptions; return $view; }
/** * Register the default events for this controller * * @return void */ protected function attachDefaultListeners() { parent::attachDefaultListeners(); $events = $this->getEventManager(); $events->attach(MvcEvent::EVENT_DISPATCH, [$this, 'validateAutoConfigureConfig'], 1000); }