示例#1
0
文件: Acl.php 项目: zaxcms/framework
 public function __call($name, $args = [])
 {
     if (method_exists($this->acl, $name)) {
         return call_user_func_array([$this->acl, $name], $args);
     }
     return parent::__call($name, $args);
 }
示例#2
0
 /**
  * Allows calling $column->icon() instead of $column->setIcon (Same for title, class, ...)
  * @param  string $name
  * @param  array  $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $method_setter = 'set' . ucfirst($name);
     if (method_exists($this, $method_setter)) {
         return Nette\Utils\Callback::invokeArgs([$this, $method_setter], $args);
     }
     parent::__call($name, $args);
 }
示例#3
0
 public function __call($methodName, $args)
 {
     if (preg_match('|.*getModel([a-zA-Z0-9]+).*|', $methodName, $mtch)) {
         if (class_exists('Model\\' . $mtch[1] . 'Model')) {
             return $this->modelLoader->loadModel($mtch[1] . 'Model');
         }
     } else {
         return parent::__call($methodName, $args);
     }
 }
示例#4
0
 /**
  * @param string $name
  * @param array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $function = 'newrelic_' . self::convertCamelCaseToUnderscore($name);
     if (!extension_loaded('newrelic')) {
         return FALSE;
     }
     if (!function_exists($function)) {
         return parent::__call($name, $args);
     }
     return call_user_func_array($function, $args);
 }
 public function __call($name, $args)
 {
     foreach ($this->getExtensions() as $extension) {
         /* @var $extension ExtensionObject */
         if ($extension->getReflection()->hasMethod($name)) {
             $method = $extension->getReflection()->getMethod($name);
             if ($method->isPublic() && !$method->isStatic() && !$method->isAbstract()) {
                 return \callback($extension, $name)->invokeArgs($args);
             }
         }
         if ($extension->getReflection()->hasEventProperty($name)) {
             return ObjectMixin::call($extension, $name, $args);
         }
     }
     return parent::__call($name, $args);
 }
示例#6
0
	/**
	 * Call a template run-time helper. Do not call directly.
	 * @param  string  helper name
	 * @param  array   arguments
	 * @return mixed
	 */
	public function __call($name, $args)
	{
		$lname = strtolower($name);
		if (!isset($this->helpers[$lname])) {
			foreach ($this->helperLoaders as $loader) {
				$helper = $loader/*5.2*->invoke*/($lname);
				if ($helper) {
					$this->registerHelper($lname, $helper);
					return $this->helpers[$lname]->invokeArgs($args);
				}
			}
			return parent::__call($name, $args);
		}

		return $this->helpers[$lname]->invokeArgs($args);
	}
示例#7
0
文件: Dir.php 项目: kdyby/filesystem
 /**
  * @param string $name
  * @param array $args
  * @return mixed
  * @throws IOException
  */
 public function __call($name, $args)
 {
     if (isset(self::$fileArg[$name])) {
         $dir = $this->dir;
         $args[self::$fileArg[$name]] = is_array($args[self::$fileArg[$name]]) ? array_map(function ($arg) use($dir) {
             return $dir . DIRECTORY_SEPARATOR . $arg;
         }, $args[self::$fileArg[$name]]) : $this->dir . DIRECTORY_SEPARATOR . $args[self::$fileArg[$name]];
         try {
             call_user_func_array(array($this->io, $name), $args);
             return $this;
         } catch (SfException $e) {
             throw new IOException($e->getMessage(), 0, $e);
         }
     }
     return parent::__call($name, $args);
 }
示例#8
0
 public function __call($name, $args)
 {
     if (preg_match('~^create(Select|Update|Delete|Insert)$~', $name, $m)) {
         #query object factory
         $class = "Flunorette\\Queries\\{$m[1]}Query";
         $queryContext = new QueryContext(reset($args), $this);
         return new $class($queryContext);
     }
     return parent::__call($name, $args);
 }
