本文整理汇总了PHP中sfConfig::set方法的典型用法代码示例。如果您正苦于以下问题:PHP sfConfig::set方法的具体用法?PHP sfConfig::set怎么用?PHP sfConfig::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfConfig
的用法示例。
在下文中一共展示了sfConfig::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: combine
/**
* Combine multiple text assets into a single file for better http performance this
* method generates a new cache file with every symfony cc you can override the cache
* by adding ?clearassetcache=1 to the page request.
*
* @param type string css or js
* @param namespace string the combined file namespace (eg. module+action names)
* @param response object the sfWebResponse instance
* @return string the url for the combiner service
*/
public function combine($type, $namespace, sfWebResponse $response)
{
//configure the combiner
$type = $type === 'css' ? 'css' : 'js';
$fullname = $type === 'css' ? 'Stylesheets' : 'Javascripts';
$response_getter = 'get' . $fullname;
$namespace = StreemeUtil::slugify($namespace);
//integrate into symfony's asset globals
sfConfig::set(sprintf('symfony.asset.%s_included', strtolower($fullname)), true);
//build the cache filename - this file will be regenerated on a symfony cc
$path = sprintf('%s/combine/%s/', sfConfig::get('sf_cache_dir'), $type);
$filename = sprintf('%s.%s', $namespace, $type);
// you can force a cache clear by passing ?clearassetcache=1 to any template
if (!is_readable($path . $filename) || @$_GET['clearassetcache'] == 1) {
//build one file of all of the css or js files
$file_content = '';
//load vendor libraries for minifying assets
require_once sfConfig::get('sf_lib_dir') . '/vendor/jsmin/jsmin.php';
require_once sfConfig::get('sf_lib_dir') . '/vendor/cssmin/cssmin.php';
foreach ($response->{$response_getter}() as $file => $options) {
if ($type === 'css') {
$file_content .= CSSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
} else {
$file_content .= JSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
}
}
//this file resides in the cache and requires wide permissions for both cli and apache users
@umask(00);
@mkdir($path, 0777, true);
file_put_contents($path . $filename, $file_content);
}
return sprintf('/service/combine/%s/%s', $type, str_replace('-', '_', $namespace));
}
示例2: initialize
public function initialize()
{
$enabledModules = sfConfig::get('sf_enabled_modules');
if (is_array($enabledModules)) {
sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules'), array('oauth')));
}
}
示例3: setNavigation
protected function setNavigation(Member $member)
{
if ($member->getId() !== $this->getUser()->getMemberId()) {
sfConfig::set('sf_nav_type', 'friend');
sfConfig::set('sf_nav_id', $member->getId());
}
}
示例4: executeShow
public function executeShow(sfWebRequest $request)
{
$p = $request->getParameter('page', 'unavailable');
$this->title = sfConfig::get('app_message_with_layout_' . $p . '_title');
$this->text = sfConfig::get('app_message_with_layout_' . $p . '_text');
sfConfig::set('sf_web_debug', false);
}
示例5: execute
public function execute($filterChain)
{
$context = $this->getContext();
$request = $context->getRequest();
if (jfPortableDevice::isPortableDevice()) {
$layout = isset(self::$_layout) ? self::$_layout : $this->getParameter('layout');
$context->getActionStack()->getFirstEntry()->getActionInstance()->setLayout($layout);
if (class_exists('sfWidgetFormSchema')) {
// compatibility with symfony 1.0
sfWidgetFormSchema::setDefaultFormFormatterName($this->getParameter('defaultFormFormatterName', 'jfPD'));
}
jfPortableDevice::setPageAttribute('data-url', $request->getUri());
}
$filterChain->execute();
if (jfPortableDevice::isPortableDevice()) {
if (jfPortableDevice::getConfig('lazyLoadImages')) {
$response = $context->getResponse();
$content = $response->getContent();
$content = preg_replace('/(<img.*)(src=)([\'|\\"].*>)/', '$1data-jfPD-src=$3', $content);
$response->setContent($content);
}
if (jfPortableDevice::isNativeApp()) {
sfConfig::set('sf_web_debug', false);
}
}
}
示例6: initialize
public function initialize()
{
if (class_exists('sfPlop')) {
sfPlop::loadPlugin(array('slots' => array('GoogleMaps' => 'GoogleMaps map', 'GoogleMapsFilter' => 'GoogleMaps filter', 'GoogleMapsPosition' => 'GoogleMaps position')));
}
sfConfig::set('sf_plop_googlemaps_zooms', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
}
开发者ID:noreiller,项目名称:sfPlopSlotGoogleMapsPlugin,代码行数:7,代码来源:sfPlopSlotGoogleMapsPluginConfiguration.class.php
示例7: executeSearch
/**
* Executes search action
*
* @param sfWebRequest $request a request object
*/
public function executeSearch(sfWebRequest $request)
{
sfConfig::set('sf_nav_type', 'default');
$params = $request->getParameter('community', array());
$this->isResult = false;
$this->category_id = 0;
if (isset($params['name'])) {
$params['name'] = $params['name'];
$this->isResult = true;
}
if (isset($params['community_category_id'])) {
$this->category_id = $params['community_category_id'];
$params['community_category_id'] = $this->category_id;
$this->isResult = true;
}
$this->filters = new CommunityFormFilter();
$this->filters->bind($params);
$q = $this->filters->getQuery()->orderBy('id desc');
$this->pager = new sfDoctrinePager('Community', 10);
$this->pager->setQuery($q);
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
$this->categorys = Doctrine::getTable('CommunityCategory')->createQuery()->where('lft > 1')->execute();
return sfView::SUCCESS;
}
示例8: handleAction
protected function handleAction($filterChain, $actionInstance)
{
$moduleName = $actionInstance->getModuleName();
$actionName = $actionInstance->getActionName();
$request = $actionInstance->getRequest();
if ($request->needToRedirectToSoftBankGateway()) {
$request->redirectToSoftBankGateway();
}
$this->handleSsl($actionInstance);
$dispatcher = sfContext::getInstance()->getEventDispatcher();
// sfDoctrinePlugin needs to notify this event for enabling i18n
$dispatcher->notify(new sfEvent($this, 'user.change_culture', array('culture' => sfContext::getInstance()->getUser()->getCulture())));
self::notifyPreExecuteActionEvent($this, $dispatcher, $actionInstance);
Doctrine::getTable('SnsTerm')->configure(sfContext::getInstance()->getUser()->getCulture(), sfConfig::get('sf_app'));
if (sfConfig::has('op_is_use_captcha')) {
sfConfig::set('op_is_use_captcha', opConfig::get('is_use_captcha'));
}
try {
$result = parent::handleAction($filterChain, $actionInstance);
} catch (opRuntimeException $e) {
$this->forwardToErrorAction();
} catch (sfValidatorErrorSchema $e) {
if (isset($e['_csrf_token'])) {
$this->forwardToCSRFErrorAction();
}
throw $e;
}
self::notifyPostExecuteActionEvent($this, $dispatcher, $actionInstance, $result);
return $result;
}
示例9: execute
/**
* List unassigned currencies for given employee and pay grade
* @param sfWebRequest $request
* @return void
*/
public function execute($request)
{
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
sfConfig::set('sf_debug', false);
$currencies = array();
if ($this->getRequest()->isXmlHttpRequest()) {
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
}
$payGrade = $request->getParameter('paygrade');
$empNumber = $request->getParameter('empNumber');
if (!empty($payGrade) && !empty($empNumber)) {
$employeeService = $this->getEmployeeService();
// TODO: call method that returns data in array format (or pass parameter)
$currencies = $employeeService->getAssignedCurrencyList($payGrade, true);
} else {
//
// Return full currency list
//
$currencyService = $this->getCurrencyService();
$currencies = $currencyService->getCurrencyList(true);
}
$currencyArray = array();
foreach ($currencies as $currency) {
$currency['currency_name'] = __($currency['currency_name']);
$currencyArray[] = $currency;
}
return $this->renderText(json_encode($currencyArray));
}
示例10: executeGenerate
protected function executeGenerate($arguments = array(), $options = array())
{
// generate module
$tmpDir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . md5(uniqid(rand(), true));
sfConfig::set('sf_module_cache_dir', $tmpDir);
$generatorManager = new sfGeneratorManager($this->configuration);
$generatorManager->generate('sfPropelCrudGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'], 'non_atomic_actions' => $options['non-atomic-actions'], 'non_verbose_templates' => $options['non-verbose-templates'], 'with_show' => $options['with-show']));
$moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module'];
// copy our generated module
$this->getFilesystem()->mirror($tmpDir . '/auto' . ucfirst($arguments['module']), $moduleDir, sfFinder::type('any'));
if (!$options['with-show']) {
$this->getFilesystem()->remove($moduleDir . '/templates/showSuccess.php');
}
// change module name
$this->getFilesystem()->replaceTokens($moduleDir . '/actions/actions.class.php', '', '', array('auto' . ucfirst($arguments['module']) => $arguments['module']));
// customize php and yml files
$finder = sfFinder::type('file')->name('*.php', '*.yml');
$this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants);
// create basic test
$this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . '/task/generator/skeleton/module/test/actionsTest.php', sfConfig::get('sf_test_dir') . '/functional/' . $arguments['application'] . '/' . $arguments['module'] . 'ActionsTest.php');
// customize test file
$this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir') . '/functional/' . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php', '##', '##', $this->constants);
// delete temp files
$this->getFilesystem()->remove(sfFinder::type('any')->in($tmpDir));
}
示例11: createContext
function createContext()
{
$context = sfContext::getInstance(array('request' => 'sfWebRequest', 'response' => 'sfWebResponse'), true);
$context->configuration = new ApplicationConfigurationMock();
sfConfig::set('sf_standard_helpers', array('Text'));
return $context;
}
示例12: execute
public function execute($request)
{
sfConfig::set('sf_web_debug', false);
sfConfig::set('sf_debug', false);
$leaveId = $request->getParameter("leaveId");
$leaveRequestId = $request->getParameter('leaveRequestId');
$comments = array();
$leaveRequestService = $this->getLeaveRequestService();
if (!empty($leaveRequestId)) {
$comments = $leaveRequestService->getLeaveRequestComments($leaveRequestId);
} else {
if (!empty($leaveId)) {
$comments = $leaveRequestService->getLeaveComments($leaveId);
}
}
$returnData = array();
if (count($comments) > 0) {
foreach ($comments as $comment) {
$commentDate = new DateTime($comment->getCreated());
$row['date'] = set_datepicker_date_format($commentDate->format('Y-m-d'));
$row['time'] = $commentDate->format('H:i');
$row['author'] = $comment->getCreatedByName();
$row['comments'] = $comment->getComments();
$returnData[] = $row;
}
}
$response = $this->getResponse();
$response->setHttpHeader('Expires', '0');
$response->setHttpHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0, max-age=0");
$response->setHttpHeader("Cache-Control", "private", false);
return $this->renderText(json_encode($returnData));
}
示例13: execute
/**
*
* @param <type> $request
* @return <type>
*/
public function execute($request)
{
$this->setLayout(false);
sfConfig::set('sf_web_debug', false);
sfConfig::set('sf_debug', false);
if ($this->getRequest()->isXmlHttpRequest()) {
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
}
$userRoleManager = $this->getContext()->getUserRoleManager();
$mode = $request->getParameter('mode');
$dataGroupName = $mode == self::MODE_CANDIDATES ? 'recruitment_candidates' : 'recruitment_vacancies';
$requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array($dataGroupName => new ResourcePermission(true, false, false, false)));
$allowedVacancyList = $userRoleManager->getAccessibleEntityIds('Vacancy', null, null, array(), array(), $requiredPermissions);
$jobTitle = $request->getParameter('jobTitle');
$vacancyService = new VacancyService();
$vacancyList = $vacancyService->getVacancyListForJobTitle($jobTitle, $allowedVacancyList, true);
$newVacancyList = array();
foreach ($vacancyList as $vacancy) {
if ($vacancy['status'] == JobVacancy::CLOSED) {
$vacancy['name'] = $vacancy['name'] . " (Closed)";
}
$newVacancyList[] = $vacancy;
}
return $this->renderText(json_encode($newVacancyList));
}
示例14: executeIndex
/**
* Executes index action
*
* @param sfWebRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
//definition
$service = self::getZendGdata();
$Id = $this->getRequestParameter('id');
$member_id = isset($Id) ? $Id : $this->getUser()->getMemberId();
$memberS = Doctrine::getTable('Member')->find($member_id);
if (!$memberS) {
return sfView::ERROR;
}
if ($member_id !== $this->getUser()->getMemberId()) {
sfConfig::set('sf_nav_type', 'friend');
sfConfig::set('sf_nav_id', $member_id);
}
$this->member_name = $memberS->getName();
$memberSpreadSheetKey = self::getMemberMasterSpreadSheetKey($service, $member_id);
$domain = null;
if (!is_null(opConfig::get('op_kintai_apps_domain', null))) {
$domain = 'a/' . opConfig::get('op_kintai_apps_domain') . '/';
}
$this->member_splink = "https://docs.google.com/" . $domain . "spreadsheet/ccc?key=" . $memberSpreadSheetKey . "&hl=ja";
$memberEditableKey = self::getMemberSpreadSheetKey($service, $member_id);
if (!is_null($memberEditableKey)) {
$this->member_editablelink = "https://docs.google.com/" . $domain . "spreadsheet/ccc?key=" . $memberEditableKey . "&hl=ja";
} else {
$this->member_editablelink = null;
}
$this->data = $data;
$this->currentMember = $this->getUser()->getMemberId();
$this->viewMember = $member_id;
return sfView::SUCCESS;
}
示例15: _initializeSymfonyConfig
/**
* Initialize some sfConfig values for Sympal
*
* @return void
*/
private function _initializeSymfonyConfig()
{
sfConfig::set('sf_cache', sfSympalConfig::get('page_cache', 'enabled', false));
sfConfig::set('sf_default_culture', sfSympalConfig::get('default_culture', null, 'en'));
sfConfig::set('sf_admin_module_web_dir', sfSympalConfig::get('admin_module_web_dir', null, '/sfSympalAdminPlugin'));
sfConfig::set('app_sf_guard_plugin_success_signin_url', sfSympalConfig::get('success_signin_url'));
if (sfConfig::get('sf_login_module') == 'default') {
sfConfig::set('sf_login_module', 'sympal_auth');
sfConfig::set('sf_login_action', 'signin');
}
if (sfConfig::get('sf_secure_module') == 'default') {
sfConfig::set('sf_secure_module', 'sympal_auth');
sfConfig::set('sf_secure_action', 'secure');
}
if (sfConfig::get('sf_error_404_module') == 'default') {
sfConfig::set('sf_error_404_module', 'sympal_default');
sfConfig::set('sf_error_404_action', 'error404');
}
if (sfConfig::get('sf_module_disabled_module') == 'default') {
sfConfig::set('sf_module_disabled_module', 'sympal_default');
sfConfig::set('sf_module_disabled_action', 'disabled');
}
sfConfig::set('sf_jquery_path', sfSympalConfig::get('jquery_reloaded', 'path'));
sfConfig::set('sf_jquery_plugin_paths', sfSympalConfig::get('jquery_reloaded', 'plugin_paths'));
}