Development

Changeset 5384

You must first sign up to be able to contribute.

Changeset 5384

Show
Ignore:
Timestamp:
10/05/07 21:01:58 (2 years ago)
Author:
fabien
Message:

renamed sfValidator to sfValidatorBase to avoid class name collision with symfony 1.1 validation system
activated sf_compat_10 mode

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/UPGRADE

    r5120 r5384  
    2121you upgrade to a new symfony 1.1 beta / RC or the final symfony 1.1, you 
    2222need to launch this task. 
     23 
     24If you don't plan to upgrade the validation system or all your helpers to 
     25the new system, you must enable the compatibility mode in `settings.yml`: 
     26 
     27  [yml] 
     28  all: 
     29    .settings: 
     30      compat_10: on 
     31 
     32Here is a list of the things that will be enabled when switching to the 
     33compatibility mode (see the bundled `sfCompat10Plugin` plugin for 
     34more information): 
     35 
     36  * Zend Framework and ezComponents bridges 
     37  * sfProcessCache 
     38  * validation system (validate.yml, validator classes, ...) 
     39  * fill in filter 
     40  * helpers 
     41  * sfMail with phpmailer 
    2342 
    2443The remaining sections explains backward incompatible changes. 
  • trunk/data/config/autoload.yml

    r5221 r5384  
    55    path:           %SF_SYMFONY_LIB_DIR% 
    66    recursive:      on 
    7     exclude:        [vendor
     7    exclude:        [vendor, plugins
    88 
    99  # plugins 
  • trunk/data/config/config_handlers.yml

    r4853 r5384  
    5353  class:    sfCacheConfigHandler 
    5454 
    55 modules/*/validate/*.yml: 
    56   class:    sfValidatorConfigHandler 
    57  
    5855modules/*/config/module.yml: 
    5956  class:    sfDefineEnvironmentConfigHandler 
  • trunk/data/config/filters.yml

    r4934 r5384  
    2929# execution filter must be the last registered filter 
    3030execution: 
    31   class: sfExecutionFilter 
     31  class: sfExecutionFilter 
    3232  param: 
    3333    type: execution 
  • trunk/lib/filter/sfExecutionFilter.class.php

    r5214 r5384  
    1111 
    1212/** 
    13  * sfExecutionFilter is the last filter registered for each filter chain. This 
     13 * sfValidationExecutionFilter is the last filter registered for each filter chain. This 
    1414 * filter does all action and view execution. 
    1515 * 
     
    3535    $actionInstance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance(); 
    3636 
    37     // validate and execute the action 
     37    // execute the action 
    3838    if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) 
    3939    { 
     
    6060      $timer->addTime(); 
    6161    } 
    62  
    63     // execute the filter chain (needed if fill-in filter is activated by the validation system) 
    64     $filterChain->execute(); 
    6562  } 
    6663 
     
    8582    if (($actionInstance->getRequestMethods() & $method) != $method) 
    8683    { 
    87       // this action will skip validation/execution for this method 
     84      // this action will skip execution for this method 
    8885      // get the default view 
    8986      return $actionInstance->getDefaultView(); 
    9087    } 
    9188 
    92     return $this->validateAction($filterChain, $actionInstance) ? $this->executeAction($actionInstance) : $this->handleErrorAction($actionInstance); 
    93   } 
    94  
    95   /** 
    96    * Validates an sfAction instance. 
    97    * 
    98    * @param  sfAction An sfAction instance 
    99    * 
    100    * @return boolean  True if the action is validated, false otherwise 
    101    */ 
    102   protected function validateAction($filterChain, $actionInstance) 
    103   { 
    104     $moduleName = $actionInstance->getModuleName(); 
    105     $actionName = $actionInstance->getActionName(); 
    106  
    107     // set default validated status 
    108     $validated = true; 
    109  
    110     // get the current action validation configuration 
    111     $validationConfig = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.$actionName.'.yml'; 
    112  
    113     // load validation configuration 
    114     // do NOT use require_once 
    115     if (null !== $validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 
    116     { 
    117       // create validator manager 
    118       $validatorManager = new sfValidatorManager($this->context); 
    119  
    120       require($validateFile); 
    121  
    122       // process validators 
    123       $validated = $validatorManager->execute(); 
    124     } 
    125  
    126     // process manual validation 
    127     $validateToRun = 'validate'.ucfirst($actionName); 
    128     $manualValidated = method_exists($actionInstance, $validateToRun) ? $actionInstance->$validateToRun() : $actionInstance->validate(); 
    129  
    130     // action is validated if: 
    131     // - all validation methods (manual and automatic) return true 
    132     // - or automatic validation returns false but errors have been 'removed' by manual validation 
    133     $validated = ($manualValidated && $validated) || ($manualValidated && !$validated && !$this->context->getRequest()->hasErrors()); 
    134  
    135     // register fill-in filter 
    136     if (null !== ($parameters = $this->context->getRequest()->getAttribute('symfony.fillin'))) 
    137     { 
    138       $this->registerFillInFilter($filterChain, $parameters); 
    139     } 
    140  
    141     if (!$validated && sfConfig::get('sf_logging_enabled')) 
    142     { 
    143       $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array('Action validation failed'))); 
    144     } 
    145  
    146     return $validated; 
     89    return $this->executeAction($actionInstance); 
    14790  } 
    14891 
     
    162105 
    163106    return $viewName ? $viewName : sfView::SUCCESS; 
    164   } 
    165  
    166   /** 
    167    * Executes the handleError method of an action. 
    168    * 
    169    * @param  sfAction An sfAction instance 
    170    * 
    171    * @return string   The view type 
    172    */ 
    173   protected function handleErrorAction($actionInstance) 
    174   { 
    175     // validation failed 
    176     $handleErrorToRun = 'handleError'.ucfirst($actionInstance->getActionName()); 
    177     $viewName = method_exists($actionInstance, $handleErrorToRun) ? $actionInstance->$handleErrorToRun() : $actionInstance->handleError(); 
    178  
    179     return $viewName ? $viewName : sfView::ERROR; 
    180107  } 
    181108 
     
    247174    } 
    248175  } 
    249  
    250   /** 
    251    * Registers the fill in filter in the filter chain. 
    252    * 
    253    * @param sfFilterChain A sfFilterChain implementation instance 
    254    * @param array         An array of parameters to pass to the fill in filter. 
    255    */ 
    256   protected function registerFillInFilter($filterChain, $parameters) 
    257   { 
    258     // automatically register the fill in filter if it is not already loaded in the chain 
    259     if (isset($parameters['enabled']) && $parameters['enabled'] && !$filterChain->hasFilter('sfFillInFormFilter')) 
    260     { 
    261       // register the fill in form filter 
    262       $fillInFormFilter = new sfFillInFormFilter($this->context, isset($parameters['param']) ? $parameters['param'] : array()); 
    263       $filterChain->register($fillInFormFilter); 
    264     } 
    265   } 
    266176} 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfCallbackValidator.class.php

    r5320 r5384  
    2929 * @version    SVN: $Id$ 
    3030 */ 
    31 class sfCallbackValidator extends sfValidator 
     31class sfCallbackValidator extends sfValidatorBase 
    3232{ 
    3333  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfCompareValidator.class.php

    r5320 r5384  
    3535 * @version    SVN: $Id$ 
    3636 */ 
    37 class sfCompareValidator extends sfValidator 
     37class sfCompareValidator extends sfValidatorBase 
    3838{ 
    3939  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfDateValidator.class.php

    r5320 r5384  
    2020 * @version    SVN: $Id$ 
    2121 */ 
    22 class sfDateValidator extends sfValidator 
     22class sfDateValidator extends sfValidatorBase 
    2323{ 
    2424  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfEmailValidator.class.php

    r5320 r5384  
    2020 * @version    SVN: $Id$ 
    2121 */ 
    22 class sfEmailValidator extends sfValidator 
     22class sfEmailValidator extends sfValidatorBase 
    2323{ 
    2424  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfFileValidator.class.php

    r5320 r5384  
    2828 * @version    SVN: $Id$ 
    2929 */ 
    30 class sfFileValidator extends sfValidator 
     30class sfFileValidator extends sfValidatorBase 
    3131{ 
    3232  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfNumberValidator.class.php

    r5320 r5384  
    3434 * @version    SVN: $Id$ 
    3535 */ 
    36 class sfNumberValidator extends sfValidator 
     36class sfNumberValidator extends sfValidatorBase 
    3737{ 
    3838  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfRegexValidator.class.php

    r5320 r5384  
    3333 * @version    SVN: $Id$ 
    3434 */ 
    35 class sfRegexValidator extends sfValidator 
     35class sfRegexValidator extends sfValidatorBase 
    3636{ 
    3737  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfStringValidator.class.php

    r5320 r5384  
    4040 * @version    SVN: $Id$ 
    4141 */ 
    42 class sfStringValidator extends sfValidator 
     42class sfStringValidator extends sfValidatorBase 
    4343{ 
    4444  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfUrlValidator.class.php

    r5320 r5384  
    1717 * @version    SVN: $Id$ 
    1818 */ 
    19 class sfUrlValidator extends sfValidator 
     19class sfUrlValidator extends sfValidatorBase 
    2020{ 
    2121  /** 
  • trunk/lib/plugins/sfCompat10Plugin/lib/validator/sfValidator.class.php

    r5320 r5384  
    1111 
    1212/** 
    13  * sfValidator allows you to apply constraints to user entered parameters. 
     13 * sfValidatorBase allows you to apply constraints to user entered parameters. 
    1414 * 
    1515 * @package    symfony 
     
    1919 * @version    SVN: $Id$ 
    2020 */ 
    21 abstract class sfValidator 
     21abstract class sfValidatorBase 
    2222{ 
    2323  protected 
  • trunk/lib/plugins/sfCompat10Plugin/test/bootstrap/functional.php

    r5320 r5384  
    88 * file that was distributed with this source code. 
    99 */ 
    10  
    11 // we need sqlite for functional tests 
    12 if (!extension_loaded('SQLite')) 
    13 { 
    14   return false; 
    15 } 
    1610 
    1711if (!isset($root_dir)) 
     
    3024sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir')); 
    3125 
    32 if (isset($fixtures)) 
    33 { 
    34   // initialize database manager 
    35   $databaseManager = new sfDatabaseManager(); 
    36   $databaseManager->initialize(); 
    37  
    38   // cleanup database 
    39   $db = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'/database.sqlite'; 
    40   if (file_exists($db)) 
    41   { 
    42     unlink($db); 
    43   } 
    44  
    45   // initialize database 
    46   $sql = file_get_contents(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'sql'.DIRECTORY_SEPARATOR.'lib.model.schema.sql'); 
    47   $sql = preg_replace('/^\s*\-\-.+$/m', '', $sql); 
    48   $sql = preg_replace('/^\s*DROP TABLE .+?$/m', '', $sql); 
    49   $con = Propel::getConnection(); 
    50   $tables = preg_split('/CREATE TABLE/', $sql); 
    51   foreach ($tables as $table) 
    52   { 
    53     $table = trim($table); 
    54     if (!$table) 
    55     { 
    56       continue; 
    57     } 
    58  
    59     $con->executeQuery('CREATE TABLE '.$table); 
    60   } 
    61  
    62   // load fixtures 
    63   $data = new sfPropelData(); 
    64   if (is_array($fixtures)) 
    65   { 
    66     $data->loadDataFromArray($fixtures); 
    67   } 
    68   else 
    69   { 
    70     $data->loadData(sfConfig::get('sf_data_dir').'/'.$fixtures); 
    71   } 
    72 } 
    73  
    7426return true; 
  • trunk/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/config/settings.yml

    r5320 r5384  
    2222 
    2323all: 
     24  .settings: 
     25    compat_10: on 
     26 
    2427#  .actions: 
    2528#    default_module:         default 
  • trunk/lib/plugins/sfCompat10Plugin/test/functional/fixtures/config/databases.yml

    r5320 r5384  
    1 all: 
    2   propel: 
    3     class:          sfPropelDatabase 
    4     param: 
    5       phptype:      sqlite 
    6       database:     %SF_DATA_DIR%/database.sqlite 
     1#all: 
     2#  propel: 
     3#    class:          sfPropelDatabase 
     4#    param: 
     5#      dsn:          mysql://root:@localhost/dbname 
  • trunk/lib/plugins/sfCompat10Plugin/test/functional/fixtures/data

    • Property svn:ignore changed from
      database.sqlite
      to

  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfCallbackValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
    1313 
    1414$t = new lime_test(11, new lime_output_color()); 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfCompareValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    13 require_once($_test_dir.'/unit/sfValidatorTestHelper.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
     13require_once(dirname(__FILE__).'/sfValidatorTestHelper.class.php'); 
    1414 
    1515$t = new lime_test(55, new lime_output_color()); 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfEmailValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
    1313 
    1414$t = new lime_test(28, new lime_output_color()); 
    1515 
    1616$context = sfContext::getInstance(); 
    17 $v = new sfEmailValidator(); 
    18 $v->initialize($context); 
     17$v = new sfEmailValidator($context); 
    1918 
    2019// ->execute() 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfNumberValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    13 require_once($_test_dir.'/unit/sfValidatorTestHelper.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
     13require_once(dirname(__FILE__).'/sfValidatorTestHelper.class.php'); 
    1414 
    1515$t = new lime_test(49, new lime_output_color()); 
    1616 
    1717$context = sfContext::getInstance(); 
    18 $v = new sfNumberValidator(); 
    19 $v->initialize($context); 
     18$v = new sfNumberValidator($context); 
    2019 
    2120// ->execute() 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfRegexValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
    1313 
    1414$t = new lime_test(9, new lime_output_color()); 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfStringValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    13 require_once($_test_dir.'/unit/sfValidatorTestHelper.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
     13require_once(dirname(__FILE__).'/sfValidatorTestHelper.class.php'); 
    1414 
    1515$t = new lime_test(36, new lime_output_color()); 
    1616 
    1717$context = sfContext::getInstance(); 
    18 $v = new sfStringValidator(); 
    19 $v->initialize($context); 
     18$v = new sfStringValidator($context); 
    2019 
    2120// ->execute() 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfUrlValidatorTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
    1313 
    1414$t = new lime_test(12, new lime_output_color()); 
    1515 
    1616$context = sfContext::getInstance(); 
    17 $v = new sfUrlValidator(); 
    18 $v->initialize($context); 
     17$v = new sfUrlValidator($context); 
    1918 
    2019// ->execute() 
  • trunk/lib/plugins/sfCompat10Plugin/test/unit/validator/sfValidatorBaseTest.php

    r5320 r5384  
    99 */ 
    1010 
    11 require_once(dirname(__FILE__).'/../../../../../../test/bootstrap/unit.php'); 
    12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 
     11require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
     12require_once($_test_dir.'/../../../../test/unit/sfContextMock.class.php'); 
    1313 
    1414$t = new lime_test(11, new lime_output_color()); 
    1515 
    16 class myValidator extends sfValidator 
     16class myValidator extends sfValidatorBase 
    1717{ 
    1818  function execute (&$value, &$error) {} 
     
    2020 
    2121$context = sfContext::getInstance(); 
    22 $validator = new myValidator(); 
    23 $validator->initialize($context); 
     22$validator = new myValidator($context); 
    2423 
    2524// ->getContext() 
     
    2928 
    3029// parameter holder proxy 
    31 require_once($_test_dir.'/unit/sfParameterHolderTest.class.php'); 
     30require_once($_test_dir.'/../../../../test/unit/sfParameterHolderTest.class.php'); 
    3231$pht = new sfParameterHolderProxyTest($t); 
    3332$pht->launchTests($validator, 'parameter'); 
  • trunk/lib/plugins/sfPropelPlugin/config/autoload.yml

    r5221 r5384  
    1010    recursive:      on 
    1111 
     12  propel_class: 
     13    name:           propel class 
     14    files: 
     15      Propel:       %SF_SYMFONY_LIB_DIR%/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php 
     16 
    1217  propel_addon: 
    1318    name:           propel addon 
    14     files: 
    15       Propel:       %SF_SYMFONY_LIB_DIR%/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php 
     19    path:           %SF_SYMFONY_LIB_DIR%/plugins/sfPropelPlugin/lib 
     20    recursive:      on 
     21    exclude:        [vendor] 
  • trunk/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/backend/config/settings.yml

    r2794 r5384  
    2222 
    2323all: 
     24  .settings: 
     25    compat_10: on 
    2426#  .actions: 
    2527#    default_module:         default 
  • trunk/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/crud/config/settings.yml

    r2794 r5384  
    2222 
    2323all: 
     24  .settings: 
     25    compat_10: on 
    2426#  .actions: 
    2527#    default_module:         default 
  • trunk/lib/util/sfAutoload.class.php

    r5231 r5384  
    2525 
    2626  protected 
     27    $overriden = array(), 
    2728    $classes = array(); 
    2829 
     
    5354  } 
    5455 
     56  public function setClassPath($class, $path) 
     57  { 
     58    $this->overriden[$class] = $path; 
     59 
     60    $this->classes[$class] = $path; 
     61  } 
     62 
    5563  public function getClassPath($class) 
    5664  { 
     
    6876 
    6977    $this->classes = include($file); 
     78 
     79    foreach ($this->overriden as $class => $path) 
     80    { 
     81      $this->classes[$class] = $path; 
     82    } 
    7083  } 
    7184 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.