Ejemplo n.º 1
0
 /**
  * Constructor method.
  *
  * The first argument of the class constructor is the name of the application environment.
  * The second argument is an array of application configurations, an instance of Zend_Config or a config file path.
  * It can contain the application name (options["app"]) and the application path (options["app"]).
  *
  * The application constructor includes the required base classes:
  * Exception, Hook, Singleton, Class, Loader automatically.
  * After the required classes included the application, the Enlight Loader registers
  * the Enlight library namespace and initials the
  * Hook, Event and Plugin manager which stores and manages all
  * registered plugins, events and hooks.
  *
  * If all components are included the Enlight configuration is loaded by the
  * given options parameter.
  * After the configuration is loaded, the application name and path is taken from the config and set in the class properties.
  *
  * @param string $environment
  * @param array $options
  * @param Container $container
  */
 public function __construct($environment, array $options, Container $container)
 {
     self::$instance = $this;
     $this->environment = $environment;
     $this->path = dirname(dirname(__FILE__)) . $this->DS();
     $this->core_path = $this->path . 'Enlight' . $this->DS();
     $this->_loader = $container->get('Loader');
     if (!empty($options['app'])) {
         $this->app = $options['app'];
     } elseif (!isset($this->app)) {
         $this->app = 'Default';
     }
     if (!empty($options['app_path'])) {
         $options['appPath'] = $options['app_path'];
     }
     // Set default path
     if (!isset($this->appPath)) {
         $this->appPath = 'Apps/' . $this->app;
     }
     // Resolve relative path
     $this->appPath = $this->_loader->isReadable($this->appPath);
     $this->appPath = realpath($this->appPath) . $this->DS();
     if (!is_dir($this->appPath)) {
         throw new Exception('App "' . $this->app . '" with path "' . $this->appPath . '" not found failure');
     }
     $this->setOptions($options);
     $this->_hooks = $container->get('hooks');
     $this->_events = $container->get('events');
 }
Ejemplo n.º 2
0
 /**
  * Constructor method.
  *
  * The first argument of the class constructor is the name of the application environment.
  * The second argument is an array of application configurations, an instance of Zend_Config or a config file path.
  * It can contain the application name (options["app"]) and the application path (options["app"]).
  *
  * The application constructor includes the required base classes:
  * Exception, Hook, Singleton, Class, Loader automatically.
  * After the required classes included the application, the Enlight Loader registers
  * the Enlight library namespace and initials the
  * Hook, Event and Plugin manager which stores and manages all
  * registered plugins, events and hooks.
  *
  * If all components are included the Enlight configuration is loaded by the
  * given options parameter.
  * After the configuration is loaded, the application name and path is taken from the config and set in the class properties.
  *
  * @param string $environment
  * @param mixed $options
  */
 public function __construct($environment, $options = null)
 {
     self::$instance = $this;
     $this->environment = $environment;
     $this->path = dirname(dirname(__FILE__)) . $this->DS();
     $this->core_path = $this->path . 'Enlight' . $this->DS();
     require_once 'Enlight/Exception.php';
     require_once 'Enlight/Hook.php';
     require_once 'Enlight/Singleton.php';
     require_once 'Enlight/Class.php';
     require_once 'Enlight/Loader.php';
     $this->_loader = new Enlight_Loader();
     $this->_loader->registerNamespace('Enlight', 'Enlight/');
     $this->_hooks = new Enlight_Hook_HookManager($this);
     $this->_events = new Enlight_Event_EventManager($this);
     $this->_plugins = new Enlight_Plugin_PluginManager($this);
     $options = $this->loadConfig($options);
     if (!empty($options['app'])) {
         $this->app = $options['app'];
     } else {
         $this->app = 'Default';
     }
     if (!empty($options['app_path'])) {
         $options['appPath'] = $options['app_path'];
     }
     if (!empty($options['appPath'])) {
         $this->appPath = realpath($options['appPath']) . $this->DS();
     } else {
         $this->appPath = realpath('Apps/' . $this->app) . $this->DS();
     }
     if (!file_exists($this->appPath) && !is_dir($this->appPath)) {
         throw new Exception('App "' . $this->app . '" with path "' . $this->appPath . '" not found failure');
     }
     $this->_loader->registerNamespace($this->App(), $this->AppPath());
     $this->setOptions($options);
 }