示例#1
0
 public function __call($name, $args)
 {
     if (!preg_match('/^get/', $name)) {
         return parent::__call($name, $args);
     }
     $property = preg_replace('/^get/', '', $name);
     $first = mb_convert_case(mb_substr($property, 0, 1), MB_CASE_LOWER);
     $property = '_' . preg_replace('/^./', $first, $property);
     return isset($this->{$property}) ? $this->{$property} : parent::__call($name, $args);
 }
示例#2
0
 public function __call($method, $args)
 {
     $accessor = substr($method, 0, 3);
     $magicKeys = array('set', 'get', 'uns', 'has');
     if (in_array($accessor, $magicKeys)) {
         $key = Core_Model_Lib_String::camelize(substr($method, 3));
         $method = $accessor . 'Data';
         $value = isset($args[0]) ? $args[0] : null;
         return call_user_func(array($this, $method), $key, $value);
     }
     return parent::__call($method, $args);
 }
示例#3
0
 /**
  * @param string $method
  * @param array $arguments
  * @return mixed|Model\Document\Tag|string
  * @throws \Exception
  */
 public function __call($method, $arguments)
 {
     $class = "\\Pimcore\\Model\\Document\\Tag\\" . ucfirst(strtolower($method));
     $classFound = true;
     if (!\Pimcore\Tool::classExists($class)) {
         $oldStyleClass = "Document_Tag_" . ucfirst(strtolower($method));
         if (!\Pimcore\Tool::classExists($oldStyleClass)) {
             $classFound = false;
         }
     }
     if ($classFound) {
         if (!isset($arguments[0])) {
             throw new \Exception("You have to set a name for the called tag (editable): " . $method);
         }
         // set default if there is no editable configuration provided
         if (!isset($arguments[1])) {
             $arguments[1] = array();
         }
         return $this->tag($method, $arguments[0], $arguments[1]);
     }
     if ($this->document instanceof Model\Document) {
         if (method_exists($this->document, $method)) {
             return call_user_func_array(array($this->document, $method), $arguments);
         }
     }
     return parent::__call($method, $arguments);
 }
示例#4
0
 /**
  * @throws Exception
  * @param $method
  * @param $arguments
  * @return mixed|string|Tag
  */
 public function __call($method, $arguments)
 {
     $class = "Document_Tag_" . ucfirst(strtolower($method));
     $tagFile = str_replace("_", "/", $class) . ".php";
     if (Pimcore_File::isIncludeable($tagFile)) {
         include_once $tagFile;
         if (@Pimcore_Tool::classExists($class)) {
             if (!isset($arguments[0])) {
                 throw new Exception("You have to set a name for the called tag (editable): " . $method);
             }
             // set default if there is no editable configuration provided
             if (!isset($arguments[1])) {
                 $arguments[1] = array();
             }
             return $this->tag($method, $arguments[0], $arguments[1]);
         }
     }
     if ($this->document instanceof Document) {
         if (method_exists($this->document, $method)) {
             return call_user_func_array(array($this->document, $method), $arguments);
         }
     }
     return parent::__call($method, $arguments);
 }