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


PHP sfEventDispatcher::notify方法代码示例

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


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

示例1: log

 /**
  * @see xfLogger
  */
 public function log($message, $section = 'sfSearch')
 {
     $message = preg_replace('/"(.+?)"/e', '$this->formatter->format("\\1", array("fg" => "blue", "bold" => true));', $message);
     $message = preg_replace('/\\.{3}$/e', '$this->formatter->format("...", array("fg" => "red", "bold" => true));', $message);
     $message = preg_replace('/(Warning|Error)!/e', '$this->formatter->format("\\1!", array("fg" => "red", "bold" => true));', $message);
     $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format($section, array('fg' => 'green', 'bold' => true)) . ' >> ' . $message)));
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:10,代码来源:xfLoggerTask.class.php

示例2: 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

示例3: 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

示例4: handleEventMessage

 public function handleEventMessage(sfEvent $event)
 {
     $message = $this->notifier()->decoratedMessage($event->getSubject());
     $message->addSection('Message Details', $event->getParameters());
     $message->addSection('Server', $this->notifier()->helper()->formatServer());
     $this->dispatcher->notify(new sfEvent($message, 'notify.decorate_message'));
     $this->notifier()->driver()->notify($message);
 }
开发者ID:nogo,项目名称:fpErrorNotifierPlugin,代码行数:8,代码来源:fpErrorNotifierHandler.php

示例5: handleException

 /**
  * 
  * @param Exception $e
  * 
  * @return void
  */
 public function handleException(Exception $e)
 {
   $message = $this->notifier()->decoratedMessage($e->getMessage());
   $message->addSection('Exception', $this->notifier()->helper()->formatException($e));
   $message->addSection('Server', $this->notifier()->helper()->formatServer());
   
   $this->dispatcher->notify(new sfEvent($message, 'notify.exception'));
   
   $this->notifier()->driver()->notify($message);
 }
开发者ID:romankallweit,项目名称:swingmachine,代码行数:16,代码来源:fpErrorNotifierHandler.php

示例6: 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

示例7: array

$t->is($dispatcher->getListeners('foobar'), array(), '->getListeners() returns an empty array if no listener are connected to the given event name');
$listener = new Listener();
// ->notify()
$t->diag('->notify()');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'listenToFoo'));
$dispatcher->connect('foo', array($listener, 'listenToFooBis'));
$e = $dispatcher->notify($event = new sfEvent(new stdClass(), 'foo'));
$t->is($listener->getValue(), 'listenToFoolistenToFooBis', '->notify() notifies all registered listeners in order');
$t->is($e, $event, '->notify() returns the event object');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'listenToFooBis'));
$dispatcher->connect('foo', array($listener, 'listenToFoo'));
$dispatcher->notify(new sfEvent(new stdClass(), 'foo'));
$t->is($listener->getValue(), 'listenToFooBislistenToFoo', '->notify() notifies all registered listeners in order');
// ->notifyUntil()
$t->diag('->notifyUntil()');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'listenToFoo'));
$dispatcher->connect('foo', array($listener, 'listenToFooBis'));
$e = $dispatcher->notifyUntil($event = new sfEvent(new stdClass(), 'foo'));
$t->is($listener->getValue(), 'listenToFoolistenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true');
$t->is($e, $event, '->notifyUntil() returns the event object');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'listenToFooBis'));
$dispatcher->connect('foo', array($listener, 'listenToFoo'));
$e = $dispatcher->notifyUntil($event = new sfEvent(new stdClass(), 'foo'));
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:sfEventDispatcherTest.php

示例8: dirname

/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id: sfLuceneEventConnectorTest.php 7108 2008-01-20 07:44:42Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(5, limeade_output::get());
$limeade = new limeade_sf($t);
$app = $limeade->bootstrap();
class FooListener
{
    public $event;
    public function listen($event)
    {
        $this->event = $event;
    }
}
$source = new sfEventDispatcher();
$target = new sfEventDispatcher();
$connector = new sfLuceneEventConnector($source, 'foo', $target, 'bar');
$t->ok($source->hasListeners('foo'), '__construct() connects a listener to the source');
$subject = 'Fabien';
$params = array('a', 'b', 'c');
$listener = new FooListener();
$target->connect('bar', array($listener, 'listen'));
$source->notify(new sfEvent($subject, 'foo', $params));
$t->isa_ok($listener->event, 'sfEvent', 'calling a linked event calls target');
$t->is($listener->event->getSubject(), $subject, 'calling a linked event sends correct subject');
$t->is($listener->event->getName(), 'bar', 'calling a linked event sends correct name');
$t->is($listener->event->getParameters(), $params, 'calling a linked event sends correct parameters');
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:31,代码来源:sfLuceneEventConnectorTest.php

示例9: __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

示例10: notify

 /**
  * Notify all listeners of the event, through the event dispatcher instance for the class. This is just a convenience method to
  * avoid accessing the event dispatcher directly
  *
  * @param sfEvent $event The event that has occured
  */
 function notify($event)
 {
     $this->eventdispatcher->notify($event);
 }
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:10,代码来源:BaseRecord.php

示例11: log

 /**
  * @see xfLogger
  */
 public function log($message, $section = 'sfSearch')
 {
     $this->dispatcher->notify(new sfEvent($this, $this->event, array($message, 'section' => $section)));
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:7,代码来源:xfLoggerEventDispatcher.class.php

示例12: notify

 public function notify(sfEvent $event)
 {
     $this->_events[] = $event;
     return parent::notify($event);
 }
开发者ID:sympal,项目名称:sympal,代码行数:5,代码来源:sfSympalEventListTask.class.php

示例13: setEventDispatcher

 public function setEventDispatcher(sfEventDispatcher $dispatcher)
 {
     if ($this->isUnknown()) {
         $dispatcher->notify(new sfEvent($this, 'dm.browser.unknown', $this->getUserAgentString()));
     }
 }
开发者ID:theolymp,项目名称:diem,代码行数:6,代码来源:dmBrowser.php

示例14: log

 protected function log($message)
 {
     if ($this->dispatcher) {
         $this->dispatcher->notify(new sfEvent($this, 'command.log', array($message)));
     }
 }
开发者ID:KnpLabs,项目名称:knpDmRackspacePlugin,代码行数:6,代码来源:knpDmRackspaceSynchronizer.php


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