Example #1
0
 /**
  *
  */
 public function __call($method, $params)
 {
     if (!method_exists($this->repository, $method)) {
         throw new RepositoryException("Method {$method} not found on repository");
     }
     if ($this->skipCache === true || config('laravel-database.cache') === false) {
         return call_user_func_array(array($this->repository, $method), $params);
     } else {
         if (empty($this->key)) {
             $this->cacheKey($this->generateKey($method, $params));
         }
         $key = $this->key;
         unset($this->key);
         if ($this->refreshCache) {
             $this->cache->forget($key);
             $this->refreshCache = false;
         }
         if (empty($this->lifetime)) {
             $this->cacheLifetime($this->repository->getModel()->cacheLifetime());
         }
         $lifetime = $this->lifetime;
         unset($this->lifetime);
         return $this->cache->remember($key, $lifetime, function () use($method, $params) {
             return call_user_func_array(array($this->repository, $method), $params);
         });
     }
 }
Example #2
0
 public function addCommandsFromClass($className, $passThrough = null)
 {
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $this->add($command);
     }
 }
Example #3
0
 public function __construct($statement)
 {
     $this->error = $statement->error;
     $this->field_count = $statement->field_count;
     $this->insert_id = $statement->insert_id;
     $this->num_rows = $statement->num_rows;
     if ($this->field_count == 1) {
         $statement->bind_result($res);
         while ($statement->fetch) {
             $this->result = $res;
             break;
         }
         $this->array = array();
     } else {
         $data = $statement->result_metadata();
         $rows = array();
         $fields = array($statement);
         while ($f = $data->fetch_field()) {
             $fields[] =& $rows[$f->name];
         }
         call_user_func_array('mysqli_stmt_bind_result', $fields);
         $statement->fetch();
         $this->array = array();
         foreach ($rows as $key => $value) {
             $this->array[$key] = $value;
         }
         $this->result = '';
     }
 }
Example #4
0
 public function SendMessage($To, $Key, $Pre = null)
 {
     $Args = func_get_args();
     array_shift($Args);
     $Message = call_user_func_array(array(new Lang($this->LangSection), 'Get'), $Args);
     if ($Message !== false) {
         return $this->SendRawMessage($To, (is_array($Pre) && !empty($Pre[0]) ? $Pre[0] : null) . $Message);
     } else {
         if ($Key === 'message:module::not_loaded') {
             return $this->SendRawMessage($To, 'That module doesn\'t exists. Try !help to see a list of available modules');
         } elseif ($Key === 'message:not_admin') {
             return $this->SendRawMessage($To, 'You need admin rights in order to do that');
         } elseif ($Key === 'message:module::not_enabled') {
             return $this->SendRawMessage($To, 'That module is loaded, but is disabled. Ask the admin about it');
         } elseif ($Key === 'message:internal_error') {
             return $this->SendRawMessage($To, 'Internal error');
         } elseif ($Key === 'message:internal_error:wrong_response_code') {
             return $this->SendRawMessage($To, 'Internal error. The code (' . var_export($Pre, true) . ') returned by the module is wrong');
         } elseif ($Key === 'message:module::load_error') {
             return $this->SendRawMessage($To, 'That module is loaded, but there are some troubles (at reload, json-php not readable/lint). If you are the admin, see the logs!');
         } else {
             array_shift($Args);
             return $this->SendLangError($To, $Key, $Args);
         }
     }
 }
Example #5
0
 public function getPrefixes()
 {
     if (!empty($this->prefixesPsr0)) {
         return call_user_func_array('array_merge', $this->prefixesPsr0);
     }
     return array();
 }
 /**
  * @todo Pass around Messages when Status class doesn't suck
  * @param array $msg Message key with parameters
  */
 public function __construct(array $msg)
 {
     $this->msg = $msg;
     // Using ->plain() instead of ->text() due to bug T58226
     $wikitext = call_user_func_array('wfMessage', $msg)->plain();
     parent::__construct($wikitext);
 }
 public function getSingleton()
 {
     if (!isset($this->instance)) {
         $this->instance = call_user_func_array([$this, 'getInstance'], func_get_args());
     }
     return $this->instance;
 }
