本文整理汇总了PHP中sfEvent::setProcessed方法的典型用法代码示例。如果您正苦于以下问题:PHP sfEvent::setProcessed方法的具体用法?PHP sfEvent::setProcessed怎么用?PHP sfEvent::setProcessed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfEvent
的用法示例。
在下文中一共展示了sfEvent::setProcessed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listenToMethodNotFound
public function listenToMethodNotFound(sfEvent $event)
{
$parameters = $event->getParameters();
if ($parameters['method'] == 'defineCombinedAssets') {
$this->loaded_assets = count($parameters['arguments']) > 0 ? $parameters['arguments'][0] : array();
$event->setProcessed(true);
}
if ($parameters['method'] == 'getCombinedAssets') {
$event->setReturnValue($this->loaded_assets);
$event->setProcessed(true);
}
}
示例2: extend
public function extend(sfEvent $event)
{
$this->_subject = $event->getSubject();
$method = $event['method'];
$arguments = $event['arguments'];
if (method_exists($this, $method)) {
$result = call_user_func_array(array($this, $method), $arguments);
$event->setProcessed(true);
$event->setReturnValue($result);
return true;
} else {
return false;
}
}
示例3: listenToFormMethodNotFound
/**
* Listen to the form.method_not_found event
*
* @param sfEvent $event
* @return void
*/
public static function listenToFormMethodNotFound(sfEvent $event)
{
$form = $event->getSubject();
// do not process events of non-object forms
if (!$form instanceof BaseFormDoctrine || $form instanceof FakeObjectForm) {
return;
}
switch (strtolower($event['method'])) {
case 'setobject':
if (count($event['arguments']) !== 1) {
throw new InvalidArugmentException('The number of arguments is invalid.');
}
self::setObject($form, $event['arguments'][0]);
$event->setProcessed(true);
break;
case 'embedcollection':
if (count($event['arguments']) < 2 || count($event['arguments']) > 3) {
throw new InvalidArgumentException('The number of arguments is invalid.');
}
self::embedCollection($form, $event['arguments'][0], $event['arguments'][1], isset($event['arguments'][2]) ? $event['arguments'][2] : array());
$event->setProcessed(true);
break;
}
}
示例4: run
public function run(sfEvent $event)
{
if (isset($event['pager'])) {
$pager = $event['pager'];
$context = sfContext::getInstance();
$response = $context->getResponse();
$request = $context->getRequest();
$className = 'sf' . ucfirst($event['format']) . 'Feed';
if (!class_exists($className)) {
return false;
}
$feed = sfFeedPeer::newInstance($event['format']);
$feed->initialize(array('title' => $response->getTitle(), 'link' => $request->getUri()));
$items = sfFeedPeer::convertObjectsToItems($pager->getResults());
$feed->addItems($items);
$event->setProcessed(true);
$event->setReturnValue($feed->asXml());
$request->setRequestFormat($event['format']);
return true;
} else {
return false;
}
}
示例5: listenOnComponentMethodNotFoundEvent
/**
* Listens on "component.method_not_found"
*
* @param sfEvent $event
* @return null
*/
public static function listenOnComponentMethodNotFoundEvent(sfEvent $event)
{
try {
$callable = array(new sfViewCacheTagManagerBridge($event->getSubject()), $event['method']);
$value = call_user_func_array($callable, $event['arguments']);
$event->setReturnValue($value);
$event->setProcessed(true);
} catch (BadMethodCallException $e) {
$event->setProcessed(false);
} catch (sfException $e) {
$event->setProcessed(true);
self::notifyApplicationLog(__CLASS__, $e->getMessage(), sfLogger::NOTICE);
}
}
示例6: catch
// ->getSubject()
$t->diag('->getSubject()');
$t->is($event->getSubject(), $subject, '->getSubject() returns the event subject');
// ->getName()
$t->diag('->getName()');
$t->is($event->getName(), 'name', '->getName() returns the event name');
// ->getParameters()
$t->diag('->getParameters()');
$t->is($event->getParameters(), $parameters, '->getParameters() returns the event parameters');
// ->getReturnValue() ->setReturnValue()
$t->diag('->getReturnValue() ->setReturnValue()');
$event->setReturnValue('foo');
$t->is($event->getReturnValue(), 'foo', '->getReturnValue() returns the return value of the event');
// ->setProcessed() ->isProcessed()
$t->diag('->setProcessed() ->isProcessed()');
$event->setProcessed(true);
$t->is($event->isProcessed(), true, '->isProcessed() returns true if the event has been processed');
$event->setProcessed(false);
$t->is($event->isProcessed(), false, '->setProcessed() changes the processed status');
// ArrayAccess interface
$t->diag('ArrayAccess interface');
$t->is($event['foo'], 'bar', 'sfEvent implements the ArrayAccess interface');
$event['foo'] = 'foo';
$t->is($event['foo'], 'foo', 'sfEvent implements the ArrayAccess interface');
try {
$event['foobar'];
$t->fail('::offsetGet() throws an InvalidArgumentException exception when the parameter does not exist');
} catch (InvalidArgumentException $e) {
$t->pass('::offsetGet() throws an InvalidArgumentException exception when the parameter does not exist');
}
$t->ok(isset($event['foo']), 'sfEvent implements the ArrayAccess interface');
示例7: handleMemoryLimitEvent
public function handleMemoryLimitEvent(sfEvent $event)
{
// store the current state
$this->saveState($event['model'], array('limit' => $event['limit'], 'page' => $event['page']));
$event->setProcessed(true);
}