本文整理汇总了PHP中sfConfig::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP sfConfig::getAll方法的具体用法?PHP sfConfig::getAll怎么用?PHP sfConfig::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfConfig
的用法示例。
在下文中一共展示了sfConfig::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
*
* @param string $environment The environment name
* @param Boolean $debug true to enable debug mode
* @param string $rootDir The project root directory
* @param sfEventDispatcher $dispatcher An event dispatcher
*/
public function __construct($environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null)
{
$this->environment = $environment;
$this->debug = (boolean) $debug;
$this->application = str_replace('Configuration', '', get_class($this));
parent::__construct($rootDir, $dispatcher);
$this->configure();
$this->initConfiguration();
if (sfConfig::get('sf_check_lock'))
{
$this->checkLock();
}
if (file_exists($file = sfConfig::get('sf_app_cache_dir').'/config/configuration.php'))
{
$this->cache = require $file;
}
$this->initialize();
// store current sfConfig values
$this->config = sfConfig::getAll();
}
示例2: getContext
/**
* Returns the current application context.
*
* @param bool $forceReload true to force context reload, false otherwise
*
* @return sfContext
*/
public function getContext($forceReload = false)
{
if (null === $this->context || $forceReload) {
$isContextEmpty = null === $this->context;
$context = $isContextEmpty ? sfContext::getInstance() : $this->context;
// create configuration
$currentConfiguration = $context->getConfiguration();
$configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug());
// connect listeners
$configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'listenToException'));
foreach ($this->listeners as $name => $listener) {
$configuration->getEventDispatcher()->connect($name, $listener);
}
// create context
$this->context = sfContext::createInstance($configuration);
unset($currentConfiguration);
if (!$isContextEmpty) {
sfConfig::clear();
sfConfig::add($this->rawConfiguration);
} else {
$this->rawConfiguration = sfConfig::getAll();
}
}
return $this->context;
}
示例3: remove
/**
* Removes a key from symfony config
*/
public function remove($key)
{
$all = sfConfig::getAll();
unset($all[$key]);
sfConfig::clear();
sfConfig::add($all);
return $this;
}
示例4: execute
protected function execute($arguments = array(), $options = array())
{
parent::execute($arguments, $options);
$this->mailLog('starting openpne:send-birthday-mail-lite task');
// load templates
list($pcTitleTpl, $pcTpl) = $this->getTwigTemplate('pc', 'birthday_lite');
$birthday = $this->fetchRow('SELECT id, is_edit_public_flag, default_public_flag FROM ' . $this->getTableName('Profile') . ' WHERE name = ?', array('op_preset_birthday'));
if (!$birthday) {
throw new sfException('This project doesn\'t have the op_preset_birthday profile item.');
}
if (!$birthday['is_edit_public_flag'] && ProfileTable::PUBLIC_FLAG_PRIVATE == $birthday['default_public_flag']) {
throw new sfException('all user\'s op_preset_birthday public_flag is hidden from backend');
}
$birthDatetime = new DateTime();
$birthDatetime->modify('+ 1 week');
$query = 'SELECT member_id FROM ' . $this->getTableName('MemberProfile') . ' WHERE profile_id = ? AND DATE_FORMAT(value_datetime, ?) = ?';
$params = array($birthday['id'], '%m-%d', $birthDatetime->format('m-d'));
if ($birthday['is_edit_public_flag']) {
$query .= ' AND public_flag <> ?';
$params[] = ProfileTable::PUBLIC_FLAG_PRIVATE;
}
if (null !== $options['start-member-id'] && is_numeric($options['start-member-id'])) {
$query .= ' AND member_id >= ?';
$params[] = $options['start-member-id'];
}
if (null !== $options['end-member-id'] && is_numeric($options['end-member-id'])) {
$query .= ' AND member_id <= ?';
$params[] = $options['end-member-id'];
}
$memberProfilesStmt = $this->executeQuery($query, $params);
if ($memberProfilesStmt instanceof PDOStatement) {
$sf_config = sfConfig::getAll();
$op_config = new opConfig();
while ($memberProfile = $memberProfilesStmt->fetch(Doctrine::FETCH_NUM)) {
$birthMember = $this->getMember($memberProfile[0]);
$birthMember['birthday'] = $birthDatetime->format('U');
$ids = $this->getFriendIds($memberProfile[0]);
foreach ($ids as $id) {
$member = $this->getMember($id);
$pcAddress = $this->getMemberPcEmailAddress($id);
if (!$pcAddress) {
continue;
}
$params = array('member' => $member, 'birthMember' => $birthMember, 'op_config' => $op_config, 'sf_config' => $sf_config);
$subject = $pcTitleTpl->render($params);
$body = $pcTpl->render($params);
try {
$this->sendMail($subject, $pcAddress, $this->adminMailAddress, $body);
$this->mailLog(sprintf("sent member %d birthday notification mail to member %d (usage memory:%s bytes)", $birthMember['id'], $member['id'], number_format(memory_get_usage())));
} catch (Zend_Mail_Transport_Exception $e) {
$this->mailLog(sprintf("%s (about member %d birthday to member %d)", $e->getMessage(), $birthMember['id'], $member['id']));
}
}
}
}
$this->mailLog('end openpne:send-birthday-mail-lite task');
}
示例5: flushConfigs
/** Restores all sfConfig values to their state before the current test was
* run.
*
* @return static
*/
public function flushConfigs()
{
if (isset(self::$_configs)) {
sfConfig::clear();
sfConfig::add(self::$_configs);
} else {
self::$_configs = sfConfig::getAll();
}
return $this;
}
示例6: clearAll
/**
* Clear conf for a given key
*/
public static function clearAll()
{
foreach (sfConfig::getAll() as $key => $value) {
if (preg_match('/^' . self::prefix() . '/', $key, $matches)) {
if (isset($matches[0][1])) {
self::clear($matches[0][1]);
}
}
}
}
示例7: execute
public function execute($request)
{
// loop through application settings and extract enabled i18n languages
foreach (sfConfig::getAll() as $setting => $value) {
if (0 === strpos($setting, 'app_i18n_languages')) {
$enabledI18nLanguages[$value] = format_language($value, $value);
}
}
// sort languages by alpha code to look pretty
ksort($enabledI18nLanguages);
$this->enabledI18nLanguages = $enabledI18nLanguages;
}
示例8: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
// $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$cfg = sfConfig::getAll();
if (!isset($options['application'])) {
echo ' NOTICE: set --application if you want the application config displayed.' . PHP_EOL;
}
if (!isset($options['env'])) {
echo ' NOTICE: set --env if you want the application config displayed.' . PHP_EOL;
}
echo 'Configuration for env = ' . $options['env'] . ', application = ' . $options['application'] . PHP_EOL . PHP_EOL;
print_r($cfg);
}
示例9: execute
/**
* Executes the filter chain.
*
* @param sfFilterChain $filterChain
*/
public function execute($filterChain)
{
$config = sfConfig::getAll();
$host = sfContext::getInstance()->getRequest()->getHost();
foreach ($config as $key => $value) {
if ($key == 'dm_' . $host) {
foreach ($value as $subkey => $subval) {
$config['dm_' . $subkey] = $subval;
}
}
}
sfConfig::clear();
sfConfig::add($config);
$filterChain->execute();
}
示例10: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
* @author uechoco
* @see sfOpenPNEMailSend::getMailTemplate()
*/
public function executeIndex(sfWebRequest $request)
{
$this->getResponse()->setTitle($this->freepage->getTitle());
$context = sfContext::getInstance();
$params['sf_config'] = sfConfig::getAll();
// The renderer name is twig.
// The template name ,which is the first argument of opFreepageTemplateLoaderDoctrine::doLoad(), is Freepage::id.
$view = new sfTemplatingComponentPartialView($context, 'freepage', 'twig:' . $this->freepage->getId(), '');
$context->set('view_instance', $view);
$view->setPartialVars($params);
$view->setAttribute('renderer_config', array('twig' => 'opTemplateRendererTwig'));
$view->setAttribute('rule_config', array('twig' => array(array('loader' => 'opFreepageTemplateLoaderDoctrine', 'renderer' => 'twig', 'model' => 'Freepage'))));
$view->execute();
$this->body = $view->render();
}
示例11: getXCSSConfiguration
/**
* Parses the given configuration from the app.yml into an xCSS config array.
*
* @param bool $force If true, loads the configuration again, otherwise returns cached config, if any.
*
* @return array
*/
public static function getXCSSConfiguration($force = false)
{
static $xCSSConfiguration = array();
if ($force || empty($xCSSConfiguration)) {
$configPrefix = 'app_xcssplugin_';
foreach (sfConfig::getAll() as $entry => $value) {
if (strstr($entry, $configPrefix) !== false) {
$xCSSConfiguration[str_replace($configPrefix, '', $entry)] = $value;
}
}
// set default config items, if not set by user
$xCSSConfiguration = array_merge(self::getDefaultXCSSConfiguration(), $xCSSConfiguration);
}
return $xCSSConfiguration;
}
示例12: buildUrl
/**
* Génération brute de l'url cross app, passer par la fonction genUrl de préference (gestion du cache)
*
* @static
* @throws Exception
* @param string $app
* @param string $url
* @param bool $absolute
* @param string $env
* @param string $initialInstanceName for test purpose
* @return mixed
*/
public static function buildUrl($app, $url, $absolute = false, $env = null, $initialInstanceName = null)
{
$initialApp = sfConfig::get('sf_app');
if ($initialInstanceName == null) {
$initialInstanceName = $initialApp;
}
$initialScriptName = $_SERVER['SCRIPT_NAME'];
$initialFrontController = basename($initialScriptName);
$initialConfig = sfConfig::getAll();
$debug = sfConfig::get('sf_debug');
//environnement par défaut
if ($env == null) {
$env = $initialConfig['sf_environment'];
}
//création du contexte
if (!sfContext::hasInstance($app)) {
sfConfig::set('sf_factory_storage', 'sfNoStorage');
// la config de base est restaurée à la fin de la fonction
sfConfig::set('sf_use_database', false);
$configuration = ProjectConfiguration::getApplicationConfiguration($app, $env, $debug);
$context = sfContext::createInstance($configuration, $app);
unset($configuration);
} else {
$context = sfContext::getInstance($app);
}
//détermination du front controller
$finalFrontController = $app;
if ($env != 'prod') {
$finalFrontController .= '_' . $env;
}
$finalFrontController .= '.php';
$crossUrl = $context->getController()->genUrl($url, $absolute);
unset($context);
//vérrification de l'existence du front controller
if (!file_exists(sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $finalFrontController)) {
throw new Exception('Le front controller ' . $finalFrontController . ' est introuvable.');
}
$crossUrl = str_replace($initialFrontController, $finalFrontController, $crossUrl);
//retour au context initial
if ($app !== $initialInstanceName) {
sfContext::switchTo($initialInstanceName);
sfConfig::clear();
sfConfig::add($initialConfig);
}
return $crossUrl;
}
示例13: executeDailyNews
public function executeDailyNews()
{
$env = 'mobile_frontend' == sfConfig::get('sf_app') ? 'mobile' : 'pc';
$twigEnvironment = new Twig_Environment(new Twig_Loader_String());
$valueTpl = $twigEnvironment->loadTemplate(opDiaryPluginToolkit::getMailTemplate($env, 'diaryGagdet'));
$diaries = Doctrine::getTable('Diary')->getFriendDiaryList($member['id'], 5);
if (!count($diaries)) {
return sfView::NONE;
}
$result = array();
foreach ($diaries as $key => $diary) {
$result[$key]['Member'] = $diary->Member;
$result[$key]['title'] = $diary->title;
$result[$key]['id'] = $diary->id;
}
$params = array('diaries' => $result, 'count' => count($diaries), 'sf_config' => sfConfig::getAll());
$this->value = $valueTpl->render($params);
}
示例14: __construct
/**
* Constructor.
*
* @param string $environment The environment name
* @param Boolean $debug true to enable debug mode
* @param string $rootDir The project root directory
* @param sfEventDispatcher $dispatcher An event dispatcher
*/
public function __construct($environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null)
{
$this->environment = $environment;
$this->debug = (bool) $debug;
$this->application = str_replace('Configuration', '', get_class($this));
parent::__construct($rootDir, $dispatcher);
$this->configure();
$this->initConfiguration();
if (sfConfig::get('sf_check_lock')) {
$this->checkLock();
}
if (sfConfig::get('sf_check_symfony_version')) {
$this->checkSymfonyVersion();
}
$this->initialize();
// store current sfConfig values
$this->config = sfConfig::getAll();
}
示例15: getMailTemplate
public static function getMailTemplate($template, $target = 'pc', $params = array(), $isOptional = true, $context = null)
{
if (!$context) {
$context = sfContext::getInstance();
}
$params['sf_config'] = sfConfig::getAll();
$view = new sfTemplatingComponentPartialView($context, 'superGlobal', 'notify_mail:' . $target . '_' . $template, '');
$context->set('view_instance', $view);
$view->setPartialVars($params);
$view->setAttribute('renderer_config', array('twig' => 'opTemplateRendererTwig'));
$view->setAttribute('rule_config', array('notify_mail' => array(array('loader' => 'sfTemplateSwitchableLoaderDoctrine', 'renderer' => 'twig', 'model' => 'NotificationMail'), array('loader' => 'opNotificationMailTemplateLoaderConfigSample', 'renderer' => 'twig'), array('loader' => 'opNotificationMailTemplateLoaderFilesystem', 'renderer' => 'php'))));
$view->execute();
try {
return $view->render();
} catch (InvalidArgumentException $e) {
if ($isOptional) {
return '';
}
throw $e;
}
}