Example #8
0
 function validate($rules, $obj)
 {
     $fail = array();
     //print_r($rules); print_r($obj);
     foreach ($rules as $k => $v) {
         $m = explode('|', $v);
         //print_r($m);
         //echo $v.' '.$k.' '.$obj->$k."\n";
         foreach ($m as $mk => $mv) {
             //$str=(string)$obj->$k;
             //chek to see if we're anything more complex
             if (preg_match('/\\[(.*?)\\]/', $mv, $matches)) {
                 //print_r($matches);
                 $par = array_merge(array($k, $obj), explode(',', $matches[1]));
                 $func = str_replace($matches[0], '', $mv);
                 $ret = call_user_func_array(array(&$this, 'validate_' . $func), $par);
             } else {
                 $ret = $this->{'validate_' . $mv}($k, $obj);
             }
             if (!$ret) {
                 if ($msg = $this->getCustErr($k)) {
                     $fail[] = $msg;
                 } else {
                     $fail[] = sprintf($this->default_err, $k);
                 }
             }
         }
     }
     return count($fail) > 0 ? $fail : false;
 }
Example #9
0
 public static function __callStatic($method, $args)
 {
     if (!isset(self::$i)) {
         self::$i = new Query();
     }
     return call_user_func_array([self::$i, $method], $args);
 }
 /**
  * Applies operation to data source and returns modified data source.
  *
  * @param $src
  * @param OperationInterface|CustomOperation $operation
  * @return mixed modified data source
  */
 public function process($src, OperationInterface $operation)
 {
     $callable = $operation->getCallback();
     $arguments = array_merge([$src], $operation->getArguments());
     $res = call_user_func_array($callable, $arguments);
     return $res ?: $src;
 }
Example #11
0
 /** @proxy */
 public function __call($method, $arguments)
 {
     if (method_exists($this->mongo, $method)) {
         return call_user_func_array(array($this->mongo, $method), $arguments);
     }
     throw new \BadMethodCallException(sprintf('Method %s does not exist on %s', $method, get_class($this)));
 }
Example #12
0
 /**
  * Handles the request to execute a task.
  *
  * Responsible for parsing the tasks to execute & also any config items that
  * should be passed to the tasks
  */
 public function action_execute()
 {
     if (empty($this->_task)) {
         return $this->action_help();
     }
     $task = $this->_retrieve_task();
     $defaults = $task->get_config_options();
     if (!empty($defaults)) {
         if (Arr::is_assoc($defaults)) {
             $options = array_keys($defaults);
             $options = call_user_func_array(array('CLI', 'options'), $options);
             $config = Arr::merge($defaults, $options);
         } else {
             // Old behavior
             $config = call_user_func_array(array('CLI', 'options'), $defaults);
         }
     } else {
         $config = array();
     }
     // Validate $config
     $validation = Validation::factory($config);
     $validation = $task->build_validation($validation);
     if (!$validation->check()) {
         echo View::factory('minion/error/validation')->set('errors', $validation->errors($task->get_errors_file()));
     } else {
         // Finally, run the task
         echo $task->execute($config);
     }
 }
Example #13
0
 public function __call($func, array $args = [])
 {
     if ($this->lazyLoad() == null) {
         return '';
     }
     return call_user_func_array([$this->lazyLoad(), $func], $args);
 }
Example #14
0
 /**
  * @internal
  *
  * @param Oxygen_Http_Request     $request
  * @param Oxygen_Util_RequestData $requestData
  * @param string                  $className
  * @param string                  $method
  * @param array                   $actionParameters
  *
  * @return Oxygen_Http_Response
  * @throws Oxygen_Exception
  */
 public function handleRaw($request, $requestData, $className, $method, array $actionParameters)
 {
     $reflectionMethod = new ReflectionMethod($className, $method);
     $parameters = $reflectionMethod->getParameters();
     $arguments = array();
     foreach ($parameters as $parameter) {
         if (isset($actionParameters[$parameter->getName()])) {
             $arguments[] = $actionParameters[$parameter->getName()];
         } else {
             if (!$parameter->isOptional()) {
                 throw new Oxygen_Exception(Oxygen_Exception::ACTION_ARGUMENT_NOT_PROVIDED);
             }
             $arguments[] = $parameter->getDefaultValue();
         }
     }
     if (is_subclass_of($className, 'Oxygen_Container_ServiceLocatorAware')) {
         $instance = call_user_func(array($className, 'createFromContainer'), $this->container);
     } else {
         $instance = new $className();
     }
     $result = call_user_func_array(array($instance, $method), $arguments);
     if (is_array($result)) {
         $result = $this->convertResultToResponse($request, $requestData, $result);
     } elseif (!$result instanceof Oxygen_Http_Response) {
         throw new LogicException(sprintf('An action should return array or an instance of Oxygen_Http_Response; %s gotten.', gettype($result)));
     }
     return $result;
 }
