当前位置: 首页>>代码示例>>PHP>>正文


PHP sfEventDispatcher类代码示例

本文整理汇总了PHP中sfEventDispatcher的典型用法代码示例。如果您正苦于以下问题:PHP sfEventDispatcher类的具体用法?PHP sfEventDispatcher怎么用?PHP sfEventDispatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sfEventDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 /**
  * Initializes this sfLogger instance.
  *
  * Available options:
  *
  * - level: The log level.
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfLogger.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (isset($options['level'])) {
         $this->setLogLevel($options['level']);
     }
     $dispatcher->connect('application.log', array($this, 'listenToLogEvent'));
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:21,代码来源:sfLogger.class.php

示例2: main

 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     $threshold = DocBlox_Core_Log::WARN;
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     } else {
         $threshold = DocBlox_Core_Log::QUIET;
     }
     if ($task->getVerbose()) {
         $threshold = DocBlox_Core_Log::DEBUG;
     }
     $dispatcher = new sfEventDispatcher();
     $logger = new DocBlox_Core_Log(DocBlox_Core_Log::FILE_STDOUT);
     $logger->setThreshold($threshold);
     $dispatcher->connect('system.log', array($logger, 'log'));
     DocBlox_Parser_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Transformer_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Reflection_Abstract::$event_dispatcher = $dispatcher;
     try {
         $task->execute();
     } catch (Exception $e) {
         if (!$task->getQuiet()) {
             echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
             echo $task->getUsageMessage();
         }
         die(1);
     }
 }
开发者ID:rvanvelzen,项目名称:phpDocumentor2,代码行数:35,代码来源:Application.php

示例3: notifyPostExecuteActionEvent

 public static function notifyPostExecuteActionEvent($subject, sfEventDispatcher $dispatcher, sfAction $actionInstance, $result)
 {
     $moduleName = $actionInstance->getModuleName();
     $actionName = $actionInstance->getActionName();
     $params = array('moduleName' => $moduleName, 'actionName' => $actionName, 'actionInstance' => $actionInstance, 'result' => $result);
     $dispatcher->notify(new sfEvent($subject, 'op_action.post_execute_' . $moduleName . '_' . $actionName, $params));
     $dispatcher->notify(new sfEvent($subject, 'op_action.post_execute', $params));
 }
开发者ID:shotaatago,项目名称:OpenPNE3,代码行数:8,代码来源:opExecutionFilter.class.php

示例4: _start

 protected function _start()
 {
     $formatter = new sfFormatter(80);
     $dispatcher = new sfEventDispatcher();
     $dispatcher->connect('command.log', array($this, "logTask"));
     $this->taskLog = array();
     $this->task = new InstallNotifierTask($dispatcher, $formatter);
 }
开发者ID:havvg,项目名称:sfNotificationsPlugin,代码行数:8,代码来源:InstallNotifierTaskTest.php

示例5: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - logger_service_id: The service id to use as the logger. Default: logger.psr
  * - auto_connect: If we must connect automatically to the context.load_factories to set the logger. Default: true
  *
  * @param sfEventDispatcher $dispatcher
  * @param array $options
  *
  * @return void
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (isset($options['logger_service_id'])) {
         $this->loggerServiceId = $options['logger_service_id'];
     }
     if (!isset($options['auto_connect']) || $options['auto_connect']) {
         $dispatcher->connect('context.load_factories', array($this, 'listenContextLoadFactoriesEvent'));
     }
     parent::initialize($dispatcher, $options);
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:23,代码来源:sfPsrLoggerAdapter.class.php

示例6: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - web_debug_class: The web debug class (sfWebDebug by default).
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean           true, if initialization completes successfully, otherwise false.
  *
  * @see sfVarLogger
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->dispatcher = $dispatcher;
     $this->webDebugClass = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     if (sfConfig::get('sf_web_debug')) {
         $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     }
     return parent::initialize($dispatcher, $options);
 }
开发者ID:WIZARDISHUNGRY,项目名称:symfony,代码行数:24,代码来源:sfWebDebugLogger.class.php

示例7: initialize

 /**
  * Initialize symfony propel
  *
  * @param sfEventDispatcher $dispatcher
  * @param string $culture
  *
  * @deprecated Moved to {@link sfPropelPluginConfiguration}
  */
 public static function initialize(sfEventDispatcher $dispatcher, $culture = null)
 {
     $dispatcher->notify(new sfEvent(__CLASS__, 'application.log', array(__METHOD__ . '() has been deprecated. Please call sfPropel::setDefaultCulture() to set the culture.', 'priority' => sfLogger::NOTICE)));
     if (null !== $culture) {
         self::setDefaultCulture($culture);
     } else {
         if (class_exists('sfContext', false) && sfContext::hasInstance() && ($user = sfContext::getInstance()->getUser())) {
             self::setDefaultCulture($user->getCulture());
         }
     }
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:19,代码来源:sfPropel.class.php

示例8: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  *  * web_debug_class: The web debug class (sfWebDebug by default)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean           true, if initialization completes successfully, otherwise false.
  *
  * @see sfVarLogger
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->webDebugClass = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     if (sfConfig::get('sf_web_debug')) {
         $dispatcher->connect('context.load_factories', array($this, 'listenForLoadFactories'));
         $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     }
     $this->registerErrorHandler();
     return parent::initialize($dispatcher, $options);
 }
