推送模板信息
@param WeixinTemplate $template  要推送的模板
@return bool|array  推送失败返回false，否则返回推送结果
772792
public function sendTemplateMsg(WeiXinTemplate $template){
        if ($template instanceof WeiXinTemplate){
            $access_token = $this->get_access_token();
            if (!$access_token) {
                /*执行业务接口的推送日志记录*/
                if ($this->business_interface) $this->business_interface->log('access_token empty');
                return false;
            }
            $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=$access_token";
            $params = $template -> get_params();
            $result = $this->curl($url,json_encode($params));
            if ($result['errcode']){
                /*执行业务接口的推送日志记录*/
                if ($this->business_interface) $this->business_interface->log('sendTemplateMsg: result:'.json_encode($result));
                /*如果access_token已经过期强制刷新缓存access_token并从新发送一次(此处恐怕会有死循环如果has_retry不起作用的话)*/
                static $has_retry = false;
                if ($result['errcode'] == 40001 && $has_retry === false){
                    $this->refreshAccessToken();
                    $this->sendTemplateMsg($template);
                    $has_retry = true;
                }
                return false;
            }
            return $result;
        }else{
            return false;
        }
    }
543759
private function fetchTemplate($template)
    {
        $resolver = $this->getResolver();
        $content  = $resolver->resolve($template);

        if (! $content) {
            throw new Exception\TemplateNotFoundException('Template by name "' . $template . '" not found');
        }

        return $content;
    }
1257139
protected function getOutTemplate($template = 'default') {
		// check for current locale
		if ($this->locale != '') {
			$templatefile = $this->templatespath.'/'.$this->locale.'/'.$this->outtemplateprefix.$template.'.htm';
			
			if (file_exists($templatefile)) {
				return $this->locale.'/'.$this->outtemplateprefix.$template;
			}
		}
		
		// if not found, check for default locale
		if ($this->deflocale != '') {
			$templatefile = $this->templatespath.'/'.$this->deflocale.'/'.$this->outtemplateprefix.$template.'.htm';
			
			if (file_exists($templatefile)) {
				return $this->deflocale.'/'.$this->outtemplateprefix.$template;
			}
		}
		
		// if not found then check in root
		$templatefile = $this->templatespath.'/'.$this->outtemplateprefix.$template.'.htm';
			
		if (file_exists($templatefile)) {
			return $this->outtemplateprefix.$template;
		}
		
		// out template not found
		return null;
	}
1044554
protected function isRoutableTemplate(Template $template)
    {
        $template_file = new \SplFileInfo($template->getFilename());

        $is_routable =
            ($this->unroutablePrefix !== substr($template_file->getBasename(), 0, strlen($this->unroutablePrefix)));

        return($is_routable);
    }
135125
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
    {
        $controller = Loader::parseName($this->controller);
        if ('think' == strtolower($this->config['type']) && $controller && 0 !== strpos($template, '/')) {
            $depr     = $this->config['view_depr'];
            $template = str_replace(['/', ':'], $depr, $template);
            if ('' == $template) {
                // 如果模板文件名为空 按照默认规则定位
                $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $this->action;
            } elseif (false === strpos($template, $depr)) {
                $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template;
            }
        }

        return parent::fetch($template, $vars, $replace, $config);
    }
637886
private function getDomainRegex($template)
    {
        if (preg_match('#https?://(.*)#', $template, $matches)) {
            $template = $matches[1];
        }
        $parameters = [];
        if (strpos($template, '<') !== false) {
            $template = preg_replace_callback(
                '/<(?:\w+):?([^>]+)?>/u',
                function ($matches) use (&$parameters) {
                    $key = '#' . count($parameters) . '#';
                    $parameters[$key] = isset($matches[1]) ? $matches[1] : '\w+';
                    return $key;
                },
                $template
            );
        }
        $template = preg_quote($template);
        $template = strtr($template, $parameters);
        return '/^' . $template . '$/u';
    }
1238481
public function resolve($template)
    {
        foreach ($this->queue as $resolver) {
            $resource = $resolver->resolve($template);
            if (false !== $resource) {
                return $resource;
            }
        }

        return false;
    }
1313107
public static function update_template($template) {

        $params = self::validate_parameters(self::update_template_parameters(), array('template' => $template));
        $params = $params['template'];
        $template = api::read_template($params['id']);
        self::validate_context($template->get_context());

        $params = (object) $params;

        return api::update_template($params);
    }
270375
public static function getAdminTemplate($template, $module = null)
    {
        $rtn = null;

        $path = static::getPath($template, $module);

        if (!is_null($path)) {
            $templateSrc = file_get_contents($path . $template . '.html');
            $rtn = new static($templateSrc);
            Event::trigger('AdminTemplateLoaded', $rtn);

            if (!is_null($rtn)) {
                $rtn->addFunction('hash', function ($args) {
                    return md5($args['value']);
                });
            }

            return $rtn;
        }

        throw new \Exception('Template does not exist: ' . $template);
    }
