当前位置: 首页>>代码示例>>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;未经允许,请勿转载。