Ejemplo n.º 1
0
 public function add(AbstractOption $option)
 {
     if (array_key_exists($option->getName(), $this->options)) {
         throw new \InvalidArgumentException(sprintf('An option with the name %s exists already.', $option->getName()));
     }
     $this->options[$option->getName()] = $option;
 }
 /**
  * {@inheritdoc}
  */
 public function setValue($value)
 {
     if (!is_bool($value) && $value !== null) {
         throw new \InvalidArgumentException(sprintf('The option "%s" only accepts boolean value.', $this->getName()));
     }
     parent::setValue($value);
 }
Ejemplo n.º 3
0
 /**
  *
  * @param type $name
  * @param type $function 
  * @param ... args the names of the arguments the javascript function should take
  */
 public function __construct($name, $function)
 {
     parent::__construct($name);
     Args::isString($function, 'function');
     $this->function = $function;
     $args = func_get_args();
     for ($i = 2; $i < count($args); $i++) {
         array_push($this->args, $args[$i]);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function setValue($value)
 {
     if (is_string($value)) {
         try {
             $value = new \DateTime($value);
         } catch (\Exception $e) {
             throw new \InvalidArgumentException($e->getMessage());
         }
     }
     if (!$value instanceof \DateTime && $value !== null) {
         throw new \InvalidArgumentException(sprintf('The option "%s" only accepts \\DateTime objects or strings.', $this->getName()));
     }
     parent::setValue($value);
 }
 public function setFromParams(array $params, $calledBySelf = false)
 {
     if (is_array($params[0])) {
         foreach ($params[0] as $paramArray) {
             $this->setFromParams($paramArray);
         }
         return $this;
     }
     if ($calledBySelf) {
         return parent::setFromParams($params);
     } else {
         $item = new static();
         $item->setFromParams($params, true);
         $this->__collection[] = $item;
         return $this;
     }
 }
Ejemplo n.º 6
0
 public function __construct($name, $value)
 {
     parent::__construct($name, $value);
     Args::isString($value, 'value');
     $this->value = $value;
 }