示例#1
0
 /**
  * Instance construct
  */
 public function __construct()
 {
     /**
      * Create default DI
      */
     $this->di = new DI\FactoryDefault();
     $this->config = ZFactory::config();
     if ($this->config->website->baseUri == '') {
         if ($_SERVER['SERVER_PORT'] != '443') {
             $this->config->website->baseUri = 'http://' . $_SERVER['HTTP_HOST'] . str_replace(['/public/index.php', '/index.php'], '', $_SERVER['SCRIPT_NAME']);
         } else {
             $this->config->website->baseUri = 'https://' . $_SERVER['HTTP_HOST'] . str_replace(['/public/index.php', '/index.php'], '', $_SERVER['SCRIPT_NAME']);
         }
     }
     $this->di->set('config', $this->config);
     /**
      * @define bool DEBUG
      */
     define('DEBUG', $this->config->debug);
     /**
      * @define string BASE_URI
      */
     define('BASE_URI', $this->config->website->baseUri);
     include ROOT_PATH . '/app/libraries/Core/Utilities/ZFunctions.php';
     parent::__construct($this->di);
 }
示例#2
0
 public function __construct($env, \Phalcon\DiInterface $di = null)
 {
     /**
      * set environment
      */
     self::$env = strtolower($env);
     switch ($this::$env) {
         case self::ENV_PRODUCTION:
             ini_set('display_errors', 0);
             ini_set('display_startup_errors', 0);
             error_reporting(0);
             break;
         case self::ENV_TESTING:
         case self::ENV_DEVELOPMENT:
             ini_set('display_errors', 1);
             ini_set('display_startup_errors', 1);
             error_reporting(-1);
             break;
         default:
             throw new \Exception('Wrong application $env passed: ' . $env);
     }
     /**
      * register di
      */
     if (is_null($di)) {
         $di = new \Phalcon\DI\FactoryDefault();
     }
     /**
      * Read the configuration
      */
     $config =& $this->config;
     $config = new \Phalcon\Config(include ROOT_PATH . '/config/config.php');
     $di->set('config', $config);
     parent::__construct($di);
 }
示例#3
0
 /**
  * @param string $env
  * @param array $configuration
  * @param \Phalcon\DiInterface $di
  * @throws \Exception
  */
 public function __construct($env, array $configuration, \Phalcon\DiInterface $di = null)
 {
     $this->env = strtolower($env);
     $this->configuration = $configuration;
     switch ($this->env) {
         case self::ENV_PRODUCTION:
         case self::ENV_STAGING:
             ini_set('display_errors', 0);
             ini_set('display_startup_errors', 0);
             error_reporting(0);
             break;
         case self::ENV_TESTING:
         case self::ENV_DEVELOPMENT:
             ini_set('display_errors', 1);
             ini_set('display_startup_errors', 1);
             error_reporting(-1);
             break;
         default:
             throw new \Exception('Wrong application $env passed: ' . $env);
     }
     if (is_null($di)) {
         $di = new \Phalcon\DI\FactoryDefault();
     }
     parent::__construct($di);
 }
示例#4
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     /**
      * Create default DI.
      */
     $di = new DI\FactoryDefault();
     /**
      * Get config.
      */
     $this->_config = Config::factory();
     if (!$this->_config->installed) {
         define('CHECK_REQUIREMENTS', true);
         require_once PUBLIC_PATH . '/requirements.php';
     }
     /**
      * Setup Registry.
      */
     $registry = new Registry();
     $registry->modules = array_merge([self::SYSTEM_DEFAULT_MODULE, 'user'], $this->_config->modules->toArray());
     $registry->widgets = $this->_config->widgets->toArray();
     $registry->directories = (object) ['engine' => ROOT_PATH . '/app/engine/', 'modules' => ROOT_PATH . '/app/modules/', 'plugins' => ROOT_PATH . '/app/plugins/', 'widgets' => ROOT_PATH . '/app/widgets/', 'libraries' => ROOT_PATH . '/app/libraries/'];
     $di->set('registry', $registry);
     // Store config in the DI container.
     $di->setShared('config', $this->_config);
     parent::__construct($di);
 }
示例#5
0
 /**
  * Application constructor.
  * @param \Phalcon\DiInterface|null $dependencyInjector
  * @param Config $config
  */
 public function __construct(\Phalcon\DiInterface $dependencyInjector = null, Config $config)
 {
     parent::__construct($dependencyInjector);
     $this->config = $config;
     $this->_eventsManager = new Manager();
     $dependencyInjector->set('config', $config);
     $this->attachBootstrapEvents();
 }
