@param array ...$args

@return null|\wulaphp\mvc\view\View
@throws \Exception
325883
public final function index(...$args) {
        $len = count($args);
        switch ($len) {
            case 0:
                return null;
            case 1:
                $subname = array_shift($args);
                $action  = 'index';
                break;
            default:
                $subname = array_shift($args);
                $fParam  = $action = array_shift($args);
        }
        if (empty($subname) || empty($action)) {
            return null;
        }
        $module = $this->module->getDirname();
        $app    = DefaultDispatcher::findApp($module, $action, $args, $this->module->getNamespace(), $subname);
        if ($app) {
            list ($controllerClz, $action, $pms, , $controllerSlag, $actionSlag) = $app;
            if (in_array($action, ['beforerun', 'afterrun', 'geturlprefix'])) {
                return null;
            }
            try {
                $clz = new $controllerClz ($this->module);

                if ($clz instanceof Controller && $clz->slag == $controllerSlag) {
                    $rqMethod = strtolower($_SERVER ['REQUEST_METHOD']);
                    $rm       = ucfirst($rqMethod);
                    // 存在index_get,index_post,add_get add_post这新的方法.
                    $md          = $action . $rm;
                    $actionFound = false;
                    if (method_exists($clz, $md)) {
                        $action      = $md;
                        $actionSlag  = $actionSlag . '-' . $rqMethod;
                        $actionFound = true;
                    } else if (!method_exists($clz, $action)) {
                        array_unshift($pms, $actionSlag);
                        $action     = 'index';
                        $actionSlag = 'index';
                    }
                    if (!$actionFound) {
                        $md = $action . $rm;
                        if (method_exists($clz, $md)) {
                            $action      = $md;
                            $actionSlag  = $actionSlag . '-' . $rqMethod;
                            $actionFound = true;
                        } else if (method_exists($clz, $action)) {
                            $actionFound = true;
                        }
                    }
                    if ($actionFound) {
                        $ref        = $clz->reflectionObj;
                        $method     = $ref->getMethod($action);
                        $methodSlag = Router::addSlash($method->getName());
                        if (!$method->isPublic() || $methodSlag != $actionSlag) {
                            return null;
                        }
                        /* @var \ReflectionParameter[] $params */
                        $params      = $method->getParameters();
                        $paramsCount = count($params);
                        if ($paramsCount < count($pms)) {
                            return null;
                        }
                        $rtn = $clz->beforeRun($action, $method);

                        $module .= '/' . $subname;
                        //beforeRun可以返回view了
                        if ($rtn instanceof View) {
                            DefaultDispatcher::prepareView($rtn, $module, $clz, $action);

                            return $rtn;
                        }
                        $args = [];

                        if ($paramsCount) {
                            $idx = 0;
                            foreach ($params as $p) {
                                $name    = $p->getName();
                                $def     = isset ($pms [ $idx ]) ? $pms [ $idx ] : ($p->isDefaultValueAvailable() ? $p->getDefaultValue() : null);
                                $value   = rqst($name, $def, true);
                                $args [] = is_array($value) ? array_map(function ($v) {
                                    return is_array($v) ? $v : urldecode($v);
                                }, $value) : urldecode($value);
                                $idx++;
                            }
                        }
                        $view = $clz->{$action}(...$args);
                        if ($view !== null) {
                            if (is_array($view)) {
                                $view = new JsonView($view);
                            } else if (!$view instanceof View) {
                                $view = new SimpleView($view);
                            } else {
                                DefaultDispatcher::prepareView($view, $module, $clz, $action);
                            }
                        }

                        return $clz->afterRun($action, $view, $method);
                    }
                }
            } catch (\Exception $e) {
                if (DEBUG == DEBUG_DEBUG) {
                    throw $e;
                }
            }
        }

        //通过插件扩展路由
        $ns = 'router:' . $this->module->getNamespace() . '/' . $subname;
        if (isset($fParam)) {
            array_unshift($args, $fParam);
        }

        return apply_filter($ns, null, $args);
    }
610879
public function get(...$args)
    {
        $record = $this->fetchSingle($args);
        if (!$record)
            return null;
        $obj = new $this->model_class;
        $obj->assignRecord($record, $this->db);
        return $obj;
    }
111709
public function remove($args)
    {
        $result = null;
        $this->allowRemove = true;
        if (isset($this->events[ self::EVENT_ON_BEFORE_REMOVE ])) {

            $this->secureEval($this->events[ self::EVENT_ON_BEFORE_REMOVE ], array(
                'args'   => &$args,
                'method' => 'remove'
            ));
        }
        if ($this->allowRemove) {
            $result = $this->getDriver()->remove($args);
        }
        if (isset($this->events[ self::EVENT_ON_AFTER_REMOVE ])) {
            $this->secureEval($this->events[ self::EVENT_ON_AFTER_REMOVE ], array(
                'args' => &$args

            ));
        }
        return $result;
    }
