本文整理匯總了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();
}