当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::__call方法代码示例

本文整理汇总了PHP中Object::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::__call方法的具体用法?PHP Object::__call怎么用?PHP Object::__call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object的用法示例。


在下文中一共展示了Object::__call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __call

 /**
  * Magic method (do not call directly).
  * @param  string  method name
  * @param  array   arguments
  * @return mixed
  * @throws \MemberAccessException
  * @throws FtpException
  */
 public function __call($name, $args)
 {
     $name = strtolower($name);
     $silent = strncmp($name, 'try', 3) === 0;
     $func = $silent ? substr($name, 3) : $name;
     static $aliases = array('sslconnect' => 'ssl_connect', 'getoption' => 'get_option', 'setoption' => 'set_option', 'nbcontinue' => 'nb_continue', 'nbfget' => 'nb_fget', 'nbfput' => 'nb_fput', 'nbget' => 'nb_get', 'nbput' => 'nb_put');
     $func = 'ftp_' . (isset($aliases[$func]) ? $aliases[$func] : $func);
     if (!function_exists($func)) {
         return parent::__call($name, $args);
     }
     /*Nette\*/
     Tools::tryError();
     if ($func === 'ftp_connect' || $func === 'ftp_ssl_connect') {
         $this->state = array($name => $args);
         $this->resource = call_user_func_array($func, $args);
         $res = NULL;
     } elseif (!is_resource($this->resource)) {
         /*Nette\*/
         Tools::catchError($msg);
         throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
     } else {
         if ($func === 'ftp_login' || $func === 'ftp_pasv') {
             $this->state[$name] = $args;
         }
         array_unshift($args, $this->resource);
         $res = call_user_func_array($func, $args);
         if ($func === 'ftp_chdir' || $func === 'ftp_cdup') {
             $this->state['chdir'] = array(ftp_pwd($this->resource));
         }
     }
     if (Tools::catchError($msg) && !$silent) {
         throw new FtpException($msg);
     }
     return $res;
 }
开发者ID:vrana,项目名称:nette,代码行数:43,代码来源:Ftp.php

示例2: __call

 public function __call($sMethodName, $aVars)
 {
     if (stristr($sMethodName, 'get')) {
         // we have a getter we return $this
         return new static();
     } elseif (!stristr($sMethodName, 'set')) {
         return parent::__call($sMethodName, $aVars);
     }
     return null;
 }
开发者ID:bogdananton,项目名称:vsc,代码行数:10,代码来源:Base.php

示例3: __call

 /**
  * Shortcut for handling configuration parameters
  */
 public function __call($name, $arguments)
 {
     if (preg_match('/^(?<op>(get)|(set))_(?<arg>.+)$/', $name, $matches)) {
         $field = $matches['arg'];
         Deprecation::notice('3.1', "Call DynamicCache::config()->{$field} directly");
         if ($matches['op'] === 'set') {
             return DynamicCache::config()->{$field} = $arguments[0];
         } else {
             return DynamicCache::config()->{$field};
         }
     }
     return parent::__call($name, $arguments);
 }
开发者ID:tractorcow,项目名称:silverstripe-dynamiccache,代码行数:16,代码来源:DynamicCache.php

示例4: __call

 /**
  * Wildcard method for applying all the possible conditions
  * @param  sting $method The method name
  * @param  array $args The arguments
  * @return  DisplayLogicCriteria
  */
 public function __call($method, $args)
 {
     if (in_array($method, $this->config()->comparisons)) {
         $val = isset($args[0]) ? $args[0] : null;
         if (substr($method, 0, 2) == "is") {
             $operator = substr($method, 2);
         } else {
             $operator = ucwords($method);
         }
         $this->addCriterion(DisplayLogicCriterion::create($this->master, $operator, $val, $this));
         return $this;
     }
     return parent::__call($method, $args);
 }
开发者ID:helpfulrobot,项目名称:unclecheese-display-logic,代码行数:20,代码来源:DisplayLogicCriteria.php

