} if (method_exists($this, $method)) { $this->beginCall($originMethod, $arguments); $return = call_user_func_array([$this, $method], $arguments); $this->endCall($originMethod, $arguments); return $return; } else { throw new InvalidCallException('fecshop service method is not exit. '.get_class($this)."::$method"); } } /** * 得到services 里面配置的子服务childService的实例. */ public function getChildService($childServiceName) { //var_dump($this->childService['xunSearch']);exit;
</font> <?php else: ?> <font class="final_price"> <b> <?= $price_info['price']['symbol'] ?> <span> <?= Yii::$service->helper->format->number_format($price_info['price']['value']) ?> </span> </b> </font> <?php endif; ?>
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require $_file_; return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
$viewFile = $this->getViewFile($view); if (!isset($config['class']) || empty($config['class'])) { if ($parentThis) { $params['parentThis'] = $parentThis; } return Yii::$app->view->renderFile($viewFile, $params); } if (isset($config['method']) && !empty($config['method'])) { $method = $config['method']; unset($config['method']); } else { $method = $this->defaultObMethod;
throw new InvalidConfigException($config['class'].' must implete fecshop\interfaces\block\BlockCache when you use block cache .'); } } } // 查看 $config['class'] 是否在YiiRewriteMap重写中存在配置,如果存在,则替换 !isset($config['class']) || $config['class'] = Yii::mapGetClassName($config['class']); $content = $this->renderContentHtml($configKey, $config, $parentThis); return $content; } /** * find theme file by mutil theme ,if not find view file and $throwError=true, it will throw InvalidValueException.
} else { throw new InvalidValueException(" config key: '$configKey', can not find in ".'Yii::$service->page->widget->widgetConfig'.', you must config it before use it.'); } } return $this->renderContent($configKey, $config, $parentThis); } /** * @param configKey String or Array * 如果传递的是一个配置数组,内容格式如下: * [ * # class 选填
<input type="hidden" class="product_csrf" name="" value="" /> <div class="pro_des" > <div class="des_name"> <h1><?= $name; ?></h1> </div> <div class="des_price"> <?= Yii::$service->page->translate->__('Price'); ?>:<?= Yii::$service->page->widget->render('product/price', ['price_info' => $price_info]); ?><br /> <?= Yii::$service->page->translate->__('Sku'); ?>:<span><?= $sku; ?></span> </div> <div class="product_options"> <?= Yii::$service->page->widget->render('product/options', ['options' => $options]); ?> </div>
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require $_file_; return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* 1.get exist view file from mutil theme by theme protity. * 2.get content by yii view compontent function renderFile() , */ public function render($view, $params = []) { $viewFile = Yii::$service->page->theme->getViewFile($view); $content = Yii::$app->view->renderFile($viewFile, $params, $this); return $this->renderContent($content); } /** * @param $view|string
// 产品详细页面 public function actionIndex() { $data = $this->getBlock()->getLastData(); if(is_array($data)){ return $this->render($this->action->id, $data); } } /** * Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors * 这里的行为的作用为添加page cache(整页缓存)。 */
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
* 使用方法:Yii::$service->cms->article; * 上面的例子就是获取cms服务的子服务article。 */ new fecshop\services\Application($config); $application = new yii\web\Application($config); $application->run();
$_GET = [ '_id' => '5db65b33bfb7ae73b518d858', ]; $_SESSION = [ '__flash' => [], 'currency_current' => 'USD', ];