本文整理汇总了PHP中yii\base\Component::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::__call方法的具体用法?PHP Component::__call怎么用?PHP Component::__call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Component
的用法示例。
在下文中一共展示了Component::__call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($name, $parameters)
{
if (method_exists($this->_api, $name)) {
return call_user_func_array(array($this->_api, $name), $parameters);
}
return parent::__call($name, $parameters);
}
示例2: __call
/**
* @param string $name
* @param array $params
* @return mixed|object
*/
public function __call($name, $params)
{
$query = strpos($name, 'Query');
$static = strpos($name, 'static');
if ($static === 0) {
$property = mb_substr($name, 6);
} else {
if ($query !== false) {
$property = mb_substr($name, 6, -5);
} else {
$property = mb_substr($name, 6);
}
}
$property = lcfirst($property) . 'Class';
if ($static === 0) {
$method = ArrayHelper::remove($params, '0', 'className');
return forward_static_call_array([$this->{$property}, $method], $params);
}
if ($query) {
$method = ArrayHelper::remove($params, '0', 'find');
return forward_static_call_array([$this->{$property}, $method], $params);
}
if (isset($this->{$property})) {
$config = [];
if (isset($params[0]) && is_array($params[0])) {
$config = $params[0];
}
$config['class'] = $this->{$property};
return Yii::createObject($config);
}
return parent::__call($name, $params);
}
示例3: __call
public function __call($name, $params)
{
if (!method_exists($this->getClient(), $name)) {
return parent::__call($name, $params);
}
return call_user_func_array(array($this->getClient(), $name), $params);
}
示例4: __call
public function __call($name, $params)
{
if (method_exists($this->_client, $name)) {
return call_user_func_array([$this->_client, $name], $params);
}
return parent::__call($name, $params);
}
示例5: __call
public function __call($method, $params)
{
$sdk = $this->getSdk();
if (is_callable([$sdk, $method])) {
return call_user_func_array(array($sdk, $method), $params);
}
return parent::__call($method, $params);
}
示例6: __call
/**
* Use magic PHP function __call to route function calls to the adLDAP class.
* Look into the adLDAP class for possible functions.
*
* @param string $methodName Method name from adLDAP class
* @param array $methodParams Parameters pass to method
* @return mixed
*/
public function __call($methodName, $methodParams)
{
if (method_exists($this->adLdapClass, $methodName)) {
return call_user_func_array(array($this->adLdapClass, $methodName), $methodParams);
} else {
return parent::__call($methodName, $methodParams);
}
}
示例7: __call
public function __call($name, $params)
{
$ucFunctionName = 'uc_' . $name;
if (function_exists($ucFunctionName)) {
return call_user_func_array($ucFunctionName, $params);
}
return parent::__call($name, $params);
}
示例8: __call
public function __call($method, $params)
{
$client = $this->getAws();
if (method_exists($client, $method)) {
return call_user_func_array(array($client, $method), $params);
}
return parent::__call($method, $params);
}
示例9: __call
public function __call($name, $params)
{
if (method_exists($this->getService(), $name)) {
call_user_func_array([$this->getService(), $name], $params);
return $this;
} else {
return parent::__call($name, $params);
}
}
示例10: __call
/**
* Proxy the calls to the Pusher object if the methods doesn't explixitly exist in this class.
*
* If the method called is not found in the Pusher Object continue with standard Yii behaviour
*/
public function __call($method, $params)
{
//Override the normal Yii functionality checking the Keen SDK for a matching method
if (method_exists($this->_pusher, $method)) {
return call_user_func_array(array($this->_pusher, $method), $params);
}
//Use standard Yii functionality, checking behaviours
return parent::__call($method, $params);
}
示例11: __call
public function __call($name, $params)
{
if (strpos($name, static::INTERNAL_HANDLER) === 0 && isset($params[0]) && $params[0] instanceof \yii\base\Event) {
$event = $params[0];
$handler = $this->_handlers[$event->name][$name];
if ($event instanceof Event) {
$extraParams = $event->params;
array_unshift($extraParams, $event);
$event->result = call_user_func_array($handler, $extraParams);
} else {
call_user_func($handler, $event);
}
} else {
return parent::__call($name, $params);
}
}
示例12: __call
/**
* Calls the named method which is not a class method.
*
* This method will check whether PSR-3 or Yii2 format is used and will execute the corresponding method.
*
* @param string $name The method name.
* @param array $arguments Method arguments.
*
* @return mixed The method return value.
*/
public function __call($name, array $arguments)
{
// Intercept calls to the "log()" method
if ($name === 'log' && !empty($arguments)) {
// PSR-3 format
$reflection = new ReflectionClass(YiiLogger::className());
if (in_array($arguments[0], array_keys($this->_monolog->getLevels())) && !in_array($arguments[1], array_keys($reflection->getConstants())) && (!isset($arguments[3]) || isset($arguments[3]) && is_array($arguments[3]))) {
return call_user_func_array([$this, 'log'], $arguments);
}
// Yii2 format
return call_user_func_array([$this, 'yiiLog'], $arguments);
}
// Execute Monolog methods, if they exists
if (method_exists($this->_monolog, $name) && !method_exists($this, $name)) {
return call_user_func_array([$this->_monolog, $name], $arguments);
}
return parent::__call($name, $arguments);
}
示例13: __call
public function __call($name, $params)
{
$methods = ['get', 'getasync', 'post', 'postasync', 'put', 'putasync', 'patch', 'patchasync'];
if (in_array(strtolower($name), $methods)) {
if (count($params) < 1) {
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
}
$uri = $params[0];
if (isset($params[1]) && is_array($params[1])) {
$params = $params[1];
if (isset($params['headers'])) {
$params['headers']['Authorization'] = 'Bearer ' . $this->token;
} else {
$params['headers'] = ['Authorization' => 'Bearer ' . $this->token];
}
} else {
$params = ['headers' => ['Authorization' => 'Bearer ' . $this->token]];
}
$query = [];
if (isset($params['query'])) {
$query = $params['query'];
unset($params['query']);
}
$uri = static::buildUrl($this->baseUrl, $uri, $query);
$result = call_user_func_array([$this->client, $name], [$uri, $params]);
$this->_restObject->result($result);
return $this->_restObject;
}
return parent::__call($name, $params);
}
示例14: __call
/**
* @param string $name
* @param array $params
* @return mixed|object
*/
public function __call($name, $params)
{
$property = false !== ($query = strpos($name, 'Query')) ? mb_substr($name, 6, -5) : mb_substr($name, 6);
$property = lcfirst($property) . 'Class';
if ($query) {
return forward_static_call([$this->{$property}, 'find']);
}
if (isset($this->{$property})) {
$config = [];
if (isset($params[0]) && is_array($params[0])) {
$config = $params[0];
}
$config['class'] = $this->{$property};
return \Yii::createObject($config);
}
return parent::__call($name, $params);
}
示例15: __call
/**
* Any requests to set or get attributes or call methods on this class that
* are not found are redirected to the {@link IService} object.
* @param string $name the method name
* @param array $parameters the method parameters
* @return mixed
* @throws \Exception
*/
public function __call($name, $parameters)
{
try {
return parent::__call($name, $parameters);
} catch (\Exception $e) {
if (method_exists($this->_service, $name)) {
return call_user_func_array(array($this->_service, $name), $parameters);
} else {
throw $e;
}
}
}