示例5: __call

 /**
  * Magic method to allow getting/setting of properties
  * 
  * @return mixed
  */
 public function __call($method, $arguments)
 {
     $action = substr($method, 0, 3);
     if (in_array($action, array('get', 'set'))) {
         $property = strtolower(substr($method, 3));
         $allowedProperties = array('id', 'test', 'yep', 'nope', 'load', 'callback', 'complete');
         if (in_array($property, $allowedProperties)) {
             if ($action === 'get') {
                 return $this->{$property};
             } else {
                 $this->{$property} = $arguments[0];
                 return null;
             }
         }
     }
     return parent::__call($method, $arguments);
 }
开发者ID:kinglozzer,项目名称:yepnopesilverstripe,代码行数:22,代码来源:YepnopeTestObject.php

示例6: __call

 /**
  * 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->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);
 }
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:21,代码来源:BaseTemplate.php

示例7: __call

 /**
  * Method overloading
  *
  * Supports dynamic methods:
  *  - delete() - deletes current model from the database, returns boolean true
  *    or false. Upon succesfull deletion the exists property is set to false,
  *    and the modified property to true - no data is deleted from the model
  *    though.
  *
  * Ties in the validator methods.
  *
  * Also calls all the mixins (see the Object class).
  * If an unknown method is called, an exception is thrown.
  *
  * @param  string $method
  * @param  string $arguments
  * @return mixed
  */
 public function __call($method, $arguments)
 {
     if ($method === 'delete' && $this->exists === true) {
         $result = $this->connection->delete($this->table, 'id=' . $this->data['id']);
         if ($result !== false) {
             $this->exists = false;
             $this->modified = true;
             $result = true;
         }
         return $result;
     } elseif (substr($method, 0, 9) === 'validate_') {
         if (method_exists('ModelValidator', $method)) {
             array_unshift($arguments, $this);
             return call_user_func_array(array('ModelValidator', $method), $arguments);
         }
     } else {
         return parent::__call($method, $arguments);
     }
 }
开发者ID:brego,项目名称:prank,代码行数:37,代码来源:base.php

示例8: __call

 /**
  * Call to undefined method.
  *
  * @param  string  method name
  * @param  array   arguments
  * @return mixed
  * @throws 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->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);
 }
开发者ID:radypala,项目名称:maga-website,代码行数:26,代码来源:Image.php

示例9: __call

 /**
  * Execute a controller action by it's name.
  *
  * Function is also capable of checking is a behavior has been mixed successfully using is[Behavior]
  * function. If the behavior exists the function will return TRUE, otherwise FALSE.
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @see execute()
  */
 public function __call($method, $args)
 {
     if (!isset($this->_mixed_methods[$method])) {
         //Handle action alias method
         if (in_array($method, $this->getActions())) {
             //Get the data
             $data = !empty($args) ? $args[0] : array();
             //Create a context object
             if (!$data instanceof CommandContextInterface) {
                 $context = $this->getCommandContext();
                 //Store the parameters in the context
                 $context->param = $data;
                 //Automatic set the data in the request if an associative array is passed
                 if (is_array($data) && !is_numeric(key($data))) {
                     $context->request->data->add($data);
                 }
                 $context->result = false;
             } else {
                 $context = $data;
             }
             //Execute the action
             return $this->execute($method, $context);
         }
         //Check if a behavior is mixed
         $parts = StringInflector::explode($method);
         if ($parts[0] == 'is' && isset($parts[1])) {
             if (!isset($this->_mixed_methods[$method])) {
                 return false;
             }
         }
     }
     return parent::__call($method, $args);
 }
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:43,代码来源:abstract.php

