本文整理汇总了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];
}
示例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';
示例3: getWindows
protected function getWindows()
{
return $this->dispatcher->filter(new sfEvent($this, 'dm.admin_homepage.filter_windows'), $this->getDefaultWindows())->getReturnValue();
}