Example #15
0
 /**
  * @param string $class_name
  */
 protected function getClass($class_name, $subclass_of = 'Cyan\\Framework\\Controller', array $arguments = [], \Closure $newInstance = null)
 {
     $required_traits = ['Cyan\\Framework\\TraitSingleton'];
     $reflection_class = new ReflectionClass($class_name);
     foreach ($required_traits as $required_trait) {
         if (!in_array($required_trait, $reflection_class->getTraitNames())) {
             throw new TraitException(sprintf('%s class must use %s', $class_name, $required_trait));
         }
     }
     if (!is_subclass_of($class_name, $subclass_of)) {
         throw new TraitException(sprintf('%s class must be a instance of %s', $class_name, $subclass_of));
     }
     if (is_callable($newInstance)) {
         $instance = call_user_func_array($newInstance, $arguments);
     } else {
         $instance = !empty($arguments) ? call_user_func_array([$class_name, 'getInstance'], $arguments) : $class_name::getInstance();
     }
     if ($this->hasContainer('application')) {
         if (!$instance->hasContainer('application')) {
             $instance->setContainer('application', $this->getContainer('application'));
         }
         if (!$instance->hasContainer('factory_plugin')) {
             $instance->setContainer('factory_plugin', $this->getContainer('application')->getContainer('factory_plugin'));
         }
     }
     if (is_callable([$instance, 'initialize']) || method_exists($instance, 'initialize')) {
         $instance->initialize();
     }
     return $instance;
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     echo "<div class=\"col-md-6\">\n                <div class=\"check_datxe\">\n                    <h4>";
     // line 3
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Thông tin vé")), "html", null, true);
     echo "</h4>\n                    <p style=\"font-size: 18px\">";
     // line 4
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Mã vé")), "html", null, true);
     echo ": 12345</p>\n                    <p class=\"hightlight\">Hà Nội - Trong thành phố</p>\n                    <p>";
     // line 6
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Giờ đi")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 7
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Ngày đi")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 8
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Phương tiện")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 9
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Hình thức")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 10
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Trả khách")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 11
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Số lượng")), "html", null, true);
     echo ":</p>\n                    <p>";
     // line 12
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('translate')->getCallable(), array("Hình thức thanh toán")), "html", null, true);
     echo ":</p>\n                    <hr/>\n                    <h3 style=\"float: right\">200.000 VNĐ</h3>\n                    <div style=\"clear: both\"></div>\n                </div>\n            </div>";
 }
Example #17
0
 /**
  * @param $method
  * @param $args
  *
  * @return mixed
  */
 public static function __callStatic($method, $args)
 {
     if (!static::$vioconInstance) {
         static::$vioconInstance = new Container();
     }
     return call_user_func_array(array(static::$vioconInstance, $method), $args);
 }
Example #18
0
 /**
  * @dataProvider providerCodePage
  */
 public function testCodePageNumberToName()
 {
     $args = func_get_args();
     $expectedResult = array_pop($args);
     $result = call_user_func_array(array('PHPExcel_Shared_CodePage', 'NumberToName'), $args);
     $this->assertEquals($expectedResult, $result);
 }