854228
public function cannot($args = null)
    {
        $args = is_array($args) ? $args : func_get_args();
        return call_user_func_array([$this->getCurrentAuthority(), 'cannot'], $args);
    }
1087440
public function checkModelName(array $args)
    {
        $arg1 = self::getExprAttr($args[0], 'value', 'value');
        if ($arg1 && is_string($arg1)) {
            $model = ['path' => null, 'name' => $arg1];
            if ($pos = strrpos($arg1, '/')) {
                $model['path'] = substr($arg1, 0, $pos);
                $model['name'] = substr($arg1, $pos + 1);
            }
            $this->model_names[] = $model;
            return $model;
        }
    }
602351
public function run($args)
	{
		if(!isset($args[0]))
		{
			echo "Error: module ID is required.\n";
			echo $this->getHelp();
			return 1;
		}

		$moduleID=$args[0];
		$moduleClass=ucfirst($moduleID).'Module';
		$modulePath=Yii::app()->getModulePath().DIRECTORY_SEPARATOR.$moduleID;

		$sourceDir=$this->templatePath===null?YII_PATH.'/cli/views/shell/module':$this->templatePath;
		$list=$this->buildFileList($sourceDir,$modulePath);
		$list['module.php']['target']=$modulePath.DIRECTORY_SEPARATOR.$moduleClass.'.php';
		$list['module.php']['callback']=array($this,'generateModuleClass');
		$list['module.php']['params']=array(
			'moduleClass'=>$moduleClass,
			'moduleID'=>$moduleID,
		);
		$list[$moduleClass.'.php']=$list['module.php'];
		unset($list['module.php']);

		$this->copyFiles($list);

		echo <<<EOD

Module '{$moduleID}' has been created under the following folder:
    $modulePath

You may access it in the browser using the following URL:
    http://hostname/path/to/index.php?r=$moduleID

Note, the module needs to be installed first by adding '{$moduleID}'
to the 'modules' property in the application configuration.

EOD;
	}
991027
public function customizeViewArguments($args, $view)
    {
        if ('view' == $view) {
            $session = $this->get('session');

            /** @var \MauticPlugin\MauticContactSourceBundle\Entity\ContactSource $item */
            $item = $args['viewParameters']['item'];

            // For line graphs in the view
            if ('POST' == $this->request->getMethod() && $this->request->request->has('sourcechartfilter')) {
                $chartFilterValues = $this->request->get('sourcechartfilter');
            } else {
                $chartFilterValues = $session->get('mautic.contactsource.'.$item->getId().'.sourcechartfilter')
                    ? $session->get('mautic.contactsource.'.$item->getId().'.sourcechartfilter')
                    : [
                        'date_from' => $this->get('mautic.helper.core_parameters')->getParameter('default_daterange_filter', 'midnight -1 month'),
                        'date_to'   => 'midnight tomorrow -1 second',
                        'type'      => '',
                    ];
            }

            if ($this->request->query->has('campaign')) {
                $chartFilterValues['campaign'] = $this->request->query->get('campaign');
            }
            if (!isset($chartFilterValues['campaign']) || empty($chartFilterValues['campaign'])) {
                $chartFilterValues['campaign'] = null;
            }

            $session->set('mautic.contactsource.'.$item->getId().'.sourcechartfilter', $chartFilterValues);

            $chartFilterForm = $this->get('form.factory')->create(
                'sourcechartfilter',
                $chartFilterValues,
                [
                    'action' => $this->generateUrl(
                        'mautic_contactsource_action',
                        [
                            'objectAction' => 'view',
                            'objectId'     => $item->getId(),
                        ]
                    ),
                ]
            );

            /** @var \MauticPlugin\MauticContactSourceBundle\Model\ContactSourceModel $model */
            $model = $this->getModel('contactsource');

            // fix dates
            $dateFrom = new \DateTime($chartFilterValues['date_from']);
            $dateTo   = new \DateTime($chartFilterValues['date_to']);

            if (in_array($chartFilterValues['type'], ['All Events', null, ''])) {
                $stats = $model->getStats(
                    $item,
                    null,
                    $dateFrom,
                    $dateTo,
                    $chartFilterValues['campaign']
                );
            } else {
                $stats = $model->getStatsByCampaign(
                    $item,
                    null,
                    $chartFilterValues['type'],
                    $dateFrom,
                    $dateTo,
                    $chartFilterValues['campaign']
                );
            }
            $limits = [];
            try {
                $limits = $model->evaluateAllCampaignLimits($item);
            } catch (\Exception $e) {
            }

            $args['viewParameters']['auditlog']        = $this->getAuditlogs($item);
            $args['viewParameters']['stats']           = $stats;
            $args['viewParameters']['chartFilterForm'] = $chartFilterForm->createView();
            $args['viewParameters']['limits']          = $limits;
        }

        return $args;
    }
