本文整理匯總了PHP中sfContext::getEventDispatcher方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfContext::getEventDispatcher方法的具體用法?PHP sfContext::getEventDispatcher怎麽用?PHP sfContext::getEventDispatcher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfContext
的用法示例。
在下文中一共展示了sfContext::getEventDispatcher方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initialize
/**
* Initializes this view.
*
* @param sfContext $context The current application context
* @param string $moduleName The module name for this view
* @param string $actionName The action name for this view
* @param string $viewName The view name
*
* @return bool true, if initialization completes successfully, otherwise false
*/
public function initialize($context, $moduleName, $actionName, $viewName)
{
$this->moduleName = $moduleName;
$this->actionName = $actionName;
$this->viewName = $viewName;
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
sfOutputEscaper::markClassesAsSafe(array('sfForm', 'sfModelGeneratorHelper'));
$this->attributeHolder = $this->initializeAttributeHolder();
$this->parameterHolder = new sfParameterHolder();
$this->parameterHolder->add(sfConfig::get('mod_' . strtolower($moduleName) . '_view_param', array()));
$request = $context->getRequest();
$format = $request->getRequestFormat();
if (null !== $format) {
if ('html' != $format) {
$this->setExtension('.' . $format . $this->getExtension());
}
if ($mimeType = $request->getMimeType($format)) {
$this->context->getResponse()->setContentType($mimeType);
if ('html' != $format) {
$this->setDecorator(false);
}
}
}
$this->dispatcher->notify(new sfEvent($this, 'view.configure_format', array('format' => $format, 'response' => $context->getResponse(), 'request' => $context->getRequest())));
// include view configuration
$this->configure();
return true;
}
示例2: __construct
/**
* Class constructor
*
* @param sfSympalConfiguration $sympalConfiguration The Sympal configuration
* @param sfContext $symfonyContext The symfony context
*/
public function __construct(sfSympalConfiguration $sympalConfiguration, sfContext $symfonyContext)
{
$this->_dispatcher = $symfonyContext->getEventDispatcher();
$this->_sympalConfiguration = $sympalConfiguration;
$this->_symfonyContext = $symfonyContext;
$this->initialize();
}
示例3: getThemeForRequest
/**
* Attempts to return the theme for the current request
*
* This first throws a sympal.theme.set_theme_from_request event, giving
* anyone the opportunity to determine the theme. If this event is not
* handled, we continue with some default rules for setting themes.
*
* @param sfContext $context
* @param array An array of valid themes, to be used for user-entered themes
*
* @return string The theme (defaults to the default theme)
*/
public function getThemeForRequest(sfContext $context, $validThemes)
{
$event = $context->getEventDispatcher()->notifyUntil(new sfEvent($this, 'theme.set_theme_from_request', array('context' => $context)));
if ($event->isProcessed()) {
return $event->getReturnValue();
}
if ($this->getOption('allow_changing_theme_by_url', true)) {
$user = $context->getUser();
$request = $context->getRequest();
if ($theme = $request->getParameter($this->getOption('theme_request_parameter_name', 'sf_theme'))) {
// make sure the theme is valid
if (in_array($theme, $validThemes)) {
$user->setCurrentTheme($theme);
return $theme;
} else {
// unset the user attribute
$user->setCurrentTheme(false);
}
}
if ($theme = $user->getCurrentTheme()) {
return $theme;
}
}
// Get the theme from module/route. False is a valid response (don't set theme)
$module = $context->getModuleName();
$route = $context->getRouting()->getCurrentRouteName();
$theme = $this->getThemeFromConfig($module, $route);
if ($theme || $theme === false) {
return $theme;
}
return $this->getOption('default_theme');
}
示例4: initialize
/**
* Initializes this controller.
*
* @param sfContext $context A sfContext implementation instance
*/
public function initialize($context)
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
// set max forwards
$this->maxForwards = sfConfig::get('sf_max_forwards');
}
示例5: initialize
/**
* Initializes this view.
*
* @param sfContext $context The current application context
* @param string $moduleName The module name for this view
* @param string $actionName The action name for this view
* @param string $viewName The view name
*
* @return bool true, if initialization completes successfully, otherwise false
*/
public function initialize($context, $moduleName, $actionName, $viewName)
{
$this->moduleName = $moduleName;
$this->actionName = $actionName;
$this->viewName = $viewName;
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Initialize view for "%s/%s"', $moduleName, $actionName))));
}
sfOutputEscaper::markClassAsSafe('sfForm');
$this->attributeHolder = $this->initializeAttributeHolder();
$this->parameterHolder = new sfParameterHolder();
$this->parameterHolder->add(sfConfig::get('mod_' . strtolower($moduleName) . '_view_param', array()));
$request = $context->getRequest();
if (!is_null($format = $request->getRequestFormat())) {
if ('html' != $format) {
$this->setExtension('.' . $format . $this->getExtension());
}
if ($mimeType = $request->getMimeType($format)) {
$this->context->getResponse()->setContentType($mimeType);
$this->setDecorator(false);
}
$this->dispatcher->notify(new sfEvent($this, 'view.configure_format', array('format' => $format, 'response' => $context->getResponse(), 'request' => $context->getRequest())));
}
// include view configuration
$this->configure();
return true;
}
示例6: initialize
/**
* Initializes this controller.
*
* @param sfContext $context A sfContext implementation instance
*/
public function initialize($context)
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
if (sfConfig::get('sf_logging_enabled')) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array('Initialization')));
}
// set max forwards
$this->maxForwards = sfConfig::get('sf_max_forwards');
}
示例7: initialize
/**
* Initializes this component.
*
* @param sfContext $context The current application context.
* @param string $moduleName The module name.
* @param string $actionName The action name.
*
* @return boolean true, if initialization completes successfully, otherwise false
*/
public function initialize($context, $moduleName, $actionName)
{
$this->moduleName = $moduleName;
$this->actionName = $actionName;
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
$this->varHolder = new sfParameterHolder();
$this->request = $context->getRequest();
$this->response = $context->getResponse();
$this->requestParameterHolder = $this->request->getParameterHolder();
}
示例8: initialize
/**
* Initializes the cache manager.
*
* @param sfContext $context Current application context
* @param sfCache $cache An sfCache instance
*/
public function initialize($context, sfCache $cache)
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
$this->controller = $context->getController();
// empty configuration
$this->cacheConfig = array();
// cache instance
$this->cache = $cache;
// routing instance
$this->routing = $context->getRouting();
}
示例9: initialize
/**
* Initializes the cache manager.
*
* @param sfContext $context Current application context
* @param sfCache $cache An sfCache instance
*/
public function initialize($context, sfCache $cache)
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
$this->controller = $context->getController();
if (sfConfig::get('sf_web_debug')) {
$this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug'));
}
// empty configuration
$this->cacheConfig = array();
// cache instance
$this->cache = $cache;
// routing instance
$this->routing = $context->getRouting();
}
示例10: initialize
/**
* Initializes the cache manager.
*
* @param sfContext $context Current application context
* @param sfCache $cache An sfCache instance
*/
public function initialize($context, sfCache $cache, $options = array())
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
$this->controller = $context->getController();
$this->request = $context->getRequest();
$this->options = array_merge(array('cache_key_use_vary_headers' => true, 'cache_key_use_host_name' => true), $options);
if (sfConfig::get('sf_web_debug')) {
$this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug'));
}
// empty configuration
$this->cacheConfig = array();
// cache instance
$this->cache = $cache;
// routing instance
$this->routing = $context->getRouting();
}
示例11: _loadEditorAssets
/**
* Loads all of the js/css necessary to support the inline editor
*
* @param sfWebResponse $response
* @return void
*/
protected function _loadEditorAssets(sfContext $context)
{
$context->getEventDispatcher()->notify(new sfEvent($context->getResponse(), 'editable_content.load_editor_assets'));
$response = $context->getResponse();
$pluginWebRoot = sfConfig::get('app_editable_content_assets_web_root', '/ioEditableContentPlugin');
// JQuery
if (true === sfConfig::get('app_editable_content_load_jquery')) {
$response->addJavascript(sprintf('%s/js/jquery-1.4.3.min.js', $pluginWebRoot), 'last');
}
// JQuery ui (just core and widget)
if (true === sfConfig::get('app_editable_content_load_jquery_ui')) {
$response->addJavascript(sprintf('%s/js/jquery-ui-core-widget.min.js', $pluginWebRoot), 'last');
}
// JQuery metadata
if (true === sfConfig::get('app_editable_content_load_jquery_metadata')) {
$response->addJavascript(sprintf('%s/js/jquery.metadata.js', $pluginWebRoot), 'last');
}
// JQuery form
if (true === sfConfig::get('app_editable_content_load_jquery_form')) {
$response->addJavascript(sprintf('%s/js/jquery.form.js', $pluginWebRoot), 'last');
}
// JQuery blockUI
if (true === sfConfig::get('app_editable_content_load_jquery_blockui')) {
$response->addJavascript(sprintf('%s/js/jquery.blockUI.js', $pluginWebRoot), 'last');
}
// Fancybox
if (true === sfConfig::get('app_editable_content_load_fancybox')) {
$response->addJavascript(sprintf('%s/fancybox/jquery.fancybox-1.3.4.js', $pluginWebRoot), 'last');
$response->addStylesheet(sprintf('%s/fancybox/jquery.fancybox-1.3.4.css', $pluginWebRoot), 'last');
}
// The admin javascript file is handled by symfony
$response->addJavascript(sprintf('%s/js/ioEditableContentList.js', $pluginWebRoot), 'last');
$response->addJavascript(sprintf('%s/js/ioEditableContent.js', $pluginWebRoot), 'last');
$response->addJavascript(sprintf('%s/js/ioContentEditor.js', $pluginWebRoot), 'last');
$response->addJavascript($context->getController()->genUrl('@editable_content_admin_js'), 'last');
// The admin css file is handled by symfony
$response->addStylesheet($context->getController()->genUrl('@editable_content_admin_css'), 'first');
}
開發者ID:kimbrelas,項目名稱:ioEditableContentPlugin,代碼行數:44,代碼來源:ioEditableContentPluginConfiguration.class.php
示例12: initialize
/**
* Initializes this controller.
*
* @param sfContext $context A sfContext implementation instance
*/
public function initialize($context)
{
$this->context = $context;
$this->dispatcher = $context->getEventDispatcher();
}
示例13: initialize
/**
* Initialize cache manager
*
* @param sfContext $context
* @param sfCache $taggingCache
* @param array $options
*
* @see sfViewCacheManager::initialize()
*/
public function initialize($context, sfCache $taggingCache, $options = array())
{
if (!$taggingCache instanceof sfTaggingCache) {
throw new InvalidArgumentException(sprintf('Cache "%s" is not instanceof sfTaggingCache', get_class($taggingCache)));
}
if (!sfConfig::get('sf_cache')) {
$taggingCache = new sfNoTaggingCache();
}
$this->setTaggingCache($taggingCache);
$this->cache = $this->getTaggingCache()->getCache();
$this->setEventDispatcher($context->getEventDispatcher());
$this->context = $context;
$this->controller = $context->getController();
$this->request = $context->getRequest();
$this->routing = $context->getRouting();
$this->setOptions(array_merge(array('cache_key_use_vary_headers' => true, 'cache_key_use_host_name' => true), $options));
if (sfConfig::get('sf_web_debug')) {
$this->getEventDispatcher()->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug'));
}
// empty configuration
$this->cacheConfig = array();
}