/**
  * Magic __call() method, used for chain-setting attribute values.
  *
  * @param string $name
  * @param array $arguments
  * @return BaseModel
  */
 function __call($name, $arguments)
 {
     if (in_array($name, $this->attributeNames())) {
         if (count($arguments) == 1) {
             $this->setAttribute($name, $arguments[0]);
         } else {
             $this->setAttribute($name, $arguments);
         }
         return $this;
     } else {
         return parent::__call($name, $arguments);
     }
 }
Exemple #2
0
 public function __call($name, $parameters)
 {
     if (isset($this->getMetaData()->relations[$name])) {
         if (empty($parameters)) {
             return $this->getRelated($name, false);
         } else {
             return $this->getRelated($name, false, $parameters[0]);
         }
     }
     $scopes = $this->scopes();
     if (isset($scopes[$name])) {
         $this->getDbCriteria()->mergeWith($scopes[$name]);
         return $this;
     }
     return parent::__call($name, $parameters);
 }
Exemple #3
0
 /**
  * @see CComponent::__call()
  * @param string $name
  * @param array $parameters
  * @return mixed
  */
 public function __call($name, $parameters)
 {
     if (!array_key_exists($name, $this->relations())) {
         return parent::__call($name, $parameters);
     }
     if (empty($parameters)) {
         return $this->getRelated($name, false);
     }
     return $this->getRelated($name, false, $parameters[0]);
 }
Exemple #4
0
 /**
  * Magic __call() method, used for chain-setting attribute values.
  *
  * @param string $name
  * @param array  $arguments
  *
  * @return BaseModel
  */
 public function __call($name, $arguments)
 {
     try {
         return parent::__call($name, $arguments);
     } catch (\CException $e) {
         // Is this one of our attributes?
         if (!$this->strictAttributes || in_array($name, $this->attributeNames())) {
             $copy = $this->copy();
             if (count($arguments) == 1) {
                 $copy->setAttribute($name, $arguments[0]);
             } else {
                 $copy->setAttribute($name, $arguments);
             }
             return $copy;
         }
         throw $e;
     }
 }
Exemple #5
0
 /**
  * Calls the named method which is not a class method.
  * Do not call this method. This is a PHP magic method that we override
  * to implement the named scope feature.
  * @param string $name the method name
  * @param array $parameters method parameters
  * @return mixed the method return value
  */
 public function __call($name, $parameters)
 {
     if (isset($this->_links[$name])) {
         if (empty($parameters)) {
             return $this->getLinked($name, false);
         } else {
             return $this->getLinked($name, false, $parameters[0]);
         }
     }
     $scopes = $this->scopes();
     if (isset($scopes[$name])) {
         $this->getCriteria()->mergeWith($scopes[$name]);
         return $this;
     }
     return parent::__call($name, $parameters);
 }