<commit_before><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfAction executes all the logic for the current request.
 *
 * @package    symfony
 * @subpackage action
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
abstract class sfAction extends sfComponent
{
  private
    $security = array(),
    $template = '';

  /**
   * Gets current module name
   *
   * @return string
   */
  public function getModuleName()
  {
    return $this->getContext()->getModuleName();
  }

  /**
   * Gets current action name
   *
   * @return string
   */
  public function getActionName()
  {
    return $this->getContext()->getActionName();
  }

  /**
   * Initialize this action.
   *
   * @param sfContext The current application context.
   *
   * @return bool true, if initialization completes successfully, otherwise false.
   */
  public function initialize($context)
  {
    parent::initialize($context);

    // include security configuration
    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true));

    return true;
  }

  /**
   * Execute an application defined process prior to execution of this Action.
   *
   * By Default, this method is empty.
   */
  public function preExecute ()
  {
  }

  /**
   * Execute an application defined process immediately after execution of this Action.
   *
   * By Default, this method is empty.
   */
  public function postExecute ()
  {
  }

  /**
   * DEPRECATED: Returns true if current action template will be executed by the view.
   *
   * This is the case if:
   * - cache is off;
   * - action is not available;
   * - cache is not fresh enough.
   *
   * Use this method to know if you have to populate parameters for the template.
   *
   * @return boolean
   */
  public function mustExecute($suffix = 'slot')
  {
    if (sfConfig::get('sf_logging_active')) $this->getContext()->getLogger()->err('This method is deprecated.');

    if (!sfConfig::get('sf_cache'))
    {
      return 1;
    }

    $cache = $this->getContext()->getViewCacheManager();

    return (!$cache->has(sfRouting::getInstance()->getCurrentInternalUri(), $suffix));
  }

  /**
   * Forwards current action to the default 404 error action
   *
   */
  public function forward404 ()
  {
    throw new sfError404Exception();
  }

  /**
   * Forwards current action to the default 404 error action
   * unless the specified condition is true.
   *
   * @param bool A condition that evaluates to true or false.
   */
  public function forward404Unless ($condition)
  {
    if (!$condition)
    {
      throw new sfError404Exception();
    }
  }

  /**
   * Forwards current action to the default 404 error action
   * if the specified condition is true.
   *
   * @param bool A condition that evaluates to true or false.
   */
  public function forward404If ($condition)
  {
    if ($condition)
    {
      throw new sfError404Exception();
    }
  }

  /**
   * Redirects current action to the default 404 error action (with browser redirection)
   *
   */
  public function redirect404 ()
  {
    return $this->redirect('/'.sfConfig::get('sf_error_404_module').'/'.sfConfig::get('sf_error_404_action'));
  }

  /**
   * Forwards current action to a new one (without browser redirection).
   *
   * This method must be called as with a return:
   *
   * <code>return $this->forward('module', 'action')</code>
   *
   * @param  string module name
   * @param  string action name
   * @return sfView::NONE<commit_msg>added message parameter to sfAction::forward404* functions (closes #710 - patch from tamcy)<commit_after><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfAction executes all the logic for the current request.
 *
 * @package    symfony
 * @subpackage action
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
abstract class sfAction extends sfComponent
{
  private
    $security = array(),
    $template = '';

  /**
   * Gets current module name
   *
   * @return string
   */
  public function getModuleName()
  {
    return $this->getContext()->getModuleName();
  }

  /**
   * Gets current action name
   *
   * @return string
   */
  public function getActionName()
  {
    return $this->getContext()->getActionName();
  }

  /**
   * Initialize this action.
   *
   * @param sfContext The current application context.
   *
   * @return bool true, if initialization completes successfully, otherwise false.
   */
  public function initialize($context)
  {
    parent::initialize($context);

    // include security configuration
    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$this->getModuleName().'/'.sfConfig::get('sf_app_module_config_dir_name').'/security.yml', true));

    return true;
  }

  /**
   * Execute an application defined process prior to execution of this Action.
   *
   * By Default, this method is empty.
   */
  public function preExecute ()
  {
  }

  /**
   * Execute an application defined process immediately after execution of this Action.
   *
   * By Default, this method is empty.
   */
  public function postExecute ()
  {
  }

  /**
   * DEPRECATED: Returns true if current action template will be executed by the view.
   *
   * This is the case if:
   * - cache is off;
   * - action is not available;
   * - cache is not fresh enough.
   *
   * Use this method to know if you have to populate parameters for the template.
   *
   * @return boolean
   */
  public function mustExecute($suffix = 'slot')
  {
    if (sfConfig::get('sf_logging_active')) $this->getContext()->getLogger()->err('This method is deprecated.');

    if (!sfConfig::get('sf_cache'))
    {
      return 1;
    }

    $cache = $this->getContext()->getViewCacheManager();

    return (!$cache->has(sfRouting::getInstance()->getCurrentInternalUri(), $suffix));
  }

  /**
   * Forwards current action to the default 404 error action
   *
   */
  public function forward404 ($message = '')
  {
    throw new sfError404Exception($message);
  }

  /**
   * Forwards current action to the default 404 error action
   * unless the specified condition is true.
   *
   * @param bool A condition that evaluates to true or false.
   */
  public function forward404Unless ($condition, $message = '')
  {
    if (!$condition)
    {
      throw new sfError404Exception($message);
    }
  }

  /**
   * Forwards current action to the default 404 error action
   * if the specified condition is true.
   *
   * @param bool A condition that evaluates to true or false.
   */
  public function forward404If ($condition, $message = '')
  {
    if ($condition)
    {
      throw new sfError404Exception($message);
    }
  }

  /**
   * Redirects current action to the default 404 error action (with browser redirection)
   *
   */
  public function redirect404 ()
  {
    return $this->redirect('/'.sfConfig::get('sf_error_404_module').'/'.sfConfig::get('sf_error_404_action'));
  }

  /**
   * Forwards current action to a new one (without browser redirection).
   *
   * This method must be called as with a return:
   *
   * <code>return $this->forward('module', 'action')</code>
   *
   * @param  string module name
   * @param  string action name
   * @return sfView::NONE
{'fraction_non_alphanumeric': 0.12386203359405051, 'fraction_numerical': 0.01513014489037056, 'mean_word_length': 2.95738203957382, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7633261', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2243, 'n_words': 720}