本文整理汇总了PHP中call_fuel_func_array函数的典型用法代码示例。如果您正苦于以下问题:PHP call_fuel_func_array函数的具体用法?PHP call_fuel_func_array怎么用?PHP call_fuel_func_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call_fuel_func_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __callStatic
/**
* Static call forwarder
*
* @param string $func method name
* @param array $args passed arguments
* @return
*/
public static function __callStatic($func, $args)
{
$instance = static::instance();
if (method_exists($instance, $func)) {
return call_fuel_func_array(array($instance, $func), $args);
}
throw new \BadMethodCallException('Call to undefined method: ' . get_called_class() . '::' . $func);
}
示例2: run
public static function run($task, $args = array())
{
$task = strtolower($task);
// Make sure something is set
if (empty($task) or $task === 'help') {
static::help();
return;
}
$module = false;
list($module, $task) = array_pad(explode('::', $task), 2, null);
if ($task === null) {
$task = $module;
$module = false;
}
if ($module) {
try {
\Module::load($module);
$path = \Module::exists($module);
\Finder::instance()->add_path($path);
} catch (\FuelException $e) {
throw new Exception(sprintf('Module "%s" does not exist.', $module));
}
}
// Just call and run() or did they have a specific method in mind?
list($task, $method) = array_pad(explode(':', $task), 2, 'run');
// Find the task
if (!($file = \Finder::search('tasks', $task))) {
$files = \Finder::instance()->list_files('tasks');
$possibilities = array();
foreach ($files as $file) {
$possible_task = pathinfo($file, \PATHINFO_FILENAME);
$difference = levenshtein($possible_task, $task);
$possibilities[$difference] = $possible_task;
}
ksort($possibilities);
if ($possibilities and current($possibilities) <= 5) {
throw new Exception(sprintf('Task "%s" does not exist. Did you mean "%s"?', $task, current($possibilities)));
} else {
throw new Exception(sprintf('Task "%s" does not exist.', $task));
}
return;
}
require_once $file;
$task = '\\Fuel\\Tasks\\' . ucfirst($task);
$new_task = new $task();
// The help option has been called, so call help instead
if ((\Cli::option('help') or $method == 'help') and is_callable(array($new_task, 'help'))) {
$method = 'help';
} else {
// if the task has an init method, call it now
is_callable($task . '::_init') and $task::_init();
}
if ($return = call_fuel_func_array(array($new_task, $method), $args)) {
\Cli::write($return);
}
}
示例3: test_debug_dump_by_call_fuel_func_array
public function test_debug_dump_by_call_fuel_func_array()
{
// Set to browser mode.
\Fuel::$is_cli = false;
$expected = '<div class="fuelphp-dump" style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;"><h1 style="border-bottom: 1px solid #CCC; padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 120% sans-serif;">COREPATH/base.php @ line: 462</h1><pre style="overflow:auto;font-size:100%;"><strong>Variable #1:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 1' . "\n\n\n" . '<strong>Variable #2:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 2' . "\n\n\n" . '<strong>Variable #3:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 3' . "\n\n\n" . '</pre></div>';
ob_start();
call_fuel_func_array('\\Debug::dump', array(1, 2, 3));
$output = ob_get_contents();
ob_end_clean();
$this->assertEquals($expected, $output);
}
示例4: __callStatic
/**
* Static access to the default instance
*
* @return mixed
* @throws BadMethodCallException if the request method does not exist
*/
public static function __callStatic($name, $arguments)
{
// old pre-1.4 mapping to new instance methods
static $mapping = array('get' => '__get', 'set' => '__set', 'set_config' => '__set', 'create_links' => 'render', 'page_links' => 'pages_render', 'prev_link' => 'previous', 'next_link' => 'next');
array_key_exists($name, $mapping) and $name = $mapping[$name];
// call the method on the default instance
if ($instance = static::instance() and method_exists($instance, $name)) {
return call_fuel_func_array(array($instance, $name), $arguments);
}
throw new \BadMethodCallException('The pagination class doesn\'t have a method called "' . $name . '"');
}
示例5: router
/**
* router
*
* this router will call action methods for normal requests,
* and REST methods for RESTful calls
*
* @param
* string
* @param
* array
*/
public function router($resource, $arguments)
{
// if this is an ajax call
if ($this->is_restful()) {
// have the Controller_Rest router deal with it
return parent::router($resource, $arguments);
}
// check if a input specific method exists
$controller_method = strtolower(\Input::method()) . '_' . $resource;
// fall back to action_ if no rest method is provided
if (!method_exists($this, $controller_method)) {
$controller_method = 'action_' . $resource;
}
// check if the action method exists
if (method_exists($this, $controller_method)) {
return call_fuel_func_array(array($this, $controller_method), $arguments);
}
// if not, we got ourselfs a genuine 404!
throw new \HttpNotFoundException();
}
示例6: preset
/**
* Exectues the presets set in the config. Additional parameters replace the $1, $2, ect.
*
* @param string $name The name of the preset.
* @return Image_Driver
*/
public function preset($name)
{
$vars = func_get_args();
if (isset($this->config['presets'][$name])) {
$old_config = $this->config;
$this->config = array_merge($this->config, $this->config['presets'][$name]);
foreach ($this->config['actions'] as $action) {
$func = $action[0];
array_shift($action);
for ($i = 0; $i < count($action); $i++) {
for ($x = count($vars) - 1; $x >= 0; $x--) {
$action[$i] = preg_replace('#\\$' . $x . '#', $vars[$x], $action[$i]);
}
}
call_fuel_func_array(array($this, $func), $action);
}
$this->config = $old_config;
} else {
throw new \InvalidArgumentException("Could not load preset {$name}, you sure it exists?");
}
return $this;
}
示例7: run_queue
/**
* Runs all queued actions on the loaded image.
*
* @param boolean $clear Decides if the queue should be cleared once completed.
*/
public function run_queue($clear = null)
{
foreach ($this->queued_actions as $action) {
$tmpfunc = array();
for ($i = 0; $i < count($action); $i++) {
$tmpfunc[$i] = var_export($action[$i], true);
}
$this->debug('', "<b>Executing <code>" . implode(", ", $tmpfunc) . "</code></b>");
call_fuel_func_array(array(&$this, '_' . $action[0]), array_slice($action, 1));
}
if ($clear === null and $this->config['clear_queue'] or $clear === true) {
$this->queued_actions = array();
}
}
示例8: benchmark
/**
* Benchmark anything that is callable
*
* @access public
* @static
*
*/
public static function benchmark($callable, array $params = array())
{
// get the before-benchmark time
if (function_exists('getrusage')) {
$dat = getrusage();
$utime_before = $dat['ru_utime.tv_sec'] + round($dat['ru_utime.tv_usec'] / 1000000, 4);
$stime_before = $dat['ru_stime.tv_sec'] + round($dat['ru_stime.tv_usec'] / 1000000, 4);
} else {
list($usec, $sec) = explode(" ", microtime());
$utime_before = (double) $usec + (double) $sec;
$stime_before = 0;
}
// call the function to be benchmarked
$result = is_callable($callable) ? call_fuel_func_array($callable, $params) : null;
// get the after-benchmark time
if (function_exists('getrusage')) {
$dat = getrusage();
$utime_after = $dat['ru_utime.tv_sec'] + round($dat['ru_utime.tv_usec'] / 1000000, 4);
$stime_after = $dat['ru_stime.tv_sec'] + round($dat['ru_stime.tv_usec'] / 1000000, 4);
} else {
list($usec, $sec) = explode(" ", microtime());
$utime_after = (double) $usec + (double) $sec;
$stime_after = 0;
}
return array('user' => sprintf('%1.6f', $utime_after - $utime_before), 'system' => sprintf('%1.6f', $stime_after - $stime_before), 'result' => $result);
}
示例9: output
public function output($filetype = null)
{
$this->gdresizefunc = $filetype == 'gif' ? 'imagecopyresized' : ($this->gdresizefunc = 'imagecopyresampled');
extract(parent::output($filetype));
$this->run_queue();
$this->add_background();
$vars = array($this->image_data, null);
if ($filetype == 'jpg' || $filetype == 'jpeg') {
$vars[] = $this->config['quality'];
$filetype = 'jpeg';
} elseif ($filetype == 'png') {
$vars[] = floor($this->config['quality'] / 100 * 9);
}
call_fuel_func_array('image' . $filetype, $vars);
if ($this->config['persistence'] === false) {
$this->reload();
}
return $this;
}
示例10: having
/**
* Alias of and_having()
*
* @param mixed $column
* column name or array($column, $alias) or object
* @param string $op
* logic operator
* @param mixed $value
* column value
*
* @return $this
*/
public function having($column, $op = null, $value = null)
{
return call_fuel_func_array(array($this, 'and_having'), func_get_args());
}
示例11: where
/**
* Alias of and_where()
*
* @return $this
*/
public function where()
{
return call_fuel_func_array(array($this, 'and_where'), func_get_args());
}
示例12: init
public static function init($args)
{
\Config::load('oil', true);
// Remove flag options from the main argument list
$args = self::_clear_args($args);
try {
if (!isset($args[1])) {
if (\Cli::option('v', \Cli::option('version'))) {
\Cli::write('Fuel: ' . \Fuel::VERSION . ' running in "' . \Fuel::$env . '" mode');
return;
}
static::help();
return;
}
switch ($args[1]) {
case 'g':
case 'generate':
$action = isset($args[2]) ? $args[2] : 'help';
$subfolder = 'orm';
if (is_int(strpos($action, '/'))) {
list($action, $subfolder) = explode('/', $action);
}
switch ($action) {
case 'config':
case 'controller':
case 'model':
case 'module':
case 'migration':
case 'task':
case 'package':
call_user_func('Oil\\Generate::' . $action, array_slice($args, 3));
break;
case 'views':
call_user_func('Oil\\Generate::views', array_slice($args, 3), $subfolder);
break;
case 'admin':
call_user_func('Oil\\Generate_Admin::forge', array_slice($args, 3), $subfolder);
break;
case 'scaffold':
call_user_func('Oil\\Generate_Scaffold::forge', array_slice($args, 3), $subfolder);
break;
default:
Generate::help();
}
break;
case 'c':
case 'console':
if (isset($args[2]) and $args[2] == 'help') {
Console::help();
} else {
new Console();
}
break;
case 'p':
case 'package':
$action = isset($args[2]) ? $args[2] : 'help';
switch ($action) {
case 'install':
case 'uninstall':
call_fuel_func_array('Oil\\Package::' . $action, array_slice($args, 3));
break;
default:
Package::help();
}
break;
case 'r':
case 'refine':
$task = isset($args[2]) ? $args[2] : null;
call_user_func('Oil\\Refine::run', $task, array_slice($args, 3));
break;
case 'cell':
case 'cells':
$action = isset($args[2]) ? $args[2] : 'help';
switch ($action) {
case 'list':
call_user_func('Oil\\Cell::all');
break;
case 'search':
case 'install':
case 'upgrade':
case 'uninstall':
call_fuel_func_array('Oil\\Cell::' . $action, array_slice($args, 3));
break;
case 'info':
case 'details':
call_fuel_func_array('Oil\\Cell::info', array_slice($args, 3));
break;
default:
Cell::help();
}
break;
case 't':
case 'test':
if (isset($args[2]) and $args[2] == 'help') {
$output = <<<HELP
Usage:
php oil [t|test]
Runtime options:
//.........这里部分代码省略.........
示例13: set_fields
/**
* Set a Model's properties as fields on a Fieldset, which will be created with the Model's
* classname if none is provided.
*
* @param string
* @param \Fieldset|null
* @return \Fieldset
*/
public static function set_fields($obj, $fieldset = null)
{
static $_generated = array();
static $_tabular_rows = array();
$class = is_object($obj) ? get_class($obj) : $obj;
if (is_null($fieldset)) {
$fieldset = \Fieldset::instance($class);
if (!$fieldset) {
$fieldset = \Fieldset::forge($class);
}
}
// is our parent fieldset a tabular form set?
$tabular_form = is_object($fieldset->parent()) ? $fieldset->parent()->get_tabular_form() : false;
// don't cache tabular form fieldsets
if (!$tabular_form) {
!array_key_exists($class, $_generated) and $_generated[$class] = array();
if (in_array($fieldset, $_generated[$class], true)) {
return $fieldset;
}
$_generated[$class][] = $fieldset;
}
$primary_keys = is_object($obj) ? $obj->primary_key() : $class::primary_key();
$primary_key = count($primary_keys) === 1 ? reset($primary_keys) : false;
$properties = is_object($obj) ? $obj->properties() : $class::properties();
if ($tabular_form and $primary_key and !is_object($obj)) {
isset($_tabular_rows[$class]) or $_tabular_rows[$class] = 0;
}
foreach ($properties as $p => $settings) {
if (\Arr::get($settings, 'skip', in_array($p, $primary_keys))) {
continue;
}
if (isset($settings['form']['options'])) {
foreach ($settings['form']['options'] as $key => $value) {
is_array($value) or $settings['form']['options'][$key] = \Lang::get($value, array(), false) ?: $value;
}
}
// field attributes can be passed in form key
$attributes = isset($settings['form']) ? $settings['form'] : array();
// label is either set in property setting, as part of form attributes or defaults to fieldname
$label = isset($settings['label']) ? $settings['label'] : (isset($attributes['label']) ? $attributes['label'] : $p);
$label = \Lang::get($label, array(), false) ?: $label;
// change the fieldname and label for tabular form fieldset children
if ($tabular_form and $primary_key) {
if (is_object($obj)) {
$p = $tabular_form . '[' . $obj->{$primary_key} . '][' . $p . ']';
} else {
$p = $tabular_form . '_new[' . $_tabular_rows[$class] . '][' . $p . ']';
}
$label = '';
}
// create the field and add validation rules
$field = $fieldset->add($p, $label, $attributes);
if (!empty($settings['validation'])) {
foreach ($settings['validation'] as $rule => $args) {
if (is_int($rule) and is_string($args)) {
$args = array($args);
} else {
array_unshift($args, $rule);
}
call_fuel_func_array(array($field, 'add_rule'), $args);
}
}
}
// increase the row counter for tabular row fieldsets
if ($tabular_form and $primary_key and !is_object($obj)) {
$_tabular_rows[$class]++;
}
return $fieldset;
}
示例14: multisort
/**
* Sorts an array on multitiple values, with deep sorting support.
*
* @param array $array
* collection of arrays/objects to sort
* @param array $conditions
* sorting conditions
* @param
* bool @ignore_case wether to sort case insensitive
*/
public static function multisort($array, $conditions, $ignore_case = false)
{
$temp = array();
$keys = array_keys($conditions);
foreach ($keys as $key) {
$temp[$key] = static::pluck($array, $key, true);
is_array($conditions[$key]) or $conditions[$key] = array($conditions[$key]);
}
$args = array();
foreach ($keys as $key) {
$args[] = $ignore_case ? array_map('strtolower', $temp[$key]) : $temp[$key];
foreach ($conditions[$key] as $flag) {
$args[] = $flag;
}
}
$args[] =& $array;
call_fuel_func_array('array_multisort', $args);
return $array;
}
示例15: execute
/**
* This executes the request and sets the output to be used later.
*
* Usage:
*
* $request = Request::forge('hello/world')->execute();
*
* @param array|null $method_params An array of parameters to pass to the method being executed
* @return Request This request object
*/
public function execute($method_params = null)
{
// fire any request started events
\Event::instance()->has_events('request_started') and \Event::instance()->trigger('request_started', '', 'none');
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ': Start of ' . $this->uri->get());
}
logger(\Fuel::L_INFO, 'Called', __METHOD__);
// Make the current request active
static::$active = $this;
// First request called is also the main request
if (!static::$main) {
logger(\Fuel::L_INFO, 'Setting main Request', __METHOD__);
static::$main = $this;
}
if (!$this->route) {
static::reset_request();
throw new \HttpNotFoundException();
}
// save the current language so we can restore it after the call
$current_language = \Config::get('language', 'en');
try {
if ($this->route->callable !== null) {
$response = call_fuel_func_array($this->route->callable, array($this));
if (!$response instanceof Response) {
$response = new \Response($response);
}
} else {
$method_prefix = $this->method . '_';
$class = $this->controller;
// Allow override of method params from execute
if (is_array($method_params)) {
$this->method_params = array_merge($this->method_params, $method_params);
}
// If the class doesn't exist then 404
if (!class_exists($class)) {
throw new \HttpNotFoundException();
}
// Load the controller using reflection
$class = new \ReflectionClass($class);
if ($class->isAbstract()) {
throw new \HttpNotFoundException();
}
// Create a new instance of the controller
$this->controller_instance = $class->newInstance($this);
$this->action = $this->action ?: ($class->hasProperty('default_action') ? $class->getProperty('default_action')->getValue($this->controller_instance) : 'index');
$method = $method_prefix . $this->action;
// Allow to do in controller routing if method router(action, params) exists
if ($class->hasMethod('router')) {
$method = 'router';
$this->method_params = array($this->action, $this->method_params);
}
if (!$class->hasMethod($method)) {
// If they call user, go to $this->post_user();
$method = strtolower(\Input::method()) . '_' . $this->action;
// Fall back to action_ if no HTTP request method based method exists
if (!$class->hasMethod($method)) {
$method = 'action_' . $this->action;
}
}
if ($class->hasMethod($method)) {
$action = $class->getMethod($method);
if (!$action->isPublic()) {
throw new \HttpNotFoundException();
}
if (count($this->method_params) < $action->getNumberOfRequiredParameters()) {
throw new \HttpNotFoundException();
}
// fire any controller started events
\Event::instance()->has_events('controller_started') and \Event::instance()->trigger('controller_started', '', 'none');
$class->hasMethod('before') and $class->getMethod('before')->invoke($this->controller_instance);
$response = $action->invokeArgs($this->controller_instance, $this->method_params);
$class->hasMethod('after') and $response = $class->getMethod('after')->invoke($this->controller_instance, $response);
// fire any controller finished events
\Event::instance()->has_events('controller_finished') and \Event::instance()->trigger('controller_finished', '', 'none');
} else {
throw new \HttpNotFoundException();
}
}
// restore the language setting
\Config::set('language', $current_language);
} catch (\Exception $e) {
static::reset_request();
// restore the language setting
\Config::set('language', $current_language);
throw $e;
}
// Get the controller's output
if ($response instanceof Response) {
$this->response = $response;
//.........这里部分代码省略.........