本文整理汇总了PHP中sfEvent::setReturnValue方法的典型用法代码示例。如果您正苦于以下问题:PHP sfEvent::setReturnValue方法的具体用法?PHP sfEvent::setReturnValue怎么用?PHP sfEvent::setReturnValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfEvent
的用法示例。
在下文中一共展示了sfEvent::setReturnValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: componentMethodNotFound
public function componentMethodNotFound(sfEvent $event)
{
$actions = $event->getSubject();
$method = $event['method'];
$args = $event['arguments'];
if ($method == 'getEntityManager') {
$databaseManager = $actions->getContext()->getDatabaseManager();
$names = $databaseManager->getNames();
if ($args) {
$name = $args[0];
if (!in_array($name, $names)) {
throw new sfException(sprintf('Could not get the entity manager for ' . 'the database connection named: "%s"', $name));
}
$database = $databaseManager->getDatabase($args[0]);
} else {
$database = $databaseManager->getDatabase(end($names));
}
$event->setReturnValue($database->getEntityManager());
return true;
} else {
if ($method == 'getEntityManagerFor') {
$entityName = $args[0];
if (is_object($entityName)) {
$entityName = get_class($entityName);
}
$databaseManager = $actions->getContext()->getDatabaseManager();
$names = $databaseManager->getNames();
foreach ($names as $name) {
$em = $databaseManager->getDatabase($name)->getEntityManager();
$cmf = $em->getMetadataFactory();
if ($cmf->hasMetadataFor($entityName)) {
$event->setReturnValue($em);
return true;
}
}
return false;
} else {
if ($method == 'getMetadataFor') {
$entityName = $args[0];
if (is_object($entityName)) {
$entityName = get_class($entityName);
}
$databaseManager = $actions->getContext()->getDatabaseManager();
$names = $databaseManager->getNames();
foreach ($names as $name) {
$em = $databaseManager->getDatabase($name)->getEntityManager();
$cmf = $em->getMetadataFactory();
if ($cmf->hasMetadataFor($entityName)) {
$event->setReturnValue($cmf->getMetadataFor($entityName));
return true;
}
}
return false;
} else {
return false;
}
}
}
}
示例2: listenToHandleHeader
public static function listenToHandleHeader(sfEvent $event)
{
switch ($event['header']) {
case 'AuthHeader':
$event->setReturnValue(self::handleAuthHeader($event['data']));
break;
case 'ExtraHeader':
$event->setReturnValue(self::handleExtraHeader($event['data']));
break;
default:
return false;
}
return true;
}
示例3: listenToContextMethodNotFoundEvent
public function listenToContextMethodNotFoundEvent(sfEvent $event)
{
$parameters = $event->getParameters();
if ('getFacebook' != $parameters['method']) {
return false;
}
if ($this->_facebook instanceof sfFacebook) {
$event->setReturnValue($this->_facebook);
return true;
}
$this->_facebook = new sfFacebook($this->dispatcher);
$event->setReturnValue($this->_facebook);
$this->dispatcher->notify(new sfEvent($this, 'facebook.configure'));
return true;
}
开发者ID:JoshuaEstes,项目名称:sfDoctrineFacebookPlugin,代码行数:15,代码来源:sfDoctrineFacebookPluginConfiguration.class.php
示例4: processApplicationConfirm
public function processApplicationConfirm(sfEvent $event)
{
$app = sfConfig::get('sf_app');
$invite = Doctrine::getTable('ApplicationInvite')->find($event['id']);
if (!$invite) {
return false;
}
$application = $invite->getApplication();
if ('pc_frontend' === $app) {
if (!$application->getIsPc()) {
return false;
}
} elseif ('mobile_frontend' === $app) {
if (!$application->getIsMobile()) {
return false;
}
}
if ($event['is_accepted']) {
$action = $event->getSubject();
if ($action instanceof sfAction) {
$action->redirect('@application_add?id=' . $application->getId() . '&invite=' . $invite->getId());
}
} else {
$invite->delete();
$event->setReturnValue("You have just rejected request of invitation to app.");
}
return true;
}
示例5: listenToMethodNotFound
/**
* Listens to component.method_not_found event.
*
* @param sfEvent A sfEvent instance
*
* @return Boolean true if the method has been found in this class, false otherwise
*/
public function listenToMethodNotFound(sfEvent $event)
{
if (!method_exists($this, $method = $event['method'])) {
return false;
}
$event->setReturnValue(call_user_func(array($this, $method), $event->getSubject()));
return true;
}
示例6: newMethod
public static function newMethod(sfEvent $event)
{
if ($event['method'] == 'newMethod') {
$arguments = $event['arguments'];
$event->setReturnValue($arguments[0]);
return true;
}
}
示例7: call
/**
* Adds 1.0 compatibility methods to the request object.
*
* @param sfEvent $event The event
*
* @return Boolean true if the method has been found here, false otherwise
*/
public static function call(sfEvent $event)
{
if (!in_array($event['method'], array('getError', 'getErrorNames', 'getErrors', 'hasError', 'hasErrors', 'removeError', 'setError', 'setErrors', 'getFile', 'getFileError', 'getFileName', 'getFileNames', 'getFilePath', 'getFileSize', 'getFileType', 'hasFile', 'hasFileError', 'hasFileErrors', 'hasFiles', 'getFileValue', 'getFileValues', 'getFileExtension', 'moveFile'))) {
return false;
}
$event->setReturnValue(call_user_func_array(array('sfRequestCompat10', $event['method']), array_merge(array($event->getSubject()), $event['arguments'])));
return true;
}
示例8: listenToHelperMethodNotFoundEvent
public function listenToHelperMethodNotFoundEvent(sfEvent $event)
{
if (method_exists($this, $event['method'])) {
$event->setReturnValue(call_user_func_array(array($this, $event['method']), $event['arguments']));
return true;
}
return false;
}
示例9: handleException
public static function handleException(sfEvent $event)
{
$moduleName = sfConfig::get('sf_error_500_module', 'connexion');
$actionName = sfConfig::get('sf_error_500_action', 'error500');
sfContext::getInstance()->getRequest()->addRequestParameters(array('exception' => $event->getSubject()));
$event->setReturnValue(true);
sfContext::getInstance()->getController()->forward($moduleName, $actionName);
}
示例10: observeMethodNotFound
public static function observeMethodNotFound(sfEvent $event)
{
if (method_exists('sfActionExtra', $event['method'])) {
$args = array_merge(array($event->getSubject()), $event['arguments']);
$ret = call_user_func_array(array('sfActionExtra', $event['method']), $args);
$event->setReturnValue($ret);
return $ret;
}
}
示例11: listenSetThemeFromRequest
public function listenSetThemeFromRequest(sfEvent $event)
{
$context = $event['context'];
if ($context->getModuleName() == 'controller' && $context->getActionName() == 'eventListener') {
$event->setReturnValue('test_theme');
return true;
}
return false;
}
示例12: listenToComponentMethodNotFoundEvent
/**
* Listens to the component.method_not_found event.
*
* @param sfEvent $event An sfEvent instance
*
* @return bool True, if the method is the 'isSoapRequest', false otherwise
*/
public static function listenToComponentMethodNotFoundEvent(sfEvent $event)
{
if ($event['method'] == 'isSoapRequest') {
$event->setReturnValue(self::isSoapRequest());
return true;
} else {
return false;
}
}
示例13: observe
/**
* Get the current tracker object.
*
* @param sfEvent $event
*
* @return bool
*/
public static function observe(sfEvent $event)
{
switch ($event['method']) {
case 'getGemiusTrafficTracker':
$event->setReturnValue(sfGemiusTrafficMixin::getTracker());
return true;
case 'setGemiusTrafficTracker':
sfGemiusTrafficMixin::setTracker($event['arguments'][0]);
return true;
}
}
示例14: observe
/**
* Get the current tracker object.
*
* @param sfEvent $event
*
* @return bool
*/
public static function observe(sfEvent $event)
{
$subject = $event->getSubject();
switch ($event['method']) {
case 'getTracker':
$event->setReturnValue(sfGoogleAnalyticsMixin::getTracker($subject));
return true;
case 'setTracker':
sfGoogleAnalyticsMixin::setTracker($subject, $event['arguments'][0]);
return true;
}
}
示例15: processFriendConfirm
public static function processFriendConfirm(sfEvent $event)
{
$toMember = Doctrine::getTable('Member')->find($event['id']);
$relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($event['member']->id, $toMember->id);
if (!$relation) {
$relation = Doctrine::getTable('MemberRelationship')->create(array('member_id_from' => $event['member']->id, 'member_id_to' => $toMember->id));
}
if (!$relation->isFriendPreTo()) {
return false;
}
if ($event['is_accepted']) {
$relation->setFriend();
$event->setReturnValue('You have just accepted %friend% link request.');
$params = array('subject' => sfContext::getInstance()->getI18N()->__('%1% accepted your %friend% link request', array('%1%' => $event['member']->getName())), 'member' => $event['member']);
opMailSend::sendTemplateMail('friendLinkComplete', $toMember->getEmailAddress(), opConfig::get('admin_mail_address'), $params);
} else {
$event->setReturnValue('You have just rejected %friend% link request.');
$relation->removeFriendPre();
}
return true;
}