} 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;
* @copyright Copyright (c) 2016 FecShop Software LLC * @license http://www.fecshop.com/license/ */ ?> <p class="proPrice"> <?php if(isset($special_price) && !empty($special_price)): ?> <?php $special_price['value'] = Yii::$service->helper->format->number_format($special_price['value']); ?> <b><?= $special_price['symbol'] ?><?= $special_price['value'] ?></b><del><?= $price['symbol'] ?><?= $price['value'] ?></del> <?php else: ?> <b><?= $price['symbol'] ?><?= $price['value'] ?></b> <?php endif; ?> </p>
{ $_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;
$ob = Yii::createObject($config); $params = $ob->$method(); if ($parentThis) { $params['parentThis'] = $parentThis; } return Yii::$app->view->renderFile($viewFile, $params); } /** * @param $configKey | string , 标记,以及报错排查时使用的key。 * @param $config,就是上面actionRender()方法中的参数,格式一样。 * @param $parentThis | array or '' , 调用层传递的参数数组,可以在view中调用。
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.
throw new InvalidConfigException('in widget ['.$configKey.'],you enable cache ,you must config widget class .'); } foreach ($diConfig as $k=>$v) { $config [$k] = $v; } return $this->renderContent($configKey, $config); } /** * @param $configKey | string ,使用配置中的widget,该参数对应相应的数组key * @param $config,就是上面actionRender()方法中的参数,格式一样。 * @param $parentThis | array or '' , 调用层传递的参数数组,可以在view中调用。
<p><?= $product['name'] ?></p> <?php $diConfig = [ 'price' => $product['price'], 'special_price' => $product['special_price'], ]; echo Yii::$service->page->widget->DiRender('home/product_price',$diConfig); ?> </a> </li> <?php endforeach; ?> <?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 选填
<section class="list"> <?php if (is_array($bestFeaturedProducts) && !empty($bestFeaturedProducts)): ?> <ul class="wall"> <?php $parentThis['products'] = $bestFeaturedProducts; $parentThis['name'] = 'featured'; echo Yii::$service->page->widget->render('cms/productlist', ['products' => $bestFeaturedProducts]); ?> </ul> <?php endif; ?> <div class="scroll-preloader"></div> </section> </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 * Get current layoutFile absolute path from mutil theme dir by protity.
// 网站信息管理 public function actionIndex() { $data = $this->getBlock()->getLastData(); return $this->render($this->action->id, $data); } public function behaviors() { $behaviors = parent::behaviors(); $cacheName = 'home';
$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();
$_SESSION = [ '__flash' => [], 'currency_current' => 'USD', ];