Пример #1
0
 /**
  * @return Zend_Controller_Plugin_Abstract
  */
 public function init()
 {
     $front = $this->getFrontController();
     $options = $this->getOptions();
     if (array_key_exists('plugins', $options)) {
         foreach ((array) $options['plugins'] as $pluginClass) {
             $stackIndex = null;
             $_options = array();
             if (is_array($pluginClass)) {
                 $pluginClass = array_change_key_case($pluginClass, CASE_LOWER);
                 if (isset($pluginClass['options'])) {
                     $_options = $pluginClass['options'];
                 }
                 if (isset($pluginClass['class'])) {
                     if (isset($pluginClass['stackindex'])) {
                         $stackIndex = $pluginClass['stackindex'];
                     }
                     $pluginClass = $pluginClass['class'];
                 }
             }
             $plugin = new $pluginClass($_options);
             $front->registerPlugin($plugin, $stackIndex);
             unset($options['plugins']);
         }
     }
     $this->_options = $options;
     return parent::init();
 }
Пример #2
0
 public function init()
 {
     $this->_frontController = $this->getFrontController();
     $this->_setRequest();
     $this->_frontController = parent::init();
     return $this->_frontController;
 }
Пример #3
0
 /**
  * Initialize Front Controller
  *
  * @return Zend_Controller_Front
  */
 public function init()
 {
     $front = $this->getFrontController();
     foreach ($this->getOptions() as $key => $value) {
         switch (strtolower($key)) {
             case 'modulecontrollerdirectoryname':
                 $front->setModuleControllerDirectoryName($value);
                 break;
             case 'moduledirectory':
                 if (is_array($value)) {
                     foreach ($value as $path) {
                         $dir = new DirectoryIterator($path);
                         foreach ($dir as $file) {
                             if ($file->isDot() || !$file->isDir() || substr($file->getFilename(), 0, 1) === '.') {
                                 continue;
                             }
                             $front->addModuleDirectory($file->getPathname());
                         }
                     }
                     unset($this->_options['moduleDirectory']);
                 }
                 break;
         }
     }
     return parent::init();
 }
Пример #4
0
 /**
  * Initialize Front Controller
  *
  * @return Zend_Controller_Front
  */
 public function init()
 {
     //$dispatcher = new ZLayer_Controller_Dispatcher_Standard();
     //$front = $this->getFrontController();
     //$front->setDispatcher($dispatcher);
     $front = parent::init();
     return $front;
 }
Пример #5
0
 /**
  * Load configuration file of options
  *
  * @return Zend_Controller_Front
  */
 public function init()
 {
     $front = parent::init();
     $application = $this->getBootstrap()->getApplication();
     if (get_class($application) == 'HausDesign_Application') {
         $front->setParam('application', $application->getApplication());
     }
     // $loaders = array();
     // foreach ($this->getFrontController()->getControllerDirectory() as $module => $directory) {
     //     $loaders[$module] = new Zend_Application_Module_Autoloader(array(
     //         'namespace' => ucfirst($module),
     //         'basePath'  => ucfirst(dirname($directory)),
     //     ));
     // }
     return $front;
 }
Пример #6
0
 /**
  * @return Zend_Controller_Front
  */
 public function init()
 {
     // If 'skipOmekaMvc' is set on the front controller, skip the Omeka
     // custom behavior here, and stick with vanilla Zend. Because of
     // resource naming conflicts, i.e. both Zend and Omeka resource plugins
     // called 'Frontcontroller', there is no easy way to use the default
     // Zend resource instead of Omeka's.  Situations where this would be
     // useful include installation of Omeka, or in any future modules that
     // want to bypass the dependency graph of Omeka in favor of using the
     // (relatively) simpler Zend Framework defaults.
     $front = parent::init();
     if ($front->getParam('skipOmekaMvc')) {
         return $front;
     }
     // REST API requests require a slightly different controller environment.
     // They must be made from the public side and the URL must match a
     // particular pattern.
     $request = new Zend_Controller_Request_Http();
     if (!$front->getParam('admin') && preg_match('#^/api/([a-z_]+)(.+)?$#', $request->getPathInfo())) {
         // Flag this as an API request.
         $front->setParam('api', true);
         // Displaying errors will break client parsers, so hide them.
         ini_set('display_errors', 0);
         // Register API-specific controller logic.
         $front->registerPlugin(new Omeka_Controller_Plugin_Api());
     }
     // Admin requests require a sligntly different controller environment.
     if ($front->getParam('admin')) {
         // Register admin-specific controller logic.
         $front->registerPlugin(new Omeka_Controller_Plugin_Admin());
     }
     // Plugin broker is required to set plugin-defined response contexts
     $bootstrap = $this->getBootstrap();
     if ($bootstrap->hasPluginResource('PluginBroker')) {
         $bootstrap->bootstrap('PluginBroker');
     }
     // Action helpers
     $this->getBootstrap()->bootstrap('Helpers');
     if ($sslConfig = $this->getBootstrap()->config->ssl) {
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         $auth = $this->getBootstrap()->bootstrap('Auth')->auth;
         $front->registerPlugin(new Omeka_Controller_Plugin_Ssl((string) $sslConfig, $redirector, $auth));
     }
     // Add a default content-type fallback.
     $front->registerPlugin(new Omeka_Controller_Plugin_DefaultContentType());
     return $front;
 }
 /**
  * @group ZF-9724
  */
 public function testShouldSetDispatcherFromConfiguration()
 {
     require_once 'Zend/Application/Resource/Frontcontroller.php';
     $resource = new Zend_Application_Resource_Frontcontroller(array('dispatcher' => array('class' => 'ZF9724_Dispatcher', 'params' => array('bar' => 'baz'))));
     $resource->init();
     $front = $resource->getFrontController();
     $this->assertEquals('ZF9724_Dispatcher', get_class($front->getDispatcher()));
     $this->assertEquals('baz', $front->getDispatcher()->getParam('bar'));
 }
Пример #8
0
 /**
  * Disable view renderering, change the module controller directory name,
  * and pass in our own dispatcher.
  *
  * @return \Zend_Controller_Front
  */
 public function init()
 {
     $dispatcher = new Dispatcher();
     $this->getFrontController()->setDispatcher($dispatcher)->setParam('prefixDefaultModule', true)->setModuleControllerDirectoryName('src/Controller');
     return parent::init();
 }
Пример #9
0
 /**
  * @group ZF-7367
  */
 public function testPassingReturnResponseFlagShouldAlterFrontControllerStatus()
 {
     require_once 'Zend/Application/Resource/Frontcontroller.php';
     $resource = new Zend_Application_Resource_Frontcontroller(array('returnresponse' => true));
     $resource->init();
     $front = $resource->getFrontController();
     $this->assertTrue($front->returnResponse());
 }