本文整理汇总了PHP中sfFilterChain::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP sfFilterChain::execute方法的具体用法?PHP sfFilterChain::execute怎么用?PHP sfFilterChain::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfFilterChain
的用法示例。
在下文中一共展示了sfFilterChain::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
*
* @param sfFilterChain $filterChain
*/
public function execute($filterChain)
{
// check to make sure the plugin is enabled, plugin is disabled by default
if (!sfConfig::get('app_sf_guard_extra_plugin_enabled', false)) {
$filterChain->execute();
return;
}
// no point in check if user is logged in =\ or if the are going to the locked out module/action
if (!$this->getContext()->getUser()->isAuthenticated() || sfConfig::get('app_sf_guard_extra_plugin_locked_out_module') == $this->getContext()->getModuleName() && sfConfig::get('app_sf_guard_extra_plugin_locked_out_action') == $this->getContext()->getActionName()) {
$this->checkIfLockedOut();
}
// check to see if user is trying to login
if (!$this->getContext()->getUser()->isAuthenticated() && sfConfig::get('sf_login_module') == $this->getContext()->getModuleName() && sfConfig::get('sf_login_action') == $this->getContext()->getActionName() && 'POST' == $this->getContext()->getRequest()->getMethod()) {
/**
* NOTE: in the future it may be possible to use the form, bind the values,
* and check to see if it is valid here. This is worth looking into
* so the plugin doesn't need to modify any other files.
*/
if (sfConfig::get('sf_logging_enabled')) {
$this->getContext()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('"%s" ("%s") failed trying to login', $this->getUserIP(), $this->getUserHost()))));
}
}
// check to see if the user is logged in if their password will expire soon
if ($this->getContext()->getUser()->isAuthenticated()) {
$this->checkIfPassExpired();
}
// user has access to continue
$filterChain->execute();
}
示例2: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// disable stateful security checking on signin and secure actions
if (sfConfig::get('sf_login_module') == $this->context->getModuleName() && sfConfig::get('sf_login_action') == $this->context->getActionName() || sfConfig::get('sf_secure_module') == $this->context->getModuleName() && sfConfig::get('sf_secure_action') == $this->context->getActionName()) {
$filterChain->execute();
return;
}
$sf_user = $this->context->getUser();
// retrieve the current action
$action = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
// get the current module and action names
$module_name = sfInflector::camelize($action->getModuleName());
$action_name = sfInflector::camelize($action->getActionName());
// get the object for the current route
$object = $this->getObjectForRoute($action->getRoute());
// i.e.: canIndexDefault
$method = "can{$action_name}{$module_name}";
// if the method exist
if (method_exists($sf_user, $method)) {
// execute it
if (!$sf_user->{$method}($object)) {
$this->forwardToSecureAction();
}
} else {
// get the default policy
$default_policy = $this->getParameter('default_policy', 'allow');
// if the default policy is not 'allow'
if ($default_policy != 'allow') {
$this->forwardToSecureAction();
}
}
$filterChain->execute();
return;
}
示例3: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// disable security on login and secure actions
if (sfConfig::get('sf_login_module') == $this->context->getModuleName() && sfConfig::get('sf_login_action') == $this->context->getActionName() || sfConfig::get('sf_secure_module') == $this->context->getModuleName() && sfConfig::get('sf_secure_action') == $this->context->getActionName()) {
$filterChain->execute();
return;
}
// NOTE: the nice thing about the Action class is that getCredential()
// is vague enough to describe any level of security and can be
// used to retrieve such data and should never have to be altered
if (!$this->context->getUser()->isAuthenticated()) {
if (sfConfig::get('sf_logging_enabled')) {
$this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" requires authentication, forwarding to "%s/%s"', $this->context->getModuleName(), $this->context->getActionName(), sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')))));
}
// the user is not authenticated
$this->forwardToLoginAction();
}
// the user is authenticated
$credential = $this->getUserCredential();
if (null !== $credential && !$this->context->getUser()->hasCredential($credential)) {
if (sfConfig::get('sf_logging_enabled')) {
$this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Action "%s/%s" requires credentials "%s", forwarding to "%s/%s"', $this->context->getModuleName(), $this->context->getActionName(), sfYaml::dump($credential, 0), sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')))));
}
// the user doesn't have access
$this->forwardToSecureAction();
}
// the user has access, continue
$filterChain->execute();
}
示例4: execute
/**
*
* @param sfFilterChain $filterChain
*/
public function execute($filterChain)
{
//Ha be van kapcsolva a Schacc login és
//Ha nem is akar bejeletkezni, akkor nincs semmi dolgunk, mehet tovább a lánc
if (!sfConfig::get('sf_Schacc_enable') || !$this->isSignin()) {
$filterChain->execute();
return;
}
$post = $this->getPostParameter('signin');
$user = Doctrine::getTable('SchaccUser')->findOneBy('username', $post['username']);
//Ha van lokális user, ami nem schacc-al került be
//Ezt nem a mi dolgunk kezelni, továbbküldjük
if ($user && !$user->is_schacc) {
$filterChain->execute();
//ha ide eljutunk azt jelenti, hogy nem sikerült autentikálni lokális adatbázisból
//ezt később figyelembe kell vennünk
$has_local_non_schacc_acc = true;
}
//Schacc autentikáció
$this->form = new sfGuardFormSignin();
$this->form->getValidatorSchema()->setPostValidator(new sfSchaccValidatorUser());
$this->form->bind($post);
if ($this->form->isValid()) {
//sikerült autentikálni a Schacc-t
if ($has_local_non_schacc_acc) {
//ha ide jutunk az nagy baj
//azt jelenti, hogy valaki egy Schacc-al próbált bejelentkezni
//de már van egy ugyan olyan felhasználó nevű, de más jelszavú user,
//aki korábban nem Schaccal lépett be,
//hanem regisztrált
//erről nem tudhatjuk biztosan, hogy Ő-e, így figyelmeztetjük
throw new Exception(<<<EOF
Schaccal próbáltál bejelentkezni,
de már van egy ilyen nevű user az adatbázisban,
aki korábban regisztrált.
Ha Te vagy ez a meglévő felhasználó,
lépj be a regisztrációnál megadott jelszavaddal.
Ha nem Te vagy, akkor sajnos más olyan felhasználónevet választott,
ami a Te Schaccod. Kérlek regisztrálj egy másik névvel.
EOF
);
}
$values = $this->form->getValues();
//Ha nem volt eddig ilyen user
if (!$user) {
$user = new SchaccUser();
$user->username = $values['username'];
}
$this->updateProfile($user, $post);
$this->getUser()->signin($user, array_key_exists('remember', $values) ? $values['remember'] : false);
// always redirect to a URL set in app.yml
// or to the referer
// or to the homepage
$signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer(''));
$this->getContext()->getController()->redirect('' != $signinUrl ? $signinUrl : '@homepage');
}
$filterChain->execute();
}
示例5: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// execute this filter only once, if cache is set and no GET or POST parameters
if (!sfConfig::get('sf_cache')) {
$filterChain->execute();
return;
}
if ($this->executeBeforeExecution()) {
$filterChain->execute();
}
$this->executeBeforeRendering();
}
示例6: execute
/**
* Executes the authorization filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
$moduleName = $this->context->getModuleName();
$actionName = $this->context->getActionName();
// disable security on login and secure actions
if (sfConfig::get('sf_login_module') == $moduleName && sfConfig::get('sf_login_action') == $actionName || sfConfig::get('sf_secure_module') == $moduleName && sfConfig::get('sf_secure_action') == $actionName || 'auth' == $moduleName && ($actionName == 'retryLogin' || $actionName == 'validateCredentials' || $actionName == 'logout')) {
$filterChain->execute();
return;
}
$logger = Logger::getLogger('filter.ohrmAuthorizationFilter');
try {
$userRoleManager = UserRoleManagerFactory::getUserRoleManager();
$this->context->setUserRoleManager($userRoleManager);
} catch (Exception $e) {
$logger->error('Exception: ' . $e);
$this->forwardToSecureAction();
}
// disable security on non-secure actions
try {
$secure = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance()->getSecurityValue('is_secure');
if (!$secure || $secure === "false" || $secure === "off") {
$filterChain->execute();
return;
}
} catch (sfStopException $e) {
// sfStopException is a symfony internal exception and
// shouldn't be treated as a normal exception
throw $e;
} catch (Exception $e) {
$logger->error('Error getting is_secure value for action: ' . $e);
$this->forwardToSecureAction();
}
try {
$permissions = $userRoleManager->getScreenPermissions($moduleName, $actionName);
} catch (Exception $e) {
$logger->error('Exception: ' . $e);
$this->forwardToSecureAction();
}
// user does not have read permissions
if (!$permissions->canRead()) {
$logger->warn('User does not have access read access to ' . $moduleName . ' - ' . $actionName);
// the user doesn't have access
$this->forwardToSecureAction();
} else {
// set permissions in context
$this->context->set('screen_permissions', $permissions);
}
// the user has access, continue
$filterChain->execute();
}
示例7: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// This filter should affect only real mobile phone
if (sfConfig::get('sf_environment') === 'test') {
$filterChain->execute();
return null;
}
$this->convertEmojiForInput();
$this->convertEncodingForInput();
$filterChain->execute();
$this->convertEmptyElementsForHTML4();
$this->convertEncodingForOutput();
$this->outputContentTypeHeader();
}
示例8: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
if ($this->request->getParameter('dm_embed')) {
sfConfig::set('dm_admin_embedded', true);
sfConfig::set('dm_toolBar_enabled', false);
}
$this->saveApplicationUrl();
$this->loadAssetConfig();
if (sfConfig::get('dm_admin_embedded')) {
$this->response->addStylesheet('admin.embed', 'last');
$this->getContext()->getEventDispatcher()->connect('admin.save_object', array($this, 'listenToAdminSaveObjectWhenEmbedded'));
}
$this->updateLock();
$filterChain->execute();
if (sfConfig::get('dm_admin_embedded')) {
$this->response->addStylesheet('admin.embed');
} else {
// If response has no title, generate one with the H1
if ($this->response->isHtmlForHuman() && !$this->response->getTitle()) {
preg_match('|<h1[^>]*>(.*)</h1>|iuUx', $this->response->getContent(), $matches);
if (isset($matches[1])) {
$title = 'Admin : ' . strip_tags($matches[1]) . ' - ' . dmConfig::get('site_name');
$this->response->setContent(str_replace('<title></title>', '<title>' . $title . '</title>', $this->response->getContent()));
}
}
}
}
示例9: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filter_chain The filter chain
*/
public function execute(sfFilterChain $filter_chain)
{
$action_instance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
// Keep track only of trackable actions
if ($this->isTrackable($action_instance))
{
try
{
$entry = ncTrackerEntryPeer::createFromAction($action_instance);
$this->log('Created a new ncTrackerEntry.');
}
catch (PropelException $exception)
{
$this->log(
sprintf('Unable to create a new ncTrackerEntry. Error message: %s.', $exception->getMessage())
);
}
}
else
{
$this->log(
sprintf('Ignored non-trackable action: %s/%s.', $action_instance->getModuleName(), $action_instance->getActionName())
);
}
$filter_chain->execute($filter_chain);
}
示例10: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// execute next filter
$filterChain->execute();
// execute this filter only once
$response = $this->context->getResponse();
// include javascripts and stylesheets
$content = $response->getContent();
if (false !== ($pos = strpos($content, '</head>')))
{
$this->context->getConfiguration()->loadHelpers(array('Tag', 'Asset'));
$html = '';
if (!sfConfig::get('symfony.asset.javascripts_included', false))
{
$html .= get_javascripts($response);
}
if (!sfConfig::get('symfony.asset.stylesheets_included', false))
{
$html .= get_stylesheets($response);
}
if ($html)
{
$response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
}
}
sfConfig::set('symfony.asset.javascripts_included', false);
sfConfig::set('symfony.asset.stylesheets_included', false);
}
示例11: execute
/**
* Insert appropriate experiment code.
*
* @throws sfConfigurationException If the configured experiment type cannot be found
*
* @param sfFilterChain $filterChain
*/
public function execute($filterChain)
{
$filterChain->execute();
// connect to each active experiment
$prefix = 'app_sf_google_website_optimizer_plugin_';
if (sfConfig::get($prefix . 'enabled', false)) {
$request = $this->context->getRequest();
$response = $this->context->getResponse();
foreach (sfConfig::get($prefix . 'experiments', array()) as $name => $param) {
// merge default with configured parameters
$param = array_merge(array('enabled' => true, 'type' => null, 'key' => null, 'uacct' => sfConfig::get($prefix . 'uacct'), 'pages' => array()), $param);
if ($param['enabled']) {
// determine experiment class
$classes = sfConfig::get($prefix . 'classes', array());
$classes = array_merge(array('ab' => 'sfGWOExperimentAB', 'multivariate' => 'sfGWOExperimentMultivariate'), $classes);
if (isset($classes[$param['type']])) {
$class = $classes[$param['type']];
$experiment = new $class($name, $param);
if ($experiment->connect($request)) {
$experiment->insertContent($response);
}
} else {
throw new sfConfigurationException(sprintf('The experiment type "%s" was not found.', $param['type']));
}
}
}
}
}
示例12: execute
/**
* Executes filter chain
*
* @param sfFilterChain $filterChain
*/
public function execute($filterChain)
{
if ($this->isFirstCall()) {
$context = $this->getContext();
$request = $context->getRequest();
$response = $context->getResponse();
$user = $context->getUser();
$cookieName = sfConfig::get('app_translation_cookie', 'myCulture');
//get the user's preferred browser language
$culture = $request->getPreferredCulture(sfConfig::get('sf_translations_available', array()));
$this->log(sprintf('Browser language is %s', $culture));
//override with a user cookie language if it exists
if ($request->getCookie($cookieName)) {
$culture = $request->getCookie($cookieName);
$this->log(sprintf('Overriding culture %s from culture cookie', $culture));
}
//has the user overridden the language manually?
if ($request->getParameter('sf_culture') && in_array(strtolower($request->getParameter('sf_culture')), array_map('strtolower', sfConfig::get('sf_translations_available', array())))) {
//set the language for this request, so you don't have to refresh
$culture = $request->getParameter('sf_culture');
//update the cookie with the new language for future requests
$response->setCookie($cookieName, $culture, time() + 60 * 60 * 24 * 30 * 12 * 30, '/');
$this->log(sprintf('Culture manually overridden to %s', $culture));
}
$this->log(sprintf('Applying culture: %s for this session', $culture));
$user->setCulture($culture);
sfConfig::set('sf_current_culture', $culture);
$context->getResponse()->addMeta('language', $culture, true);
}
$filterChain->execute();
}
示例13: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
// This filter should affect only real mobile phone
if (sfConfig::get('sf_environment') === 'test') {
$filterChain->execute();
return null;
}
$this->convertEmojiForInput();
$this->convertEncodingForInput();
$filterChain->execute();
$this->convertEmptyElementsForHTML4();
if ($this->getContext()->getRequest()->getMobile()->isDoCoMo() && opConfig::get('font_size')) {
$this->convertAddFont4Docomo();
}
$this->convertEncodingForOutput();
$this->outputContentTypeHeader();
}
示例14: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
if ($this->isFirstCall() && !$this->context->getUser()->isAuthenticated()) {
if ($memberId = $this->context->getUser()->getRememberedMemberId()) {
$this->context->getUser()->login($memberId);
}
}
$filterChain->execute();
}
示例15: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
$request = $this->context->getRequest();
if (!$request->isMobile()) {
if (!$this->isErrorAction()) {
$this->forwardToErrorAction();
}
}
$filterChain->execute();
}