當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfEventDispatcher::filter方法代碼示例

本文整理匯總了PHP中sfEventDispatcher::filter方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfEventDispatcher::filter方法的具體用法?PHP sfEventDispatcher::filter怎麽用?PHP sfEventDispatcher::filter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfEventDispatcher的用法示例。


在下文中一共展示了sfEventDispatcher::filter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: shouldShowEditor

 /**
  * Returns whether or not inline editing should be enabled.
  *
  * This method can be called "in general" (no $obj passed) or answered
  * for a very specific object being modified.
  *
  * @param Object $object The Object being edited - could be a Doctrine_Record, Doctrine_Collection 
  * @return boolean
  */
 public function shouldShowEditor($obj = null, $forceRefresh = false)
 {
     $key = $obj === null ? 'generic' : spl_object_hash($obj);
     if (!isset($this->_shouldShowEditor[$key]) || $forceRefresh) {
         $credential = $this->getOption('admin_credential');
         if ($credential) {
             $shouldShow = $this->_user->hasCredential($credential);
         } else {
             // even if no credential were passed, still require a login at least
             $shouldShow = $this->_user->isAuthenticated();
         }
         $event = new sfEvent($this, 'editable_content.should_show_editor', array('user' => $this->_user, 'object' => $obj));
         $this->_dispatcher->filter($event, $shouldShow);
         $this->_shouldShowEditor[$key] = $event->getReturnValue();
     }
     return $this->_shouldShowEditor[$key];
 }
開發者ID:kimbrelas,項目名稱:ioEditableContentPlugin,代碼行數:26,代碼來源:ioEditableContentService.class.php

示例2: sfEvent

$e = $dispatcher->notifyUntil($event = new sfEvent(new stdClass(), 'foo'));
$t->is($listener->getValue(), 'listenToFooBis', '->notifyUntil() notifies all registered listeners in order and stops if it returns true');
// ->filter()
$t->diag('->filter()');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$e = $dispatcher->filter($event = new sfEvent(new stdClass(), 'foo'), 'foo');
$t->is($e->getReturnValue(), '-*foo*-', '->filter() filters a value');
$t->is($e, $event, '->filter() returns the event object');
$listener->reset();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$e = $dispatcher->filter($event = new sfEvent(new stdClass(), 'foo'), 'foo');
$t->is($e->getReturnValue(), '*-foo-*', '->filter() filters a value');
class Listener
{
    protected $value = '';
    function filterFoo(sfEvent $event, $foo)
    {
        return "*{$foo}*";
    }
    function filterFooBis(sfEvent $event, $foo)
    {
        return "-{$foo}-";
    }
    function listenToFoo(sfEvent $event)
    {
        $this->value .= 'listenToFoo';
開發者ID:Phennim,項目名稱:symfony1,代碼行數:31,代碼來源:sfEventDispatcherTest.php

示例3: getWindows

 protected function getWindows()
 {
     return $this->dispatcher->filter(new sfEvent($this, 'dm.admin_homepage.filter_windows'), $this->getDefaultWindows())->getReturnValue();
 }
開發者ID:runopencode,項目名稱:diem-extended,代碼行數:4,代碼來源:dmAdminHomepageManager.php


注:本文中的sfEventDispatcher::filter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。