开发者ID:vcgato29,项目名称:poff,代码行数:25,代码来源:sfWebDebugLogger.class.php

示例9: dispatch

 /**
  * Dispatches an event to the Event Dispatcher.
  *
  * This method tries to dispatch an event; if no Event Dispatcher has been
  * set than this method will explicitly not fail and return null.
  *
  * By not failing we make the Event Dispatcher optional and is it easier
  * for people to re-use this component in their own application.
  *
  * @param string   $name      Name of the event to dispatch.
  * @param string[] $arguments Arguments for this event.
  *
  * @throws DocBlox_Parser_Exception if there is a dispatcher but it is not
  *  of type sfEventDispatcher
  *
  * @return mixed|null
  */
 public function dispatch($name, $arguments)
 {
     if (!self::$event_dispatcher) {
         return null;
     }
     if (!self::$event_dispatcher instanceof sfEventDispatcher) {
         throw new DocBlox_Parser_Exception('Expected the event dispatcher to be an instance of ' . 'sfEventDispatcher');
     }
     $event = self::$event_dispatcher->notify(new sfEvent($this, $name, $arguments));
     return $event ? $event->getReturnValue() : null;
 }
开发者ID:rvanvelzen,项目名称:phpDocumentor2,代码行数:28,代码来源:Abstract.php

示例10: initialize

 public static function initialize(sfEventDispatcher $dispatcher, $culture = null)
 {
     $dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent'));
     if (!is_null($culture)) {
         self::setDefaultCulture($culture);
     } else {
         if (class_exists('sfContext', false) && sfContext::hasInstance() && ($user = sfContext::getInstance()->getUser())) {
             self::setDefaultCulture($user->getCulture());
         }
     }
     self::$initialized = true;
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:12,代码来源:sfPropel.class.php

示例11: initialize

 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->sfFire = sfFirePHP::getInstance(true);
     if (isset($options['processor'])) {
         sfFirePHP::setProcessor($options['processor'] . '?' . time());
     }
     if (isset($options['renderer'])) {
         sfFirePHP::setRenderer($options['renderer'] . '?' . time());
     }
     $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     $this->dispatcher = $dispatcher;
     return parent::initialize($dispatcher, $options);
 }
开发者ID:vcgato29,项目名称:poff,代码行数:13,代码来源:sfFirePHPLogger.php

示例12: __construct

 /**
  * Constructor.
  *
  * Available options:
  *
  *  * charset: The default charset to use for messages
  *  * logging: Whether to enable logging or not
  *  * delivery_strategy: The delivery strategy to use
  *  * spool_class: The spool class (for the spool strategy)
  *  * spool_arguments: The arguments to pass to the spool constructor
  *  * delivery_address: The email address to use for the single_address strategy
  *  * transport: The main transport configuration
  *  *   * class: The main transport class
  *  *   * param: The main transport parameters
  *
  * @param sfEventDispatcher $dispatcher An event dispatcher instance
  * @param array             $options    An array of options
  */
 public function __construct(sfEventDispatcher $dispatcher, $options)
 {
     // options
     $options = array_merge(array('charset' => 'UTF-8', 'logging' => false, 'delivery_strategy' => 'realtime', 'transport' => array('class' => 'Swift_MailTransport', 'param' => array())), $options);
     $constantName = 'sfMailer::' . strtoupper($options['delivery_strategy']);
     $this->strategy = defined($constantName) ? constant($constantName) : false;
     if (!$this->strategy) {
         throw new InvalidArgumentException(sprintf('Unknown mail delivery strategy "%s" (should be one of realtime, spool, single_address, or none)', $options['delivery_strategy']));
     }
     // transport
     $class = $options['transport']['class'];
     $transport = new $class();
     if (isset($options['transport']['param'])) {
         foreach ($options['transport']['param'] as $key => $value) {
             $method = 'set' . ucfirst($key);
             if (method_exists($transport, $method)) {
                 $transport->{$method}($value);
             } elseif (method_exists($transport, 'getExtensionHandlers')) {
                 foreach ($transport->getExtensionHandlers() as $handler) {
                     if (in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()))) {
                         $transport->{$method}($value);
                     }
                 }
             }
         }
     }
     $this->realtimeTransport = $transport;
     if (sfMailer::SPOOL == $this->strategy) {
         if (!isset($options['spool_class'])) {
             throw new InvalidArgumentException('For the spool mail delivery strategy, you must also define a spool_class option');
         }
         $arguments = isset($options['spool_arguments']) ? $options['spool_arguments'] : array();
         if ($arguments) {
             $r = new ReflectionClass($options['spool_class']);
             $this->spool = $r->newInstanceArgs($arguments);
         } else {
             $this->spool = new $options['spool_class']();
         }
         $transport = new Swift_SpoolTransport($this->spool);
     } elseif (sfMailer::SINGLE_ADDRESS == $this->strategy) {
         if (!isset($options['delivery_address'])) {
             throw new InvalidArgumentException('For the single_address mail delivery strategy, you must also define a delivery_address option');
         }
         $this->address = $options['delivery_address'];
         $transport->registerPlugin($this->redirectingPlugin = new Swift_Plugins_RedirectingPlugin($this->address));
     }
     parent::__construct($transport);
     // logger
     if ($options['logging']) {
         $this->logger = new sfMailerMessageLoggerPlugin($dispatcher);
         $transport->registerPlugin($this->logger);
     }
     if (sfMailer::NONE == $this->strategy) {
         // must be registered after logging
         $transport->registerPlugin(new Swift_Plugins_BlackholePlugin());
     }
     // preferences
     Swift_Preferences::getInstance()->setCharset($options['charset']);
     $dispatcher->notify(new sfEvent($this, 'mailer.configure'));
 }