示例10: __call

 /**
  * Search the behaviors to see if this table behaves as.
  *
  * Function is also capable of checking is a behavior has been mixed successfully using is[Behavior] function.
  * If the behavior exists the function will return TRUE, otherwise FALSE.
  *
  * @param  string     $method    The function name
  * @param  array      $arguments The function arguments
  * @throws \BadMethodCallException     If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     // If the method is of the form is[Bahavior] handle it.
     $parts = StringInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         if (!$this->hasBehavior(strtolower($parts[1]))) {
             return false;
         }
     }
     return parent::__call($method, $arguments);
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:22,代码来源:abstract.php

示例11: __call

 /**
  * Supports a simple form of Fluent Interfaces. Allows you to assign variables to the view by using the variable
  * name as the method name. If the method name is a setter method the setter will be called instead.
  *
  * For example : $view->data(array('foo' => 'bar'))->title('name')->render()
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @return  ViewAbstract
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     if (!$this->isMixedMethod($method)) {
         //If one argument is passed we assume a setter method is being called
         if (count($args) == 1) {
             if (!method_exists($this, 'set' . ucfirst($method))) {
                 $this->{$method} = $args[0];
                 return $this;
             } else {
                 return $this->{'set' . ucfirst($method)}($args[0]);
             }
         }
         //Check if a behavior is mixed
         $parts = StringInflector::explode($method);
         if ($parts[0] == 'is' && isset($parts[1])) {
             return false;
         }
     }
     return parent::__call($method, $args);
 }
开发者ID:nooku,项目名称:nooku-framework,代码行数:32,代码来源:abstract.php

示例12: array

 /**
  * Handle postTo* methods.
  *
  * @param string $method
  * @param array $arguments
  */
 function __call($method, $arguments)
 {
     if (text($method)->startsWith('get')) {
         // a get*($parameters) method?
         if (empty($this->id)) {
             throw new \Exception('Can\'t fetch a connection without an id');
         }
         if (count($arguments) > 0) {
             $parameters = $arguments[0];
         } else {
             $parameters = array();
         }
         $connection = lcfirst(substr($method, 3));
         $connections = $this->getKnownConnections(array('id' => $this->id));
         if (isset($connections[$connection]['class'])) {
             $class = $connections[$connection]['class'];
         } else {
             $class = '\\Sledgehammer\\GraphObject';
         }
         if (isset($connections[$connection]['permission']) && $connections[$connection]['permission'] !== 'denied' && in_array($connections[$connection]['permission'], Facebook::getInstance()->getPermissions()) === false) {
             notice('Connection "' . $connection . '" requires the "' . $connections[$connection]['permission'] . '" permission', 'Current permissions: ' . quoted_human_implode(' and ', Facebook::getInstance()->getPermissions()));
         }
         $objects = array();
         $response = Facebook::all($this->id . '/' . $connection, $parameters);
         foreach ($response as $data) {
             $objects[] = new $class($data);
         }
         if (empty($arguments['fields'])) {
             foreach ($objects as $object) {
                 $object->_state = 'partial';
             }
         }
         return new Collection($objects);
     }
     if (text($method)->startsWith('postTo')) {
         // a postTo*($data) method?
         if (empty($this->id)) {
             throw new \Exception('Can\'t post to a connection without an id');
         }
         if (count($arguments) > 0) {
             $parameters = $arguments[0];
         } else {
             notice('Missing argument 1 for ' . $method . '()');
             $parameters = array();
         }
         $response = Facebook::post($this->id . '/' . lcfirst(substr($method, 6)), $parameters);
         return new GraphObject($response['id']);
     } else {
         return parent::__call($method, $arguments);
     }
 }
开发者ID:sledgehammer,项目名称:facebook,代码行数:57,代码来源:GraphObject.php

示例13: __call

 /**
  * Implement dynamic getters
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @return  string|false Returns FALSE if the manifest doesn't exist
  */
 public final function __call($method, $args)
 {
     if (count($args) == 0 && substr($method, 0, 2) == 'get') {
         $key = strtolower(substr($method, 3));
         return $this->{$key};
     }
     return parent::__call($method, $args);
 }
开发者ID:nooku,项目名称:nooku-framework,代码行数:15,代码来源:manifest.php

示例14: __call

 /**
  * 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 = call_user_func($loader, $lname);
             if ($helper) {
                 $this->registerHelper($lname, $helper);
                 return call_user_func_array($helper, $args);
             }
         }
         return parent::__call($name, $args);
     }
     return call_user_func_array($this->helpers[$lname], $args);
 }
开发者ID:vrana,项目名称:nette,代码行数:21,代码来源:BaseTemplate.php

示例15: __call

 /**
  * Supports a simple form Fluent Interfaces. Allows you to set states by using the state name as the method name.
  *
  * For example : $model->sort('name')->limit(10)->getRowset();
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @return  ModelAbstract
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     if ($this->getState()->has($method)) {
         $this->getState()->set($method, $args[0]);
         return $this;
     }
     return parent::__call($method, $args);
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:19,代码来源:abstract.php


注:本文中的Object::__call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。