1317332
private function showTemplate($template = null, $theme = null)
	{
		// 解析出模版文件名
		$file = $this->getTemplateFile($template, $theme);
		$this->pathStack[] = dirname($file).'/';
		// 将view层数据转为变量，方便模版中直接调用
		extract($this->data);
		// 返回模版引擎处理后的文件名
		$file = $this->templateEngineParse($file);
		$fp = fopen($file,'r');
		flock($fp,LOCK_SH);
		include $file;
		fclose($fp);
		array_pop($this->pathStack);
	}
601046
protected function templateExists($template)
    {
        if ($this->isBackoffice() || $this->inBackofficeRoot()) {
            $template = '@ClasticBackofficeBundle/Exception/exception_full.html.twig';
        }

        return parent::templateExists($template);
    }
502877
protected function resolveTemplate($template)
    {
        if (!$this->pathCache[$template]) {

            foreach (array_reverse($this->templateDirs) as $dir) {
                $path = $dir . DIRECTORY_SEPARATOR . $template .'.'. $this->getFileExtension();
                if (is_readable($path)) {
                    $this->pathCache[$template] = $path;
                    break;
                }
            }

        }

        return $this->pathCache[$template];
    }
589477
public function createFromTemplate($template)
    {
        $parameter = new GroupParameter();
        $parameter->setName($template->name);
        $parameter->setTemplate($template);
        if ($template->type == GroupParameterType::HASHTABLE && isset($template->entries)) {
            $parameter->setChildren($this->createRequiredFromTemplates($template->entries));
        } elseif ($template->type != GroupParameterType::HASHTABLE && $template->type != GroupParameterType::EDITABLE_HASHTABLE) {
            if ($template->type == GroupParameterType::BOOLEAN) {
                $value = true;
            } else {
                $value = empty($template->values) ? '' : $template->values[0];
            }
            $parameter->addValue($value);
        }
        return $parameter;
    }
1117530
private function getTemplateStatus(array $template) : bool
    {
        $status      = false;

        $moduleSrv = $this->getServiceLocator()->get('ModulesService');
        $modulePath = $moduleSrv->getModulePath($template['module']);

        if (!empty($modulePath)){

            $viewPath = $modulePath.'/view/'.$this->moduleNameToViewName($template['module']);
            $ctrlPath = $modulePath.'/src/Controller';

            if (strpos($modulePath, '/module/') != false){
                $ctrlPath = $modulePath.'/'.$template['module'].'/src/Controller';
            }

            $ctrlFile = $ctrlPath.'/'.$template['controller'].'Controller.php';

            if (file_exists($ctrlFile)){

                $ctrlFileContent = file_get_contents($ctrlFile);

                // Check if template's Action exists
                $actionPattern = '/function.*'.$template['action'].'Action/';
                if (preg_match($actionPattern, $ctrlFileContent)) {

                    $viewFile = $viewPath.'/'.$this->moduleNameToViewName($template['controller']).'/'.$this->moduleNameToViewName($template['action']).'.phtml';

                    if (file_exists($viewFile)){
                        $status = true;
                    }
                }
            }
        }

        return $status;
    }
733910
private function parseTemplateFile($template)
    {
        if ('' == pathinfo($template, PATHINFO_EXTENSION)) {
            if (strpos($template, '@')) {
                list($module, $template) = explode('@', $template);
            }

            if (0 !== strpos($template, '/')) {
                $template = str_replace(['/', ':'], $this->config['view_depr'], $template);
            } else {
                $template = str_replace(['/', ':'], $this->config['view_depr'], substr($template, 1));
            }

            if ($this->config['view_base']) {
                $module = isset($module) ? $module : '';
                $path   = $this->config['view_base'] . ($module ? $module . DIRECTORY_SEPARATOR : '');
            } else {
                $path = $this->config['view_path'];
            }

            $template = $path . $template . '.' . ltrim($this->config['view_suffix'], '.');
        }

        if (is_file($template)) {
            // 记录模板文件的更新时间
            $this->includeFile[$template] = filemtime($template);

            return $template;
        } else {
            throw new TemplateNotFoundException('template not exists:' . $template, $template);
        }
    }
99681
public function indexAction(Template $template)
    {
        $templating = $this->container->get('templating');

        $response = $this->getResponse(
            $templating->render(
                $template->getRenderName(),
                $template->getRenderData()
            )
        );

        return($response);
    }
926662
protected function templateExists($template)
    {
        try {
            $class = $this->templating->getTemplateClass($template);
        } catch (Twig_Error_Loader $e) {
            return false;
        }

        return $template;
    }