public function __construct() { $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions(__DIR__ . '/config.php'); $container = $containerBuilder->build(); parent::__construct($container); }
/** * Shiniwork constructor. * * @param array $settings */ public function __construct(array $settings = []) { session_start(); $container = new Settings($settings); parent::__construct($container); $this->registerView()->registerDatabase()->registerMailer()->registerJWT()->addJWTMiddleware(); }
/** * * @param array $routes * @param unknown $options */ public function __construct(array $routes, $options = null) { parent::__construct($options); $this->container = $this->getContainer(); $this->_routes = $routes; $this->resolve(); }
/** * {@inheritdoc} */ public function __construct(Container $container = null) { $container = $container ?: new Container(); $container->delegate(new ReflectionContainer()); $container->addServiceProvider(new SlimServiceProvider()); parent::__construct($container); }
/** * App constructor. * * @param $basePath */ public function __construct($basePath) { $this->setBasePath($basePath); $this->init(); $container = new SlimContainer(); parent::__construct($container); self::$instance = $this; }
/** * @param ContainerInterface|array $container */ public function __construct($container = []) { parent::__construct($container); $this->getContainer()['app'] = function () { return $this; }; $this->setupEnvData(); $this->loadRoutes(); $this->setupNotFound(); }
/** * {@inheritdoc} */ public function __construct($userSettings = []) { parent::__construct($userSettings); if ($userSettings['debug']) { $this->debug = $userSettings['debug']; } $this->config = Config::getInstance(); $this->registerHandlers(); $this->registerServices(); }
/** * Create a new application. * * @param string $basePath */ public function __construct($basePath) { if (is_null($basePath)) { throw new \InvalidArgumentException("The base path has not been set."); } parent::__construct(); // Make the container instance used by this application // globally available. Container::setInstance($this->getContainer()); $this->setBasePath($basePath); $this->bootstrap(); }
/** * @param ContainerInterface|array $container */ public function __construct($container = []) { parent::__construct($container); $this->getContainer()['app'] = function () { return $this; }; $this->setupServices(); $this->setupEnvData(); $this->loadRoutes(); $this->setupNotFound(); $this->setupErrorHandler(); Model::setApp($this); }
public function __construct($container = null) { parent::__construct($container); $this->loadDI(); $this->loadPlugins(); }
/** * @param array|\Interop\Container\ContainerInterface $config * @param $debug */ public function __construct($config, $debug) { $config['displayErrorDetails'] = $debug; parent::__construct(['settings' => $config]); }
function __construct($settings) { parent::__construct($settings); $more = array(); self::$instance = $this; }
public function __construct($container = []) { parent::__construct($container); $this->setUpRoutes(); $this->setupRenderer(); }
/** * Constructor * * @param array|ContainerInterface $container Instancia de Container o array de configuración. Default: [] */ public function __construct($container = []) { parent::__construct($container); $this->registerDafaultServicesProvider(); $this->registerServiceProviders(); }
/** * @internal */ public function __construct($userSettings = null) { $configDir = '.'; // Пользовательские настройки // -------------------------- if (!is_array($userSettings)) { $userSettings = array('file' => $userSettings); } if ($file = @$userSettings['file']) { unset($userSettings['file']); if (file_exists($file)) { $configDir = dirname($file); $settings = Utils::loadConfig($file); Log::debug("Configuration load: " . realpath($file)); unset($file); $userSettings = array_merge($userSettings, $settings); } } $userSettings = array_merge($this->defaultsSettings, $userSettings); if ($p = $userSettings['templates.path']) { if (substr($p, 0, 1) !== '/') { $userSettings['templates.path'] = SYSPATH . '/' . $p; } } // if (is_array($userSettings['import'])) { // $import = $userSettings['import']; // foreach ($import as $file) { // $file = $configDir . '/' . $file; // $settings = Utils::loadConfig($file); // if ($settings) { // $defaultSettings = array_merge($defaultSettings, $settings); // Log::debug("Configuration import", // array(realpath($file))); // } // } // } parent::__construct((array) $userSettings); $app =& $this; // Если Internet Explorer, то шлем на хуй /* if (preg_match('/(rv:11.0|MSIE)/i', $_SERVER['HTTP_USER_AGENT'])) { $app->log->warning('Bad Browser ', array('HTTP_USER_AGENT'=>$_SERVER['HTTP_USER_AGENT'])); $app->redirect( "http://fobia.github.io/docs/badbrowser.html" ); exit(); } */ // // Автоматическая загрузка секций конфигурации // ---------------------------------------------- $autoload = $this['settings']['app.autoload']; if ($autoload) { $this['settings']['app'] = new \Pimple(); $this['settings']['app']['autoload'] = $autoload; if (is_array($autoload)) { foreach (@$autoload as $cfg => $file) { $this['settings']['app'][$cfg] = function ($c) use($cfg, $file, $configDir) { Log::debug(">> autoload config", array($cfg, $file)); if (!file_exists($configDir . "/{$file}")) { trigger_error("Нет автозагрузочной секции конфигурации '{$cfg}'" . "/{$file}", E_USER_ERROR); return; } return Utils::loadConfig($file); }; } } } unset($autoload, $cfg, $file); // Session // session.gc_maxlifetime = 1440 // ;setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): // ------------------ $this['session'] = function ($c) { $sid = null; if ($c['settings']['session.cookie'] && @$_COOKIE['SID']) { $sid = $_COOKIE['SID']; session_id($sid); } $session = new \Slim\Session($c['settings']['session.handler']); @$session->start(); if ($c['settings']['session.encrypt'] === true) { $session->decrypt($c['crypt']); } if ($sid === null) { $sid = session_id(); if ($c['settings']['session.cookie']) { @$c->setCookie('SID', $sid, time() + 1440); Log::debug('Session save cookie'); } } Log::debug('Session start', array($sid)); return $session; }; // View // ------------------ $this['view'] = function ($c) { $view = $c['settings']['view']; if ($view instanceof \Slim\Interfaces\ViewInterface !== false) { return $view; } $view = new \Slim\Views\Smarty($c['settings']['templates.path']); $view->parserExtensions = SRC_DIR . '/src/Slim/Views/SmartyPlugins'; $view->parserCompileDirectory = CACHE_DIR . '/templates'; $view->parserCacheDirectory = CACHE_DIR; return $view; }; // Database // ------------------ $this['db'] = function ($c) { $db = \Fobia\DataBase\DbFactory::create($c['settings']['database']); \ezcDbInstance::set($db); return $db; }; // Auth // ------------------ $this['auth'] = function ($c) use($app) { $auth = new \Fobia\Auth\Authentication($app); $auth->authenticate(); return $auth; }; // API // ------------------ // $this['apiHandler'] = function() { // return new \Api\ApiHandler(); // }; // $this['api'] = $this->protect(function($method, $params = null) use ($app) { // $result = $app['apiHandler']->request($method, $params); // return $result; // }); // ------------------ if (!self::$instance[0]) { self::setInstance($this); } }
/** * Create new Charcoal application (and SlimApp). * * ### Dependencies * * **Required** * * - `config` — AppConfig * * **Optional** * * - `logger` — PSR-3 Logger * * @uses SlimApp::__construct() * @param ContainerInterface|array $container The application's settings. * @throws LogicException If trying to create a new instance of a singleton. */ public function __construct($container = []) { if (isset(static::$instance)) { throw new LogicException(sprintf('"%s" is a singleton. Use static instance() method.', get_called_class())); } // Ensure the DI container is if (is_array($container)) { $container = new AppContainer($container); } // SlimApp constructor parent::__construct($container); if (isset($container['config'])) { $this->setConfig($container['config']); } }