本文整理匯總了PHP中sfEventDispatcher::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfEventDispatcher::connect方法的具體用法?PHP sfEventDispatcher::connect怎麽用?PHP sfEventDispatcher::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfEventDispatcher
的用法示例。
在下文中一共展示了sfEventDispatcher::connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例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);
}
}
示例3: 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'));
}
示例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);
}
示例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);
}
示例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);
}
示例7: 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;
}
示例8: 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);
}
示例9: register
public function register($file)
{
if (!file_exists($file) || !is_readable($file)) {
throw new Exception('The plugin file "' . $file . '" must exist and be readable');
}
$reflection = new DocBlox_Reflection_File($file);
$classes = $reflection->getClasses();
if (count($classes) > 1) {
throw new Exception('Plugin file should only contain one class');
}
/** @var DocBlox_Reflection_Class $listener_definition */
$listener_definition = reset($classes);
// initialize the plugin / event listener
include_once $file;
$listener_name = $listener_definition->getName();
$listener = new $listener_name($this->event_dispatcher);
// connect all events of the each method to the event_dispatcher
foreach ($listener_definition->getMethods() as $method) {
/** @var DocBlox_Reflection_Tag $event */
foreach ($method->getDocBlock()->getTagsByName('event') as $event) {
$this->event_dispatcher->connect($event->getDescription(), array($listener, $method->getName()));
}
}
}
示例10: 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);
}
示例11: 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'));
}
示例12: 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;
}
示例13: register
/**
* Registers the new methods in the component class.
*
* @param sfEventDispatcher A sfEventDispatcher instance
*/
public static function register(sfEventDispatcher $dispatcher)
{
$mixin = new sfSslRequirementActionMixin();
$dispatcher->connect('component.method_not_found', array($mixin, 'listenToMethodNotFound'));
return $mixin;
}
示例14: initialize
/**
* Initializes this logger.
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
$dispatcher->connect('command.log', array($this, 'listenToLogEvent'));
return parent::initialize($dispatcher, $options);
}
示例15: initializeSFEventDispatcher
/**
* Initialize and Configure an SFEventDispatcher instance
*
* @return sfEventDispatcher A configured event dispatcher instance
*/
function initializeSFEventDispatcher()
{
$eventdispatcher = new sfEventDispatcher();
$eventdispatcher->connect(SYSTEM_ADDVARIABLE, "auditTransactionEventHandler");
$eventdispatcher->connect(SYSTEM_UPDATEVARIABLE, "auditTransactionEventHandler");
$eventdispatcher->connect(SYSTEM_DELETEVARIABLE, "auditTransactionEventHandler");
$eventdispatcher->connect(SYSTEM_CREATEROLE, "auditTransactionEventHandler");
$eventdispatcher->connect(SYSTEM_UPDATEROLE, "auditTransactionEventHandler");
$eventdispatcher->connect(SYSTEM_DELETEROLE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_LOGIN, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_LOGOUT, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_CREATE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_UPDATE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_DELETE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_DEACTIVATE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_REACTIVATE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_CHANGE_PASSWORD, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_RESET_PASSWORD, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_RESET_PASSWORD_CONFIRM, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_CHANGE_EMAIL, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_CHANGE_EMAIL_CONFIRM, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_CHANGE_USERNAME, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_RECOVER_PASSWORD, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_INVITE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_ACTIVATE, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_SIGNUP, "auditTransactionEventHandler");
$eventdispatcher->connect(USER_UPLOADPHOTO, "auditTransactionEventHandler");
return $eventdispatcher;
}