Development

#1596: sf-1596-behavior-config-validation.patch

You must first sign up to be able to contribute.

Ticket #1596: sf-1596-behavior-config-validation.patch

File sf-1596-behavior-config-validation.patch, 1.2 kB (added by trivoallan, 2 years ago)
  • lib/addon/propel/sfPropelBehavior.class.php

    old new  
    5858      } 
    5959      else 
    6060      { 
     61        // validate parameters 
     62 
     63        /* 
     64         * Behavior classes can implement a `checkConfig(array $parameters, string $class)` method. 
     65         *  
     66         * This method can be used to validate configuration given by user. It should throw a `sfConfigurationException` 
     67         * if supplied configuration is not valid. 
     68         *  
     69         * For this to work correctly, behavior name (first argument to  
     70         * `sfPropelBehavior::add()`, `sfPropelBehavior::registerHook()` and `sfPropelBehavior::registerMethod()`) 
     71         * must be the name of the class implementing the `checkConfig()` method. 
     72         */ 
     73        $validation_callback = array($name, 'checkConfig'); 
     74        if (is_callable($validation_callback)) 
     75        { 
     76          call_user_func($validation_callback, $parameters, $class); 
     77        } 
     78 
    6179        // register parameters 
    6280        foreach ($parameters as $key => $value) 
    6381        {