本文整理汇总了PHP中sfConfig::add方法的典型用法代码示例。如果您正苦于以下问题:PHP sfConfig::add方法的具体用法?PHP sfConfig::add怎么用?PHP sfConfig::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfConfig
的用法示例。
在下文中一共展示了sfConfig::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _restoreSfConfig
protected function _restoreSfConfig()
{
if (!empty($this->_backupSfConfig)) {
sfConfig::clear();
sfConfig::add($this->_backupSfConfig);
}
}
示例2: autoload
/**
* Autoloads symfony
* Note: This is not compatible with ->bootstrap()
* Code adopted from command/sfSymfonyCommandApplication.class.php
*/
public function autoload()
{
if ($this->autoload) {
return;
}
$this->autoload = 'simple';
require_once $this->sf_lib_dir . '/util/sfCore.class.php';
require_once $this->sf_lib_dir . '/config/sfConfig.class.php';
require_once $this->sf_lib_dir . '/util/sfSimpleAutoload.class.php';
require_once $this->sf_lib_dir . '/util/sfToolkit.class.php';
require_once $this->sf_lib_dir . '/util/sfFinder.class.php';
sfConfig::add(array('sf_symfony_lib_dir' => $this->sf_lib_dir, 'sf_symfony_data_dir' => $this->sf_lib_dir));
// directory layout
sfCore::initDirectoryLayout($this->sf_lib_dir);
// include path
set_include_path(sfConfig::get('sf_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_app_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_model_dir') . PATH_SEPARATOR . get_include_path());
$cache = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . sprintf('limeade_autoload_%s.data', md5(__FILE__));
$autoloader = sfSimpleAutoload::getInstance($cache);
$autoloader->register();
$finder = sfFinder::type('file')->ignore_version_control()->prune('test')->prune('vendor')->name('*.php');
$autoloader->addFiles($finder->in(sfConfig::get('sf_symfony_lib_dir')));
$autoloader->addFiles($finder->in($this->project_root));
$autoloader->addDirectory(sfConfig::get('sf_root_dir') . '/plugins');
return $this;
}
示例3: configure
public function configure()
{
// upload dir
sfConfig::add(array('sf_image_dir_name' => $sf_image_dir_name = 'images', 'sf_userimage_dir_name' => $sf_userimage_dir_name = 'userimages', 'sf_userimage_dir' => sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $sf_image_dir_name . DIRECTORY_SEPARATOR . $sf_userimage_dir_name, 'sf_default_photo' => 'avatar.gif', 'sf_badgeimage_dir_name' => $sf_badgeimage_dir_name = "badgeimages", 'sf_badgeimage_dir' => sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . $sf_image_dir_name . DIRECTORY_SEPARATOR . $sf_badgeimage_dir_name));
// set default formatter to DIV
sfWidgetFormSchemaDecorator::setDefaultFormFormatterName('div');
}
示例4: 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;
}
示例5: loadConfiguration
protected function loadConfiguration()
{
sfConfig::add(array('sf_i18n' => true, 'sf_charset' => 'utf-8', 'sf_upload_dir_name' => str_replace(dmOs::normalize(sfConfig::get('sf_web_dir') . '/'), '', dmOs::normalize(sfConfig::get('sf_upload_dir'))), 'dm_data_dir' => dmOs::join(sfConfig::get('sf_data_dir'), 'dm'), 'dm_cache_dir' => dmOs::join(sfConfig::get('sf_cache_dir'), 'dm')));
if (extension_loaded('mbstring')) {
mb_internal_encoding('UTF-8');
}
dmConfig::initialize($this->dispatcher);
}
示例6: remove
/**
* Removes a key from symfony config
*/
public function remove($key)
{
$all = sfConfig::getAll();
unset($all[$key]);
sfConfig::clear();
sfConfig::add($all);
return $this;
}
示例7: initialize
public function initialize()
{
parent::initialize();
if (class_exists('sfPlop')) {
sfPlop::loadPlugin(array('modules' => array('sf_extranet_dashboard' => array('name' => 'Extranet dashboard', 'route' => '@sf_extranet_dashboard'), 'sf_extranet_event' => array('name' => 'Extranet events', 'route' => '@sf_extranet_event'), 'sf_extranet_document' => array('name' => 'Extranet documents', 'route' => '@sf_extranet_document'))));
}
sfConfig::add(array('extranet_dashboard_pagination' => 10, 'extranet_anonymous_name' => 'Anonymous', 'extranet_event_fields' => array('title', 'description', 'date', 'is_published'), 'extranet_document_fields' => array('title', 'category', 'file', 'is_published')));
}
示例8: setDefaultConfiguration
public function setDefaultConfiguration()
{
$configuration_list = Doctrine_Core::getTable('Configuration')->createQuery()->execute();
foreach ($configuration_list as $configuration) {
sfConfig::add(array($configuration->getKey() => $configuration->getValue()));
}
if ($default_timezone = sfConfig::get('sf_default_timezone')) {
date_default_timezone_set($default_timezone);
}
}
示例9: 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;
}
示例10: initConfiguration
public static function initConfiguration($sf_symfony_lib_dir, $sf_symfony_data_dir, $test = false)
{
// start timer
if (SF_DEBUG) {
sfConfig::set('sf_timer_start', microtime(true));
}
// main configuration
sfConfig::add(array('sf_root_dir' => SF_ROOT_DIR, 'sf_app' => SF_APP, 'sf_environment' => SF_ENVIRONMENT, 'sf_debug' => SF_DEBUG, 'sf_symfony_lib_dir' => $sf_symfony_lib_dir, 'sf_symfony_data_dir' => $sf_symfony_data_dir, 'sf_test' => $test));
// directory layout
include $sf_symfony_data_dir . '/config/constants.php';
}
示例11: initializeAmazonS3
public function initializeAmazonS3()
{
$uploadDir = sfConfig::get('sf_upload_dir');
if (sfConfig::get('app_sf_amazon_plugin_s3_enabled', false) && ($bucket = sfConfig::get('app_sf_amazon_plugin_s3_bucket', false))) {
// $s3 = new AmazonS3(
// sfConfig::get('app_sf_amazon_plugin_access_key'),
// sfConfig::get('app_sf_amazon_plugin_secret_key')
// );
$path = str_replace(sfConfig::get('sf_web_dir'), '', $uploadDir);
sfConfig::add(array('sf_upload_read_dir' => 'http://' . $bucket . '.s3.amazonaws.com' . $path, 'sf_upload_write_dir' => 's3://' . $bucket . $path));
} else {
sfConfig::add(array('sf_upload_read_dir' => $uploadDir, 'sf_upload_write_dir' => $uploadDir));
}
}
示例12: 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();
}
示例13: execute
public function execute($filterChain)
{
// Create a function cache object for the QubitSettings method call
$cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_app_cache_dir') . '/settings'));
// Get settings (from cache if exists)
if ($cache->has('settings')) {
$settings = unserialize($cache->get('settings'));
} else {
$settings = QubitSetting::getSettingsArray();
$cache->set('settings', serialize($settings));
}
// Overwrite/populate settings into sfConfig object
sfConfig::add($settings);
// Execute next filter
$filterChain->execute();
}
示例14: initialize
public function initialize()
{
// LISTENERS
$this->dispatcher->connect('plop.messaging', array('sfPlopListeners', 'listenToMessagingEvent'));
// CONFIG
sfConfig::add(array('sf_plop_version' => '2', 'sf_plop_website_description' => 'Plop CMS - a fully customizable CMS', 'sf_plop_website_keywords' => 'plop, cms', 'sf_plop_use_custom_page_title' => true, 'sf_plop_website_title' => 'Plop CMS', 'sf_plop_website_title_position' => 'after', 'sf_plop_website_title_prefix' => '-', 'sf_plop_website_title_suffix' => '', 'sf_plop_use_title_in_seo_description' => true, 'sf_plop_default_culture' => 'fr', 'sf_plop_cultures' => array('fr', 'en'), 'sf_plop_use_country_flags' => true, 'sf_plop_country_flags_path' => '/sfPlopPlugin/vendor/famfamfam/flags/', 'sf_plop_loaded_admin_themes' => array('admin' => array('name' => 'admin', 'description' => 'Default admin theme', 'color' => '#444'), 'admin-theme-light' => array('name' => 'admin-theme-light', 'description' => 'Light version of the default admin theme', 'color' => '#eee')), 'sf_plop_admin_theme' => 'admin', 'sf_plop_loaded_themes' => array('none' => false, 'victor' => array('name' => 'victor', 'description' => 'Victor grey', 'location' => '/sfPlopPlugin/themes/victor/', 'css' => array('/sfPlopPlugin/themes/victor/css/theme.css', 'http://fonts.googleapis.com/css?family=Kreon'), 'subthemes' => array('victor victor-black' => 'Victor black', 'victor victor-blue' => 'Victor blue')), 'dark' => array('name' => 'dark', 'description' => 'Dark', 'location' => '/sfPlopPlugin/themes/dark/', 'css' => '/sfPlopPlugin/themes/dark/css/theme.css'), 'florentine' => array('name' => 'florentine', 'description' => 'Florentine', 'location' => '/sfPlopPlugin/themes/florentine/', 'css' => '/sfPlopPlugin/themes/florentine/css/theme.css'), 'metal' => array('name' => 'metal', 'description' => 'Metal', 'location' => '/sfPlopPlugin/themes/metal/', 'css' => '/sfPlopPlugin/themes/metal/css/theme.css'), 'canvas' => array('name' => 'mfgallery', 'description' => 'Canvas', 'location' => '/sfPlopPlugin/themes/canvas/', 'css' => '/sfPlopPlugin/themes/canvas/css/theme.css'), 'kerbi' => array('name' => 'kerbi', 'description' => 'Kerbi', 'location' => '/sfPlopPlugin/themes/kerbi/', 'css' => array('/sfPlopPlugin/themes/kerbi/css/theme.css', 'http://fonts.googleapis.com/css?family=Kreon')), 'architect' => array('name' => 'architect', 'description' => 'Architect', 'location' => '/sfPlopPlugin/themes/architect/', 'css' => array('/sfPlopPlugin/themes/architect/css/theme.css', 'http://fonts.googleapis.com/css?family=Terminal+Dosis'))), 'sf_plop_theme' => 'victor', 'sf_plop_custom_css' => null, 'sf_plop_custom_js' => null, 'sf_plop_custom_favicon' => '/sfPlopPlugin/images/favicon.ico', 'sf_plop_custom_webapp_favicon' => '/sfPlopPlugin/images/apple-touch-icon.png', 'sf_plop_use_html5' => true, 'sf_plop_use_image_zoom' => false, 'sf_plop_use_ajax' => false, 'sf_plop_form_help_format' => '<div class="widget-form-help">%help%</div>', 'sf_plop_use_statistics' => false, 'sf_plop_statistics_code' => '', 'sf_plop_slots_class_prefix' => 'sfPlopSlot', 'sf_plop_allow_registration' => false, 'sf_plop_private_access' => false, 'sf_plop_menu_items' => array('icon' => 'icon', 'title' => 'title', 'subtitle' => 'subtitle'), 'sf_plop_slot_layouts' => array('l' => 'left', 'c' => 'center', 'r' => 'right', 'lc' => 'left + center', 'cr' => 'center + right', 'ml' => 'midleft', 'mr' => 'midright', 'lcr' => 'left + center + right'), 'sf_plop_loaded_slots' => array('RichText' => 'Rich text', 'Text' => 'Simple text', 'PageTitle' => 'Page title', 'Area' => 'Blocks area', 'PageHeader' => 'Page header', 'PageFooter' => 'Page footer', 'MainNavigation' => 'Main navigation', 'SecondNavigation' => 'Second navigation', 'LocaleNavigation' => 'Localization navigation', 'LoginLinks' => 'Login links', 'Breadcrumb' => 'Breadcrumb trail', 'SiteMap' => 'Site map', 'ContactForm' => 'Contact form', 'LoginForm' => 'Login form', 'RegisterForm' => 'Register form', 'Code' => 'Code block', 'XmlFeed' => 'Xml feed', 'Date' => 'Date', 'PoweredByPlopCMS' => 'Powered by Plop CMS', 'ThemeSwitcher' => 'Theme switcher', 'DistantGallery' => 'Distant gallery'), 'sf_plop_loaded_modules' => array('sf_plop_cms' => array('name' => 'Contents', 'route' => '@sf_plop_homepage', 'culture' => 'default'), 'sf_plop_dashboard' => array('name' => 'Dashboard', 'route' => '@sf_plop_dashboard')), 'sf_plop_loaded_links' => array('sf_plop_homepage' => array('name' => 'Homepage', 'route' => '@sf_plop_homepage', 'culture' => 'default')), 'sf_plop_cache_lifetime' => 86400, 'sf_plop_uncached_slots' => array('Date', 'ContactForm', 'LoginForm', 'RegisterForm'), 'sf_plop_richtext_editors' => array('aloha-editor'), 'sf_plop_richtext_editor' => 'aloha-editor', 'sf_plop_richtext_editor_aloha-editor_bridge' => '/sfPlopPlugin/js/admin.aloha.js', 'sf_plop_richtext_editor_aloha-editor_css' => '/sfPlopPlugin/vendor/aloha-editor/src/css/aloha.css', 'sf_plop_richtext_editor_aloha-editor_script' => array('src' => '/sfPlopPlugin/vendor/aloha-editor/src/lib/aloha.js', 'data-aloha-plugins' => 'common/format,common/table,common/list,common/link,common/undo,common/paste,common/contenthandler,common/characterpicker,common/image,common/align,plopcms/plopcms,aloha-editor-extra-plugins/hr/hr')));
// Enabled slots and modules for sfPlopCMS
sfConfig::add(array('sf_plop_enabled_slots' => array('RichText', 'Text', 'PageTitle', 'Area', 'PageHeader', 'PageFooter', 'MainNavigation', 'SecondNavigation', 'LocaleNavigation', 'LoginLinks', 'Breadcrumb', 'SiteMap', 'ContactForm', 'LoginForm', 'RegisterForm', 'Code', 'Date', 'XmlFeed', 'ThemeSwitcher', 'PoweredByPlopCMS', 'DistantGallery', 'Asset', 'AssetGallery', 'CustomGalleryAsset', 'AssetGalleryNavigation', 'GoogleMaps', 'GoogleMapsFilter', 'GoogleMapsPosition'), 'sf_plop_enabled_modules' => array('sf_plop_cms', 'sf_plop_dashboard', 'sfAssetLibrary', 'sfAssetGallery'), 'sf_plop_enabled_links' => array('sf_plop_homepage')));
// Configuration for sfPlopDashoard
sfConfig::add(array('sf_plop_dashboard_show_welcome_message' => true, 'sf_plop_dashboard_show_browser_recommandations' => true, 'sf_plop_dashboard_show_news' => false, 'sf_plop_dashboard_show_stats' => false));
// Configuration for sfPlopDashoard / non-overridable settings
sfConfig::add(array('sf_plop_dashboard_settings_tabs' => array('seo' => 'SEO', 'pluginModules' => 'Modules manager', 'pluginSlots' => 'Content blocks manager', 'statistics' => 'Statistics', 'culture' => 'Content languages', 'messaging' => 'Messaging', 'appearance' => 'Appearance', 'access' => 'Public access')));
// Configuration for sfPlopMessaging
sfConfig::add(array('sf_plop_messaging_from_email' => 'anon@ymous.com', 'sf_plop_messaging_from_name' => 'Anon YMOUS', 'sf_plop_messaging_to_email' => 'anon@ymous.com', 'sf_plop_messaging_to_name' => 'Anon YMOUS', 'sf_plop_messaging_subject' => 'Your plop website has a message for you', 'sf_plop_messaging_message' => 'Message from your plop website'));
// Load dynamic config
sfPlop::check();
sfPlop::loadPlugin(array('slots' => sfPlop::get('sf_plop_loaded_slots', true), 'modules' => sfPlop::get('sf_plop_loaded_modules', true), 'themes' => sfPlop::get('sf_plop_loaded_themes', true), 'links' => sfPlop::get('sf_plop_loaded_links', true)));
// CSS values
sfConfig::add(array('sf_plop_css_background-repeat' => array('no-repeat' => 'No repetition', 'repeat' => 'Repetition', 'repeat-x' => 'Horizontal repetition', 'repeat-y' => 'Vertical repetition'), 'sf_plop_css_background-position-x' => array('left' => 'Left', 'center' => 'Center', 'right' => 'Right'), 'sf_plop_css_background-position-y' => array('top' => 'Top', 'center' => 'Middle', 'bottom' => 'Bottom'), 'sf_plop_css_border-style' => array('solid' => 'Solid', 'dashed' => 'Dashed', 'dotted' => 'Dotted'), 'sf_plop_css_font-family' => array('Arial, Helvetica, sans-serif' => 'Arial, Helvetica, sans-serif', 'Verdana, Arial, Helvetica, sans-serif' => 'Verdana, Arial, Helvetica, sans-serif', 'Georgia, "Times New Roman", Times, serif' => 'Georgia, "Times New Roman", Times, serif', '"Times New Roman", Times, serif' => '"Times New Roman", Times, serif', '"Courier New", Courier, mono' => '"Courier New", Courier, mono'), 'sf_plop_css_font-size' => array('.75em' => '1 (75%)', '1em' => '2 (100%)', '1.2em' => '3 (120%)', '1.4em' => '4 (140%)', '1.6em' => '5 (160%)'), 'sf_plop_css_border-width' => array('0px' => '0px', '1px' => '1px', '2px' => '2px', '3px' => '3px', '4px' => '4px', '5px' => '5px', '6px' => '6px', '7px' => '7px', '8px' => '8px', '9px' => '9px', '10px' => '10px'), 'sf_plop_css_website-width' => array('100%' => 'Fluid layout (100%)', '1000px' => 'Screen resolution of 1280x1024 (1000px)', '960px' => 'Screen resolution of 1024x768 (960px)', '750px' => 'Screen resolution of 800x600 (750px)', '320px' => 'Mobile (320px)')));
}
示例15: initialize
/**
* @see sfPluginConfiguration
*/
public function initialize()
{
/**
* Zend Autoloader
*/
ProjectConfiguration::registerZend();
/**
* configure amazon s3
*/
$uploadDir = sfConfig::get('sf_upload_dir');
if (sfConfig::get('app_amazon_s3_enabled') && ($bucket = sfConfig::get('app_amazon_s3_bucket'))) {
$this->registerAmazonS3Stream();
$path = str_replace(sfConfig::get('sf_web_dir'), '', $uploadDir);
sfConfig::add(array('sf_upload_read_dir' => 'http://' . $bucket . '.s3.amazonaws.com' . $path, 'sf_upload_write_dir' => 's3://' . $bucket . $path));
} else {
sfConfig::add(array('sf_upload_read_dir' => $uploadDir, 'sf_upload_write_dir' => $uploadDir));
}
/**
* end amazon s3 config
*/
}