示例#6
0
 /**
  * Bootstrap constructor - set the dependency Injector
  *
  * @package     las
  * @version     1.0
  *
  * @param \Phalcon\DiInterface $di
  */
 public function __construct(\Phalcon\DiInterface $di)
 {
     $this->_di = $di;
     $loaders = array('config', 'loader', 'timezone', 'i18n', 'db', 'filter', 'flash', 'crypt', 'auth', 'session', 'cookie', 'cache', 'url', 'router');
     // Register services
     foreach ($loaders as $service) {
         $this->{$service}();
     }
     // Register modules
     $this->registerModules(array('frontend' => array('className' => 'Las\\Frontend\\Module', 'path' => ROOT_PATH . '/app/frontend/Module.php'), 'admin' => array('className' => 'Las\\Backend\\Module', 'path' => ROOT_PATH . '/app/backend/Module.php'), 'doc' => array('className' => 'Las\\Doc\\Module', 'path' => ROOT_PATH . '/app/doc/Module.php')));
     // Register the app itself as a service
     $this->_di->set('app', $this);
     // Set the dependency Injector
     parent::__construct($this->_di);
 }
示例#7
0
 /**
  * Constructor
  */
 public function __construct()
 {
     if (empty($this->_configPath)) {
         $class = new \ReflectionClass($this);
         throw new \Engine\Exception('Application has no config path: ' . $class->getFileName());
     }
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces(['Engine' => ROOT_PATH . '/engine']);
     $loader->register();
     // create default di
     $di = new \Phalcon\DI\FactoryDefault();
     // get config
     $this->_config = (include_once ROOT_PATH . $this->_configPath);
     // Store config in the Di container
     $di->setShared('config', $this->_config);
     parent::__construct($di);
 }
示例#8
0
 public function __construct(\Phalcon\DI $di = null)
 {
     if (!self::$_alreadyInit) {
         self::$_alreadyInit = true;
         self::$_instance = $this;
         self::$_token = Tokenizer::randomToken();
         $this->loader = new Autoloader(self::$_token);
         new Constants();
         $this->definePermissionGroups();
         $this->di = $di == null ? new DependencyInjection() : $di;
         $this->_registerServices();
         parent::__construct($this->di);
         $this->_registerDefaultModule();
         $this->_registerModules();
         $this->_registerListeners();
         $this->debug = new \Phalcon\Debug();
     } else {
         self::throwException(null, 100);
     }
 }
示例#9
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     /**
      * Create default DI.
      */
     $di = new DI\FactoryDefault();
     /**
      * Get config.
      */
     $this->_config = Config::factory();
     /**
      * Adding modules to registry to load.
      * Module namespace - directory will be load from here.
      */
     $registry = new PhRegistry();
     $registry->modules = array_merge([self::SYSTEM_DEFAULT_MODULE], $this->_config->modules->toArray());
     $registry->directories = (object) ['engine' => ROOT_PATH . '/app/engine/', 'modules' => ROOT_PATH . '/app/modules/'];
     $di->set('registry', $registry);
     /**
      * Store config in the DI container.
      */
     $di->setShared('config', $this->_config);
     parent::__construct($di);
 }
示例#10
0
 /**
  * @param DiInterface $dependencyInjector
  */
 public function __construct(DiInterface $dependencyInjector)
 {
     parent::__construct($dependencyInjector);
     $this->useImplicitView(false);
 }
示例#11
0
 public function __construct(Bootstrap $bootstrap)
 {
     parent::__construct($bootstrap->getDI());
     $this->bootstrap = $bootstrap;
     $this->config = $bootstrap->getConfig();
 }
示例#12
0
 /**
  * Creates an extended Phalcon Application that additionally
  * loads environment variables and bootstraps important handlers.
  * 
  * @param DependencyInjector|null $dependencyInjector       
  */
 public function __construct($rootDir, $configFile, DependencyInjector $DI)
 {
     parent::__construct($DI);
     $this->setRootDirectory($rootDir);
     $this->setConfigFile($configFile);
 }
示例#13
0
 /**
  * Class constructor registers autoloading and error
  * handler.
  *
  * @param mixed $dependencyInjector
  * @return \Phalcon\Error\Application
  */
 public function __construct(DiInterface $dependencyInjector = null)
 {
     $this->registerAutoloaders();
     ErrorHandler::register();
     parent::__construct($dependencyInjector);
 }
示例#14
0
 public function __construct($di)
 {
     parent::__construct($di);
     $this->config = ApplicationConfig::getConfig();
     self::$app = $this;
 }
示例#15
0
 public function __construct($projectPath, $environment = Application::ENVIRONMENT_DEV)
 {
     $this->application = new Application($this, $projectPath, $environment);
     parent::__construct();
 }