示例#9
0
 /**
  * Call to undefined method.
  *
  * @param  string  method name
  * @param  array   arguments
  * @return mixed
  * @throws Nette\MemberAccessException
  */
 public function __call($name, $args)
 {
     $function = 'image' . $name;
     if (function_exists($function)) {
         foreach ($args as $key => $value) {
             if ($value instanceof self) {
                 $args[$key] = $value->getImageResource();
             } elseif (is_array($value) && isset($value['red'])) {
                 // rgb
                 $args[$key] = imagecolorallocatealpha($this->image, $value['red'], $value['green'], $value['blue'], $value['alpha']);
             }
         }
         array_unshift($args, $this->image);
         $res = call_user_func_array($function, $args);
         return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res;
     }
     return parent::__call($name, $args);
 }
 /**
  * Calls internal facebook SDK task
  *
  * @param  string $name
  * @param  array $args
  * @return mixed
  */
 function __call($name, $args)
 {
     try {
         return NCallback::invokeArgs(array($this->fb, $name), $args);
     } catch (Nette\InvalidArgumentException $e) {
         return parent::__call($name, $args);
     }
 }
示例#11
0
 /**
  * Call a template run-time helper. Do not call directly.
  * @param  string  helper name
  * @param  array   arguments
  * @return mixed
  */
 public function __call($name, $args)
 {
     $lname = strtolower($name);
     if (!isset($this->helpers[$lname])) {
         foreach ($this->helperLoaders as $loader) {
             $helper = Callback::invoke($loader, $lname);
             if ($helper) {
                 $this->registerHelper($lname, $helper);
                 return Callback::invokeArgs($this->helpers[$lname], $args);
             }
         }
         return parent::__call($name, $args);
     }
     return Callback::invokeArgs($this->helpers[$lname], $args);
 }
示例#12
0
 /**
  * @param  string $name
  * @param  array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     if (strncmp($name, 'getBy', 5) === 0 && strlen($name) > 5) {
         $selection = $this->getTable()->limit(1);
         $properties = explode('And', substr($name, 5));
         if (count($properties) !== count($args)) {
             throw new Exception\InvalidArgumentException('Wrong number of argument passed to ' . $name . ' method - ' . count($properties) . ' expected, ' . count($args) . ' given.');
         }
         $ref = Reflection\EntityType::from($class = $this->getEntityClass());
         foreach ($properties as $key => $property) {
             $property = lcfirst($property);
             $prop = $ref->getEntityProperty($property);
             if ($prop === NULL) {
                 throw new Exception\InvalidArgumentException("Property '\${$property}' not found in entity '{$class}'.");
             }
             $selection->where($prop->getColumn(), $args[$key]);
         }
         return $this->createEntityFromSelection($selection);
     } elseif (strncmp($name, 'findBy', 6) === 0 && strlen($name) > 6) {
         $selection = $this->getTable();
         $properties = explode('And', substr($name, 6));
         if (count($properties) !== count($args)) {
             throw new Exception\InvalidArgumentException('Wrong number of argument passed to ' . $name . ' method - ' . count($properties) . ' expected, ' . count($args) . ' given.');
         }
         $criteria = [];
         $ref = Reflection\EntityType::from($class = $this->getEntityClass());
         foreach ($properties as $key => $property) {
             $property = lcfirst($property);
             $prop = $ref->getEntityProperty($property);
             if ($prop === NULL) {
                 throw new Exception\InvalidArgumentException("Property '\${$property}' not found in entity '{$class}'.");
             }
             $criteria[$prop->getColumn()] = $args[$key];
         }
         return $this->findBy($criteria);
     }
     return parent::__call($name, $args);
 }
示例#13
0
文件: Repository.php 项目: Vyki/orm
 public function __call($method, $args)
 {
     if (isset($this->proxyMethods[strtolower($method)])) {
         if (FindByParserHelper::parse($method, $args)) {
             return call_user_func([$this, $method], $args);
         }
         $result = call_user_func_array([$this->mapper, $method], $args);
         if (!($result instanceof ICollection || $result instanceof IEntity || $result === NULL)) {
             $result = $this->mapper->toCollection($result);
         }
         return $result;
     } else {
         return parent::__call($method, $args);
     }
 }
示例#14
0
 /**
  * Method overload for findBy...
  *
  * @param string $name
  * @param array $args
  * @return mixed
  * @throws InvalidArgumentException
  */
 public function __call($name, $args)
 {
     if (strncmp($name, 'findBy', 6) === 0 && strlen($name) > 6) {
         $name = lcfirst(substr($name, 6));
         $metadata = Metadata::getMetadata($this->entity);
         $identityMap = $this->em->getIdentityMap($this->entity);
         return $identityMap->map($this->em->connection->select("*")->from($metadata->tableName)->where("[" . Tools::underscore($name) . "] = " . $this->getModificator($name), $args[0])->execute()->fetch());
     } else {
         return parent::__call($name, $args);
     }
 }