Example #19
0
 public function __construct($config, $transFunc, $transFuncArgs = array())
 {
     $this->config = array('x2_version' => '', 'php_version' => phpversion(), 'GD_support' => function_exists('gd_info') ? 1 : 0, 'db_type' => 'MySQL', 'db_version' => '', 'unique_id' => 'none', 'formId' => '', 'submitButtonId' => '', 'statusId' => '', 'themeUrl' => '', 'titleWrap' => array('<h2>', '</h2>'), 'receiveUpdates' => 1, 'serverInfo' => False, 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'registered' => 0, 'edition' => 'opensource', 'isUpgrade' => False);
     foreach ($config as $key => $value) {
         $this->config[$key] = $value;
     }
     // Is it OS edition?
     $this->os = $config['edition'] == 'opensource' && !$this->config['isUpgrade'];
     // Empty the unique_id field; user will fill it.
     if (!$this->os) {
         if ($this->config['unique_id'] == 'none') {
             $this->config['unique_id'] = '';
         }
     }
     // $this->config['unique_id'] = 'something'; // To test what the form looks like when unique_id is filled
     // Translate all messages for the updates form:
     foreach (array('label', 'message', 'leadSources') as $attr) {
         $attrArr = $this->{$attr};
         foreach (array_keys($this->{$attr}) as $key) {
             $attrArr[$key] = call_user_func_array($transFunc, array_merge($transFuncArgs, array($attrArr[$key])));
         }
         $this->{$attr} = $attrArr;
     }
     $this->message['connectionNOsMessage'] .= ': <a href="http://www.x2crm.com/contact/">x2crm.com</a>.';
 }
Example #20
0
 /**
  * Executes payment via INLINE GoPay payment gate
  *
  * @param Payment $payment
  * @param string $channel
  * @param callable $callback
  * @return RedirectResponse
  * @throws InvalidArgumentException on undefined channel
  * @throws GopayFatalException on maldefined parameters
  * @throws GopayException on failed communication with WS
  */
 public function payInline(Payment $payment, $channel, $callback)
 {
     $paymentSessionId = $this->buildPayment($payment, $channel);
     $response = ["url" => GopayConfig::fullNewIntegrationURL() . '/' . $paymentSessionId, "signature" => $this->createSignature($paymentSessionId)];
     call_user_func_array($callback, [$paymentSessionId]);
     return $response;
 }
 public function sendData(callable $callback)
 {
     $client = new swoole_client(SWOOLE_SOCK_UDP, SWOOLE_SOCK_ASYNC);
     $client->on("connect", function ($cli) {
         $this->isConnect = true;
         $cli->send($this->data);
     });
     $client->on('close', function ($cli) {
         $this->isConnect = false;
     });
     $client->on('error', function ($cli) use($callback) {
         $this->isConnect = false;
         $cli->close();
         call_user_func_array($callback, array('r' => 1, 'key' => $this->key, 'error_msg' => 'conncet error'));
     });
     $client->on("receive", function ($cli, $data) use($callback) {
         $this->isConnect = false;
         $cli->close();
         call_user_func_array($callback, array('r' => 0, 'key' => $this->key, 'data' => $data));
     });
     if ($client->connect($this->ip, $this->port, $this->timeout)) {
         if (intval($this->timeout) > 0) {
             swoole_timer_after(intval($this->timeout) * 1000, function () use($client, $callback) {
                 if ($this->isConnect) {
                     //error_log(__METHOD__." client ===== ".print_r($client,true),3,'/tmp/client.log');
                     $client->close();
                     call_user_func_array($callback, array('r' => 2, 'key' => '', 'error_msg' => 'timeout'));
                 }
             });
         }
     }
 }
 public function block_scripts_header($context, array $blocks = array())
 {
     // line 13
     echo "        <script type=\"text/javascript\" src=\"";
     echo twig_escape_filter($this->env, call_user_func_array($this->env->getFunction('asset')->getCallable(), array("asset/three.js/build/three.js")), "html", null, true);
     echo "\"></script>\n    ";
 }
Example #23
0
 public function __call($func, $args)
 {
     $connectionObj = $this->connections[$this->defaultConnection];
     if (method_exists($connectionObj, $func)) {
         call_user_func_array([$connectionObj, $func], $args);
     }
 }
 public function __call($method, $arguments)
 {
     if ($this->conditionalResult) {
         $this->resultChecker = call_user_func_array(array($this->resultChecker, $method), $arguments);
     }
     return $this;
 }
