Example #1
0
 /**
  * Setting values
  *
  * @access   public
  * @param    string $name
  * @param    mixed  $value
  * @throws   Exception\Fatal
  * @sicne    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function __set($name, $value)
 {
     if (Router::isRouteModifyOn() === FALSE) {
         throw new Exception\Fatal('Modifying route in wrong place. Routes can be edited only in routing.php config files.');
     }
     if (property_exists($this, $name)) {
         switch ($name) {
             case 'action':
                 if (!is_string($value)) {
                     throw new Exception\Fatal('Wrong value for route action in "' . $this->name . '" route.');
                 }
                 break;
             case 'controller':
                 if (!is_string($value)) {
                     throw new Exception\Fatal('Wrong value for route controller in "' . $this->name . '" route.');
                 }
                 break;
             case 'defaults':
                 if (!is_array($value)) {
                     throw new Exception\Fatal('Wrong value for route default values in "' . $this->name . '" route.');
                 }
                 break;
             case 'permissions':
                 if (!is_array($value)) {
                     throw new Exception\Fatal('Wrong value for route permissions in "' . $this->name . '" route.');
                 }
                 break;
             case 'parametersTypes':
                 if (!is_array($value)) {
                     throw new Exception\Fatal('Wrong value for route parameters types in "' . $this->name . '" route.');
                 }
                 break;
             case 'url':
             case 'rawURL':
                 if (!is_string($value)) {
                     throw new Exception\Fatal('Wrong value for route URL (or raw URL) in "' . $this->name . '" route.');
                 }
                 break;
         }
         $this->{$name} = $value;
     }
 }