1201490
protected function getCanCreateContext($args)
    {
        // Inspect second parameter to canCreate for a 'Parent' context
        if (isset($args[1]['Parent'])) {
            return $args[1]['Parent'];
        }
        // Hack in currently edited page if context is missing
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
            return Controller::curr()->currentPage();
        }

        // No page being edited
        return null;
    }
1364358
public function action($m, $type, $args = [])
    {
        if (!is_array($args)) {
            throw new Exception([
                '$args must be an array',
                'args' => $args,
            ]);
        }

        $q = $this->initQuery($m);
        switch ($type) {
            case 'insert':
                return $q->mode('insert');
                // cannot apply conditions now

            case 'update':
                $q->mode('update');
                break;

            case 'delete':
                $q->mode('delete');
                $this->initQueryConditions($m, $q);
                $m->hook('initSelectQuery', [$q, $type]);

                return $q;

            case 'select':
                $this->initQueryFields($m, $q, isset($args[0]) ? $args[0] : null);
                break;

            case 'count':
                $this->initQueryConditions($m, $q);
                $m->hook('initSelectQuery', [$q]);
                if (isset($args['alias'])) {
                    $q->reset('field')->field('count(*)', $args['alias']);
                } else {
                    $q->reset('field')->field('count(*)');
                }

                return $q;

            case 'field':
                if (!isset($args[0])) {
                    throw new Exception([
                        'This action requires one argument with field name',
                        'action' => $type,
                    ]);
                }

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];
                $m->hook('initSelectQuery', [$q, $type]);
                if (isset($args['alias'])) {
                    $q->reset('field')->field($field, $args['alias']);
                } elseif ($field instanceof Field_SQL_Expression) {
                    $q->reset('field')->field($field, $field->short_name);
                } else {
                    $q->reset('field')->field($field);
                }
                $this->initQueryConditions($m, $q);
                $this->setLimitOrder($m, $q);

                return $q;

            case 'fx':
            case 'fx0':
                if (!isset($args[0], $args[1])) {
                    throw new Exception([
                        'fx action needs 2 arguments, eg: ["sum", "amount"]',
                        'action' => $type,
                    ]);
                }

                $fx = $args[0];
                $field = is_string($args[1]) ? $m->getField($args[1]) : $args[1];
                $this->initQueryConditions($m, $q);
                $m->hook('initSelectQuery', [$q, $type]);

                if ($type == 'fx') {
                    $expr = "$fx([])";
                } else {
                    $expr = "coalesce($fx([]), 0)";
                }

                if (isset($args['alias'])) {
                    $q->reset('field')->field($q->expr($expr, [$field]), $args['alias']);
                } elseif ($field instanceof Field_SQL_Expression) {
                    $q->reset('field')->field($q->expr($expr, [$field]), $fx.'_'.$field->short_name);
                } else {
                    $q->reset('field')->field($q->expr($expr, [$field]));
                }

                return $q;

            default:
                throw new Exception([
                    'Unsupported action mode',
                    'type' => $type,
                ]);
        }

        $this->initQueryConditions($m, $q);
        $this->setLimitOrder($m, $q);
        $m->hook('initSelectQuery', [$q, $type]);

        return $q;
    }
