protected function getClass(ReflectionClass $class, Config $config = null, $name = null) { $parameters = $this->getConstructor($class)->getParameters(); $values = array(); if (!$config && $parameters) { throw new MissingConfigurationException('Missing configuration for utility class ' . $class->getName()); } foreach ($parameters as $i => $parameter) { if ($parameter->getClass() && $parameter->getClass()->getName() === 'Cohesion\\Structure\\Config' || $parameter->getName() === 'config') { $values[] = $config; } else { if ($config->get($parameter->getName()) !== null) { if ($parameter->getClass()) { $values[] = $this->getClass($parameter->getClass(), $config->getConfig($parameter->getName()), $parameter->getName()); } else { $values[] = $config->get($parameter->getName()); } } else { if (!$parameter->isOptional()) { if (!$name) { $name = $class->getShortName(); } throw new MissingConfigurationException("Missing configuration for {$name} {$parameter->getName()}"); } else { $values[] = $parameter->getDefaultValue(); } } } } return $class->newInstanceArgs($values); }
public function __construct(FacebookUserServiceInterface $userService, Config $config) { parent::__construct($userService); $this->config = $config->getConfig('utility.Facebook'); $this->appId = $this->config->get('app_id'); $this->secret = $this->config->get('secret'); $this->permissions = $this->config->get('permissions'); $this->redirectUrl = $config->get('global.base_url') . $config->get('global.uri'); $this->siteName = $config->get('global.site_name'); }
public function __construct() { $this->environment = isset($_SERVER['APPLICATION_ENV']) ? $_SERVER['APPLICATION_ENV'] : null; $config = new Config(); $config->loadFromFile(CONFIG_DIR . 'cohesion-default-conf.json'); $config->loadFromFile(CONFIG_DIR . 'default-conf.json'); if ($this->environment) { $envConfFile = CONFIG_DIR . $this->environment . '-conf.json'; if (file_exists($envConfFile)) { $config->loadFromFile($envConfFile); } else { throw new \Exception("Missing config file for {$this->environment} environment"); } } $this->config = $config; $global = $config->get('global'); $domain = $config->get('global.domain_name'); if ($domain) { $global['abs_base_url'] = "http://{$domain}"; $global['ssl_base_url'] = "https://{$domain}"; $global['base_url'] = $global['abs_base_url']; } if ($this->environment == 'production' || $config->get('global.production')) { $global['production'] = true; $this->production = true; } if ($config->get('data_access.cache.driver') == 'APC') { $cache = new APC(); $global['cache'] = $cache; } $config->merge('global', $global); RoutingFactory::$config = $this->getConfig('routing'); ViewFactory::$config = $this->getConfig('view'); ViewFactory::$environment = $this; }
public function __construct(DataAccessFactory $daoFactory, Config $config = null, $user = null) { $this->daoFactory = $daoFactory; $this->config = $config; if ($config && $config->get(static::UTILITY_CONFIG_SECTION)) { $utilConfig = $config->getConfig(static::UTILITY_CONFIG_SECTION); } else { $utilConfig = $config; } $this->utilFactory = new UtilityFactory($utilConfig); $this->user = $user; $this->services = array(); $this->cyclicDependancies = array(); }
public function __construct(Config $config) { $this->config = $config; $this->versionCache = $config->get('global.cache'); if ($config->get('template.cache.ttl') !== null) { $templateCache = new CohesionMoCache($this->versionCache, $config->get('template.cache.ttl')); } else { $fileCacheDir = $config->get('template.cache.directory'); if ($fileCacheDir) { if ($fileCacheDir[0] !== DIRECTORY_SEPARATOR) { $fileCacheDir = $config->get('global.base_dir') . DIRECTORY_SEPARATOR . $fileCacheDir; } $templateCache = $fileCacheDir; } else { $templateCache = null; } } parent::__construct(array('partials_loader' => new MustacheVariablePartialLoader($config->get('global.base_dir') . DIRECTORY_SEPARATOR . $config->get('template.directory'), array('extension' => $config->get('template.extension'))), 'pragmas' => array('FILTERS'), 'cache' => $templateCache)); }
public function __construct(Config $config) { $this->config = $config; $this->fromName = $config->get('from.name'); $this->fromEmail = $config->get('from.email'); $this->headers = $config->get('headers'); $this->template = $config->get('template'); $this->bccs = $config->get('bccs'); }