public function __construct() { if ($this->config === null) { $this->config = config::getConfig(__CLASS__); } $this->config['cookie.user'] .= ':' . crc32(environment::getCurrentEnvironment()); }
public function __construct() { $tokenClass = config::getConfig(__CLASS__)['token_class']; $this->token_class = new $tokenClass(); if (!$this->token_class instanceof tokenManagerInterface) { throw new tokenManagerException("{$tokenClass} is not implements tokenManagerInterface"); } }
/** * @return mixed */ private function getConfig() { static $config; if ($config === null) { $config = config::getConfig(__CLASS__); } return $config; }
public function __construct() { $config = config::getConfig(__CLASS__); $this->cookie = $config['cookie']; $this->cookie['name'] .= ':' . crc32(environment::getCurrentEnvironment()); $aclClass = $config['acl_class']; $this->aclManager = new $aclClass(); if (!$this->aclManager instanceof aclManagerInterface) { throw new aclException("{$aclClass} is not implements aclManagerInterface"); } }
protected function getPackageConfig() { static $config; if ($config === null) { $config = config::getConfig(get_called_class()); } if (!isset($config[$this->configSection])) { // TODO :: Check, really configurationException needed to throw or factoryException throw new configurationException("Unable to find configSection: \"{$this->configSection}\""); } return $config[$this->configSection]; }
/** * Initialize driver and connect to host * * @var string $configSection * @throws cacheException */ public function __construct($configSection = 'default') { $this->factoryConstruct($configSection); $config = config::getConfig(__CLASS__); if (!isset($config[$configSection])) { throw new cacheException("Config section {$configSection} not found!"); } $this->memcached = new \Memcached(); foreach ($config[$configSection]['servers'] as $server) { $this->memcached->addServer($server['host'], $server['port']); } }
/** * @return mongoInstance * @throws storageException */ public function storage() { if ($this->storageInstance === null) { $config = config::getConfig(get_called_class()); $this->mongoCrudStorageConfig = $config['storage']; if (!array_key_exists('configSection', $this->mongoCrudStorageConfig)) { throw new storageException('Unable to find config[storage][configSection] in case of mongoCrud usage'); } $this->storageInstance = mongoInstance::factory($this->mongoCrudStorageConfig['configSection']); } return $this->storageInstance; }
/** * Constructor */ public function __construct() { profiler::addStack('view::init'); if (!defined('SMARTY_MBSTRING')) { define(SMARTY_MBSTRING, true); } $options = config::getConfig(get_called_class()); parent::__construct(); $this->force_compile = $options['force_compile']; $this->debugging = $options['debugging']; $this->caching = $options['caching']; $this->cache_lifetime = $options['cache_lifetime']; $this->setCompileDir($options['compile_dir']); $this->setConfigDir($options['config_dir']); $this->setCacheDir($options['cache_dir']); }
/** * Executes the current command. * * This method is not because you can use this class * as a concrete class. In this case, instead of defining the * execute() method, you set the code to execute by passing * a Closure to the setCode() method. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|int null or 0 if everything went fine, or an error code * * @throws \LogicException When this method is not implemented * * @see setCode() */ protected function handle(InputInterface $input, OutputInterface $output) { $this->output = $output; $smartyDir = dirname(rtrim(config::getConfig('mpcmf_system_view_smartyDriver')['config_dir'], '/')); if (file_exists($smartyDir)) { @shell_exec("chmod -R 0777 '{$smartyDir}' && chmod -R 0777 '{$smartyDir}'"); } else { @mkdir($smartyDir, 0777, true); } $this->prepareThreads($input); $this->checkThreads(); $masterServerAddr = $input->getOption('master-server'); if ($masterServerAddr) { $this->masterServer($this->parseAddr($masterServerAddr)); } else { for (;;) { $this->checkThreads(); sleep(1); } } }
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ use Monolog\Logger; use mpcmf\system\configuration\config; use mpcmf\system\helper\io\codes; $level = Logger::DEBUG; config::setConfig(__FILE__, ['default' => [codes::RESPONSE_CODE_FAIL => 'Ошибка:( %s', codes::RESPONSE_CODE_OK => 'Всё хорошо.', codes::RESPONSE_CODE_SAVED => 'Объект %s сохранён!', codes::RESPONSE_CODE_REMOVED => 'Объект удалён!', codes::RESPONSE_CODE_CREATED => 'Объект %s создан!']]);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['cookie' => ['name' => 'mpcmf:user', 'expire' => '+1 day'], 'acl_class' => 'mpcmf\\modules\\authex\\simpleAclManager']);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['name' => 'Web application base', 'slim' => ['debug' => true, 'log.enabled' => true, 'templates.path' => null, 'view' => '\\mpcmf\\system\\view\\smartyDriver', 'cookies.encrypt' => true, 'cookies.lifetime' => '60 minutes', 'cookies.path' => '/', 'cookies.domain' => null, 'cookies.secure' => false, 'cookies.httponly' => false, 'cookies.secret_key' => 'CHANGE_THIS_SECRET_KEY', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, 'http.version' => '1.1']]);
<?php /** * mongoInstance configuration * * @author Gregory Ostrovsky <*****@*****.**> */ use mpcmf\system\configuration\config; use mpcmf\system\configuration\environment; config::setConfig(__FILE__, ['default' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]], 'localhost' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]]]); config::setConfig(__FILE__, ['localhost' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]]], environment::ENV_PRODUCTION);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, []);
/** * Get micro-web-framework object * * @param null $instance * @param string|null $appKey * * @return Slim * @throws webApplicationException */ public function slim($instance = null, $appKey = null) { if ($appKey === null) { $appKey = get_called_class(); } if ($instance !== null) { self::$slimInstance[$appKey] = $instance; } elseif (!isset(self::$slimInstance[$appKey])) { $config = array_replace_recursive(config::getConfig(__CLASS__), $this->getPackageConfig()); if (!isset($config['slim'], $config['name'])) { throw new webApplicationException('Undefined required config sections: slim, name'); } self::$slimInstance[$appKey] = new Slim($config['slim']); self::$slimInstance[$appKey]->setName($appKey); set_error_handler(array('\\Slim\\Slim', 'handleErrors')); //Apply final outer middleware layers if (self::$slimInstance[$appKey]->config('debug')) { //Apply pretty exceptions only in debug to avoid accidental information leakage in production self::$slimInstance[$appKey]->add(new PrettyExceptions()); } } return self::$slimInstance[$appKey]; }
<?php use Monolog\Logger; use mpcmf\system\configuration\config; use mpcmf\system\configuration\environment; $path = '/tmp/mpcmf.log'; $defaultLevel = Logger::DEBUG; config::setConfig(__FILE__, ['default' => ['name' => 'BaseLog', 'path' => 'php://stdout', 'level' => $defaultLevel], 'applicationBase' => ['name' => 'ApplicationLog', 'path' => 'php://stdout', 'level' => $defaultLevel], 'controllerBase' => ['name' => 'ControllerLog', 'path' => 'php://stdout', 'level' => $defaultLevel]]); $productionLevel = MPCMF_DEBUG ? Logger::DEBUG : Logger::NOTICE; config::setConfig(__FILE__, ['default' => ['name' => 'BaseLog', 'path' => "{$path}/mpcmf.log", 'level' => $productionLevel], 'applicationBase' => ['name' => 'ApplicationLog', 'path' => "{$path}/mpcmf.log", 'level' => $productionLevel], 'controllerBase' => ['name' => 'ControllerLog', 'path' => "{$path}/mpcmf.log", 'level' => $productionLevel]], environment::ENV_PRODUCTION); MPCMF_DEBUG && config::setConfigByEnvironment(__FILE__, environment::ENV_PRODUCTION);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['compile_dir' => '/tmp/mpcmf/smarty/templates_c/', 'config_dir' => '/tmp/mpcmf/smarty/configs/', 'cache_dir' => '/tmp/mpcmf/smarty/templates_cache/', 'cache_lifetime' => 3600, 'caching' => true, 'debugging' => false, 'force_compile' => true]);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ use mpcmf\system\configuration\config; config::setConfig(__FILE__, ['localhost' => ['host' => '127.0.0.1', 'port' => '5672', 'login' => 'guest', 'password' => 'guest']]);
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['token_class' => \mpcmf\apps\mpcmfWeb\libraries\acl\defaultTokenManager::class]);
<?php use Monolog\Logger; use mpcmf\system\configuration\config; $path = '/tmp/mpcmf.log'; $defaultLevel = Logger::DEBUG; config::setConfig(__FILE__, ['default' => ['name' => 'BaseLog', 'path' => 'php://stdout', 'level' => $defaultLevel], 'applicationBase' => ['name' => 'ApplicationLog', 'path' => 'php://stdout', 'level' => $defaultLevel], 'controllerBase' => ['name' => 'ControllerLog', 'path' => 'php://stdout', 'level' => $defaultLevel]]);
<?php /** * mongoInstance configuration * * @author Gregory Ostrovsky <*****@*****.**> */ use mpcmf\system\configuration\config; config::setConfig(__FILE__, ['default' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]], 'mongo01' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]], 'localhost' => ['uri' => 'mongodb://localhost', 'options' => ['connect' => true]]]);
/** * Get package config data * * @return mixed */ protected function getPackageConfig() { return config::getConfig(get_called_class()); }
<?php /** * @author greevex * @date : 11/16/12 5:11 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['cookie' => ['name' => 'mpcmf:user', 'expire' => '+1 day'], 'acl_class' => \mpcmf\apps\mpcmfWeb\libraries\acl\defaultAclManager::class]);
<?php /** * @author gilberg.vrn * @date : 5/29/15 10:55 PM */ \mpcmf\system\configuration\config::setConfig(__FILE__, ['default' => ['servers' => [['host' => 'localhost', 'port' => 11211]]]]);
public function saveMapperConfig() { $smarty = $this->smarty(); $smarty->appendData(['entityData' => $this->entityData]); $filepath = config::getConfigFilepath($this->entityData['struct']['mapper']['fullClassName']); file_put_contents($filepath, $smarty->render('mapperConfig.tpl', true)); }