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


PHP functions::is_callable方法代码示例

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


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

示例1: execute

 /**
  * render|update|create model model ...
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  * @throws \tf_exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //require('../_tests/loader.php');
     $core = $this->core();
     $this->prepare_db($input->getOption('database'));
     $action = $input->getArgument('action');
     if (empty($action)) {
         throw new \tf_exception("empty action\n");
     }
     $ids = $input->getArgument('models');
     if (empty($ids)) {
         throw new \tf_exception("empty ID\n");
     }
     if ($ids[0] == '*') {
         $ids = Helpers\ModelEnumerator::find();
     }
     /*
      * $action = @$_SERVER['argv'][2] ? : 'render';
        if (in_array('--', $_SERVER['argv'])) {
        }
     */
     $output->writeln('action: ' . $action);
     /** @var collection_generator */
     $generator = \abs_collection::get_generator();
     foreach ($ids as $mid) {
         $_mid = explode('.', trim($mid));
         if (count($_mid) == 1) {
             array_unshift($_mid, 'core');
             $container = core::selfie();
         } else {
             $container = core::module($_mid[0]);
         }
         if (!$container) {
             $output->writeln('skip ' . $mid);
             continue;
         }
         $method = 'get_' . $_mid[1] . '_handle';
         // allow model with params: get_model_handle | model('model')
         $obj = \functions::is_callable(array($container, $method)) ? $container->{$method}() : $container->model($_mid[1]);
         $generator->append_object($obj);
     }
     $output->writeln($generator->render_table_structure(), OutputInterface::OUTPUT_RAW);
     if ($action == 'update') {
         $generator->update_table_structure();
     }
     if ($action == 'create') {
         $generator->update_table_structure(true);
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:56,代码来源:GeneratorCommand.php

示例2: render_virtual

 function render_virtual($method, $type)
 {
     if ($method instanceof Closure) {
         return $method($this, $type);
     }
     $method = 'virtual_' . $method;
     if (!functions::is_callable(array($this, $method))) {
         throw new collection_exception('Virtual method not callable : ' . get_class($this) . '.' . $method);
     }
     return call_user_func(array($this, $method), $type);
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:11,代码来源:item.php

示例3: invoke

 /**
  * Run method on all children
  *
  * $users->invoke('dump');
  * $users->invoke(function($item){$item->dump();});
  *
  * @param mixed $method
  * @param mixed $params
  * @return abs_collection self
  */
 function invoke($method, $params = null)
 {
     $_method = $method;
     if ($this->count()) {
         foreach ($this as $item) {
             if (is_string($_method)) {
                 $method = array($item, $_method);
                 if (functions::is_callable($method)) {
                     call_user_func_array($method, $params);
                 } else {
                     if ($this->_invoke_exception) {
                         throw new Collection_Exception(__METHOD__ . ' not callable: ' . get_class($method[0]) . ':' . $method[1]);
                     }
                 }
             } else {
                 // closure pass selfie first param
                 if ($_method instanceof Closure) {
                     $params = array($item, $params);
                     call_user_func_array($method, $params);
                     // $method(...$params)
                 } else {
                     if ($this->_invoke_exception) {
                         throw new Collection_Exception(__METHOD__ . ' closure not callable');
                     }
                 }
             }
         }
     }
     return $this;
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:40,代码来源:registry.php

示例4: dispatch

 /**
  * Entry point for app
  *
  * @return bool false - not found
  * @throws router_exception
  */
 function dispatch($url = false)
 {
     if ($this->cfg('options.log_requests')) {
         $this->logger->log('request', $url);
     }
     $request = $url ? $url : urldecode($_SERVER['REQUEST_URI']);
     self::event('dispatch_before', array('url' => &$request));
     $skip_site_check = false;
     if (preg_match('@users/(login|logout)/\\z@', $request)) {
         $this->set_cfg_var('in_login', true);
         $skip_site_check = true;
     }
     // returns HTTP_HOST if main_domain not set
     $domain = $_SERVER['HTTP_HOST'];
     //$this->get_main_domain();
     $subdomain = $_SERVER['HTTP_HOST'] != $domain ? substr($_SERVER['HTTP_HOST'], 0, -1 + -1 * strlen($domain)) : false;
     if ('www' === $subdomain) {
         $subdomain = false;
     }
     $this->set_cfg_var('subdomain', $subdomain);
     $cname = false;
     // check for cname
     if ($domain != substr($_SERVER['HTTP_HOST'], -1 * ($sl = strlen($domain)), $sl)) {
         $cname = preg_replace('/^.*\\.([^\\.]+\\.[\\w]+)$/', '$1', $_SERVER['HTTP_HOST']);
         $this->set_cfg_var('cname', $cname);
     }
     // @todo fix tails or errors
     if (false !== ($qpos = strpos($request, '?'))) {
         $request = substr($request, 0, $qpos);
     }
     $dispatcher = self::$modules->get_main();
     if (!$dispatcher) {
         throw new module_exception('Main module not set');
     }
     $this->append_base_url($this->router->get_protocol());
     $this->append_base_url($this->cfg('main_domain'), true);
     if ($dispatcher && functions::is_callable(array($dispatcher, 'predispatch'))) {
         $dispatcher->predispatch($domain, $request);
     }
     /**
      * /domain/module+alias/
      * check path against
      *   - modules list
      *   - alias list
      */
     $request_array = explode('/', $request);
     // remove empty parts
     array_splice($request_array, 0, 1);
     if (empty($request_array[count($request_array) - 1])) {
         array_splice($request_array, -1, 1);
     }
     $request_count = count($request_array);
     // Output filters
     if ($request_count >= 2 && $request_array[$request_count - 2] == 'outfilter') {
         $filter = $request_array[$request_count - 1];
         if (!$this->set_output_filter($filter)) {
             throw new router_exception('Invalid filter - ' . $filter, router_exception::NOT_FOUND);
         }
         array_splice($request_array, -2);
         // @todo slice $request
     }
     $router_module = null;
     if ($this->in_index()) {
         // override frontpage layout
         if ($template = $this->cfg('site.frontpage.template')) {
             $this->renderer->set_page_template($template);
         }
     }
     $root = isset($request_array[0]) ? array_shift($request_array) : false;
     if (!empty($root) && !preg_match('/^[\\w_\\.\\-\\%а-я[:space:]]+$/ui', $root)) {
         throw new router_exception('Root route error');
     }
     if (empty($root)) {
         // use default module as router
         self::$modules->get_main()->set_is_router();
     } else {
         // core module calls
         if ('core' == $root) {
             $this->set_is_router(true);
             $router_module = $this;
         } else {
             if (self::$modules->is_registered($root)) {
                 self::$modules->set_router($root);
             } else {
                 /** @var core_module */
                 $pmod = self::$modules->get_by_alias($root);
                 if ($pmod) {
                     $pmod->set_is_router(true);
                 } else {
                     // default, inject root element
                     array_unshift($request_array, $root);
                     self::$modules->get_main()->set_is_router();
                     // no module found, route to default router (with main flag)
                 }
//.........这里部分代码省略.........
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:101,代码来源:core.php

示例5: run_section

 /**
  * Call section
  * @param $section
  * @param $route
  * @param $params
  */
 function run_section($section, $route, $params)
 {
     $method = "section_{$section}";
     if (functions::is_callable(array($this, $method))) {
         $this->{$method}($route, $params);
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:13,代码来源:module_controller.php


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