1347574
public function call($args = [])
    {
        if (count($args) == 0 || empty($args[2]))
            throw new NoticeException('Command "'.$this->key.'": Expecting an object to resigter (widget|type).');

        $object = explode(':', $args[2]);

        switch ($object[0]) {
            case 'widget':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a widget class name.');
                $this->registerWidget($object[1], $args);
                break;
            case 'type':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a post type. I.e. "ayuco register type:book" (where "book" would be the type)');
                // Prepare
                $model = !isset($args[3]) || empty($args[3]) ? ucfirst($object[1]) : $args[3];
                $controller = !isset($args[4]) || empty($args[4]) ? null : $args[4];
                // Create controller
                $this->createModel($model);
                // Set properties
                $this->createModelProperty($model, 'type', $object[1]);
                $this->createModelProperty($model, 'aliases', []);
                if ($controller) {
                    $this->createModelProperty($model, 'registry_controller', $controller);
                    $this->createModelProperty($model, 'registry_metabox', ['title'=>'Meta fields','context'=>'normal','priority'=>'default']);
                    // Create controller
                    $this->createModelController($controller);
                    $this->createControllerProperty($controller, 'model', $this->config['namespace'].'\\Models\\'.$model);
                    // Create view
                    $this->createView('admin.metaboxes.'.$object[1].'.meta', 'metabox.php');
                }
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_model', [$model]));
                $builder->build();
                break;
            case 'model':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting a model name.');
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_model', [$object[1]]));
                $builder->build();
                // Print end
                $this->_print('Model registered!');
                $this->_lineBreak();
                break;
            case 'asset':
                if (!isset($object[1]) || empty($object[1]))
                    throw new NoticeException('Command "'.$this->key.'": Expecting an asset relative path.');
                // Register model at bridge
                $builder = Builder::parser($this->rootPath.'/app/Main.php');
                $builder->addVisitor(new AddMethodCallVisitor('init', 'add_asset', [$object[1]]));
                $builder->build();
                // Print end
                $this->_print('Asset registered!');
                $this->_lineBreak();
                break;
        }
    }
28473
public function make($view, array $data = [])
    {
        $location = $this->finder->find($view);

        if ( ! $location) {
            throw new \Exception(sprintf('View `%s` cannot be found!', $view));
        }

        return new View($location, $view, $data);
    }
1298412
public function update( array $args ) {

		$wp = $args ? reset( $args ) : NULL;

		if ( ! $wp instanceof \WP ) {
			return new NullLog();
		}

		$error = [];
		isset( $wp->query_vars[ 'error' ] ) and $error[] = $wp->query_vars[ 'error' ];
		is_404() and $error[] = '404 Page not found';

		if ( empty( $error ) ) {
			return new NullLog();
		}

		$url     = filter_var( add_query_arg( [] ), FILTER_SANITIZE_URL );
		$message = "Error on frontend request for url {$url}.";
		$context = [
			'error'        => $error,
			'query_vars'   => $wp->query_vars,
			'matched_rule' => $wp->matched_rule,
		];

		return new Debug( $message, Channels::HTTP, $context );
	}
722812
protected function parseArguments(array $args)
    {
        if (count($args) === 1 && is_array($args[0])) {
            $args = $args[0];
        }

        if (count($args) === 0) {
            throw new QueryException('No arguments given');
        }

        return $args;
    }
693053
public function update( array $args ) {

		if ( self::$ran ) {
			return new NullLog();
		}

		if ( $this->is_cron() || $this->is_cli() ) {
			$this->register_event_listener();
		}

		return new NullLog();
	}
216094
private function collection($args = null) {

        static $data = [];


        if(isset($args[1])) {
            
            if(preg_match('/(.*)\[(.*)\]/', $args[0], $matches)) {

                $data[$matches[1]][$matches[2]] = $args[1];

            } else {

                $data[$args[0]] = $args[1];

                return $args[1];
            }
        }

        return $data;
    }
587903
public function afterFetch(Array &$args) {
        $model = $args[0];
        $results = $args[1];
        $table = $model->getName();
        $chartService = new Garp_Service_Google_Chart();
        $ini = Garp_Config_Ini::getCached(APPLICATION_PATH.'/configs/routes.ini');
        $routes = $ini->routes->toArray();
        $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');

        $routeFound = false;
        foreach ($routes as $r) {
            if (
                array_key_exists('route', $r) &&
                $r['route'] === '/'.$table.'/:slug'
            ) {
                $routeFound = $r;
                break;
            }
        }

        if (!$routeFound) {
            throw new Exception('There is no direct route to this object.');
        }

        // provide uniform interface, so we can always loop
        if (!$results instanceof Garp_Db_Table_Rowset) {
            $results = array($results);
        }

        foreach ($results as $row) {
            if (
                isset($row->slug) &&
                $row->slug
            ) {
                $refUrl = $view->fullUrl('/'.$table.'/'.$row->slug);
                $row->setVirtual('qrcode', $chartService->fetchQRCodeUrl($refUrl));
            }
        }

        // return the pointer to 0
        if ($results instanceof Garp_Db_Table_Rowset) {
            $results->rewind();
        } else {
        // also, return results to the original format if it was no Rowset to begin with.
            $results = $results[0];
        }
    }
1027858
public static function init($args=null) {
    if(is_null(self::$instance)) {
      self::$instance = new ErrorClass($args);
    }
    return self::$instance;
  }