Example #25
0
 public function __call($name, $arguments)
 {
     if (isset($this->apis[$name]) && is_callable($this->apis[$name])) {
         return call_user_func_array($this->apis[$name], $arguments);
     }
     return null;
 }
Example #26
0
 function apply_filters_ref_array($tag, $args)
 {
     global $wp_filter, $merged_filters, $wp_current_filter;
     // Do 'all' actions first
     if (isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
         $all_args = func_get_args();
         _wp_call_all_hook($all_args);
     }
     if (!isset($wp_filter[$tag])) {
         if (isset($wp_filter['all'])) {
             array_pop($wp_current_filter);
         }
         return $args[0];
     }
     if (!isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
     }
     // Sort
     if (!isset($merged_filters[$tag])) {
         ksort($wp_filter[$tag]);
         $merged_filters[$tag] = true;
     }
     reset($wp_filter[$tag]);
     do {
         foreach ((array) current($wp_filter[$tag]) as $the_) {
             if (!is_null($the_['function'])) {
                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
             }
         }
     } while (next($wp_filter[$tag]) !== false);
     array_pop($wp_current_filter);
     return $args[0];
 }
 protected function doClean($values)
 {
     $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
     $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
     $allowEmail = sfConfig::get('app_sf_guard_plugin_allow_login_with_email', true);
     $method = $allowEmail ? 'retrieveByUsernameOrEmailAddress' : 'retrieveByUsername';
     // don't allow to sign in with an empty username
     if ($username) {
         if ($callable = sfConfig::get('app_sf_guard_plugin_retrieve_by_username_callable')) {
             $user = call_user_func_array($callable, array($username));
         } else {
             $user = $this->getTable()->retrieveByUsername($username);
         }
         // user exists?
         if ($user) {
             // password is ok?
             if ($user->getIsActive() && $user->checkPassword($password)) {
                 return array_merge($values, array('user' => $user));
             }
         }
     }
     if ($this->getOption('throw_global_error')) {
         throw new sfValidatorError($this, 'invalid');
     }
     throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
 }
Example #28
0
 public function success($response)
 {
     $pq = phpQuery::newDocument($response);
     foreach ($this->calls as $k => $r) {
         // check if method exists
         if (!method_exists(get_class($pq), $r['method'])) {
             throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
             // execute method
         } else {
             $pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
         }
     }
     if (!isset($this->options['dataType'])) {
         $this->options['dataType'] = '';
     }
     switch (strtolower($this->options['dataType'])) {
         case 'json':
             if ($pq instanceof PHPQUERYOBJECT) {
                 $results = array();
                 foreach ($pq as $node) {
                     $results[] = pq($node)->htmlOuter();
                 }
                 print phpQuery::toJSON($results);
             } else {
                 print phpQuery::toJSON($pq);
             }
             break;
         default:
             print $pq;
     }
     // output results
 }
Example #29
0
 public function __construct()
 {
     //funkcja parseUrl() znajduje sie ponizej
     $url = $this->parseUrl();
     //////////////////////
     //testowanie postowany danych
     if (!empty($_POST)) {
         $url[1] = 'post';
     }
     /////////////////////////////
     if (!$url == NULL) {
         if (file_exists('../app/controllers/' . $url[0] . '.php')) {
             $this->controller = $url[0];
             unset($url[0]);
         } else {
             $this->controller = 'error';
             unset($url[0]);
         }
     }
     require_once '../app/controllers/' . $this->controller . '.php';
     $this->controller = new $this->controller();
     if (isset($url[1])) {
         if (method_exists($this->controller, $url[1])) {
             $this->method = $url[1];
             unset($url[1]);
         }
     }
     $this->params = $url ? array_values($url) : [];
     call_user_func_array([$this->controller, $this->method], $this->params);
 }
 /**
  * Init the minify class - optionally, code may be passed along already.
  */
 public function __construct()
 {
     // it's possible to add the source through the constructor as well ;)
     if (func_num_args()) {
         call_user_func_array(array($this, 'add'), func_get_args());
     }
 }