开发者ID:hunde,项目名称:bsc,代码行数:78,代码来源:sfMailer.class.php

示例13: initialize

 /**
  * Initializes this logger.
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->dispatcher = $dispatcher;
     $class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     $this->webDebug = new $class($dispatcher);
     $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     if (isset($options['xdebug_logging'])) {
         $this->xdebugLogging = $options['xdebug_logging'];
     }
     // disable xdebug when an HTTP debug session exists (crashes Apache, see #2438)
     if (isset($_GET['XDEBUG_SESSION_START']) || isset($_COOKIE['XDEBUG_SESSION'])) {
         $this->xdebugLogging = false;
     }
     return parent::initialize($dispatcher, $options);
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:24,代码来源:sfWebDebugLogger.class.php

示例14: runAndCheckTask

 /**
  * Подготовить таск (мок), запустить и проверить вызовы методов
  *
  * @param  array  $ntfnList - Массив OperationNotification
  * @param  bool   $isOk     - Успешно отправить уведомления
  */
 private function runAndCheckTask(array $ntfnList, $isOk)
 {
     // Мок таска - перекроем 'getEventsFromQueue', чтобы изолировать логику
     // выборки уведомлений. И будем свои уведомления на отправку
     $task = $this->getMock('myOperationNotificationTask', array('getEventsFromQueue'), array($dispatcher = new sfEventDispatcher(), new sfFormatter()));
     $task->expects($this->once())->method('getEventsFromQueue')->will($this->returnValue($ntfnList));
     // Создаем и регистрируем обработчик уведомлении и будем проверять его вызовы
     $handler = $this->getMock('myNotificationHandlerInterface', array('run'));
     $handler->expects($this->exactly(count($ntfnList)))->method('run')->will($this->returnValue($isOk));
     foreach ($ntfnList as $ntfn) {
         $task->registerHandler($ntfn->getType(), $handler);
     }
     // Повесим собственный обработчик на логи таска, чтобы их сохранять и проверять
     $dispatcher->connect('command.log', array($this, 'handleTaskLogs'));
     // Запустить таск
     $task->run($args = array(), $options = array('env' => 'test'));
 }
开发者ID:ru-easyfinance,项目名称:EasyFinance,代码行数:23,代码来源:myOperationNotificationTaskTest.php

示例15: initialize

 /**
  * Initialize sfymfony propel
  *
  * @param sfEventDispatcher $dispatcher
  * @param string $culture
  */
 public static function initialize(sfEventDispatcher $dispatcher, $culture = null)
 {
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         // add propel logger
         Propel::setLogger(new sfPropelLogger($dispatcher));
     }
     // propel initialization
     $configuration = sfPropelDatabase::getConfiguration();
     if ($configuration) {
         Propel::setConfiguration($configuration);
         if (!Propel::isInit()) {
             Propel::initialize();
         }
     }
     $dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent'));
     if (!is_null($culture)) {
         self::setDefaultCulture($culture);
     } else {
         if (class_exists('sfContext', false) && sfContext::hasInstance() && ($user = sfContext::getInstance()->getUser())) {
             self::setDefaultCulture($user->getCulture());
         }
     }
     self::$initialized = true;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:30,代码来源:sfPropel.class.php


注:本文中的sfEventDispatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。