示例#15
0
 /**
  * Method overload for findBy...
  *
  * @param string $name
  * @param array $args
  * @return mixed
  * @throws InvalidArgumentException
  */
 public function __call($name, $args)
 {
     if (strncmp($name, 'findBy', 6) === 0 && strlen($name) > 6) {
         $entity = $args[0];
         unset($args[0]);
         return callback($this->getRepository($entity), $name)->invokeArgs($args);
     } else {
         return parent::__call($name, $args);
     }
 }
示例#16
0
 /**
  * Performs calling "magic" methods from annotations.
  *
  * For example, annotation `method SomePage clickFoo()` defines a magic
  * method that calls `$this->foo->click()` and returns an object of type
  * `SomePage`. If `$this` is instance of that type, it will return `$this`.
  * Otherwise it instantiates a new object.
  *
  * Either way it calls the method {@see self::checkState()} afterwise on the
  * return object.
  *
  * The annotation may contain more return types, separated by vertical bar.
  * First that match is returned back.
  *
  * Another magic method is fillShortcut - if it is defined such a shortcut,
  * it will translate to `$this->shortcut->value($input)`, but it returns
  * `$this`.
  *
  * @param string $name Name of called method.
  * @param array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     if (!isset($this->methods)) {
         foreach ($this->getThisClasses() as $className) {
             $annotations = Utils::getClassAnnotations($className);
             $methodAnnotations = isset($annotations['method']) ? $annotations['method'] : array();
             foreach ($methodAnnotations as $methodAnnotation) {
                 if (preg_match('~^(?<type>[^\\s]+)\\s+(?<methodName>[^\\s(]+)~', $methodAnnotation, $matches)) {
                     $returnType = $matches['type'];
                     $fullMethodName = $matches['methodName'];
                     if (preg_match('~^(?<elementMethod>[[:lower:]]+)(?<elementShortcut>.*)~', $fullMethodName, $matches)) {
                         $elementMethod = $matches['elementMethod'];
                         $elementShortcut = isset($this->{$matches['elementShortcut']}) ? $matches['elementShortcut'] : lcfirst($matches['elementShortcut']);
                         if (isset($this->{$elementShortcut})) {
                             $this->methods[$fullMethodName] = array($elementShortcut, $elementMethod, $returnType, $className);
                         }
                     }
                 }
             }
         }
     }
     if (isset($this->methods[$name])) {
         $elementShortcut = $this->methods[$name][0];
         $elementMethod = $this->methods[$name][1];
         callback($this->{$elementShortcut}, $elementMethod)->invokeArgs($args);
         $this->session->waitForDocument();
         return $this->getNextPageFromList(explode('|', $this->methods[$name][2]), $this->methods[$name][3]);
     } elseif (substr($name, 0, 4) === 'fill' && (isset($this->{$shortcut = substr($name, 4)}) || isset($this->{$shortcut = lcfirst(substr($name, 4))}))) {
         callback($this->{$shortcut}, 'value')->invokeArgs($args);
         return $this;
     } else {
         return parent::__call($name, $args);
     }
 }
示例#17
0
 /**
  * Magic function for getters / setters
  *
  * @param string variable name
  * @return mixed data
  *
  * @throws Nette\MemberAccessException if field doesn't exists or name is empty
  * @throws Nette\InvalidStateException if field with given key is not cached (and getter is called)
  */
 public function __call($name, $args)
 {
     $setMode = Nette\Utils\Strings::startsWith($name, "set");
     $getMode = Nette\Utils\Strings::startsWith($name, "get");
     $hasMode = Nette\Utils\Strings::startsWith($name, "has");
     if (($setMode || $getMode || $hasMode) && count($args) > 0) {
         if (mb_strlen($name) > 3) {
             // Musim data bacha na MB kodovani
             $fieldName = \mb_substr($name, 3);
             $fieldName = \mb_strtolower(\mb_substr($fieldName, 0, 1), 'UTF-8') . \mb_substr($fieldName, 1);
         } else {
             $fieldName = array_shift($args);
         }
         // Pokud jde o definovane pole
         if ($this->eMetadata->hasField($fieldName)) {
             if (!isset($this->data)) {
                 $this->loadData();
             }
             $ptr =& $this->data->table;
             foreach ($this->eMetadata->getIdFields() as $idField) {
                 if (count($args) == 0) {
                     throw new Nette\InvalidArgumentException("Missing primary key '{$idField}'");
                 }
                 $key = array_shift($args);
                 if (!isset($ptr[$key])) {
                     if ($setMode) {
                         $ptr[$key] = array();
                     } elseif ($hasMode) {
                         return false;
                     } else {
                         throw new Nette\InvalidStateException("Key '{$key}' not cached for '{$this->eClass}'");
                     }
                 }
                 $ptr =& $ptr[$key];
             }
             if ($getMode) {
                 return $ptr->{$fieldName};
             } elseif ($hasMode) {
                 return true;
             } else {
                 if (is_array($ptr)) {
                     $ptr = new \StdClass();
                 }
                 $ptr->{$fieldName} = count($args) ? array_shift($args) : NULL;
                 $this->cache->save('data', $this->data);
                 return;
             }
         }
     }
     parent::__call($name, $args);
 }
示例#18
0
 /**
  * Method overload for universal getter/setter
  * 
  * @param string $name associtation name
  * @param array $attr
  * @return mixed
  * @throws MemberAccessException
  */
 public function __call($name, $attr)
 {
     try {
         $metadata = Metadata::getMetadata(get_called_class());
         if (strncmp($name, 'get', 3) === 0 && $metadata->hasColumn(lcfirst(substr($name, 3)))) {
             return $this->universalGetValue(lcfirst(substr($name, 3)));
         } elseif (strncmp($name, 'set', 3) === 0 && $metadata->hasColumn(lcfirst(substr($name, 3)))) {
             return $this->universalSetValue(lcfirst(substr($name, 3)), isset($attr[0]) ? $attr[0] : NULL);
         } else {
             return parent::__call($name, $attr);
         }
     } catch (\MemberAccessException $e) {
         return parent::__call($name, $attr);
     }
 }
示例#19
0
 public function __call($method, $args)
 {
     if (isset($this->proxyMethods[strtolower($method)])) {
         if (substr($method, 0, 5) === 'getBy' || substr($method, 0, 6) === 'findBy') {
             return call_user_func_array([$this->findAll(), $method], $args);
         }
         $result = call_user_func_array([$this->mapper, $method], $args);
         if (!($result instanceof ICollection || $result instanceof IEntity)) {
             $result = $this->mapper->toCollection($result);
         }
         return $result;
     } else {
         return parent::__call($method, $args);
     }
 }
示例#20
0
InvalidArgumentException("Unsupported image type.");}header('Content-Type: '.image_type_to_mime_type($type));return$this->save(NULL,$quality,$type);}function
__call($name,$args){$function='image'.$name;if(function_exists($function)){foreach($args
as$key=>$value){if($value
instanceof
self){$args[$key]=$value->getImageResource();}elseif(is_array($value)&&isset($value['red'])){$args[$key]=imagecolorallocatealpha($this->getImageResource(),$value['red'],$value['green'],$value['blue'],$value['alpha']);}}array_unshift($args,$this->getImageResource());$res=call_user_func_array($function,$args);return
is_resource($res)&&get_resource_type($res)==='gd'?$this->setImageResource($res):$res;}return
parent::__call($name,$args);}}class