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


PHP PHPTAL::getFunctionName方法代码示例

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


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

示例1: _executeMacroOfTemplate

 /**
  * This is PHPTAL's internal function that handles
  * execution of macros from templates.
  *
  * $this is caller's context (the file where execution had originally started)
  *
  * @param PHPTAL $local_tpl is PHPTAL instance of the file in which macro is defined
  *                          (it will be different from $this if it's external macro call)
  * @access private
  */
 public final function _executeMacroOfTemplate($path, PHPTAL $local_tpl)
 {
     // extract macro source file from macro name, if macro path does not
     // contain filename, then the macro is assumed to be local
     if (preg_match('/^(.*?)\\/([a-z0-9_-]*)$/i', $path, $m)) {
         list(, $file, $macroName) = $m;
         if (isset($this->externalMacroTemplatesCache[$file])) {
             $tpl = $this->externalMacroTemplatesCache[$file];
         } else {
             $tpl = clone $this;
             array_unshift($tpl->_repositories, dirname($this->_source->getRealPath()));
             $tpl->setTemplate($file);
             $tpl->prepare();
             // keep it small (typically only 1 or 2 external files are used)
             if (count($this->externalMacroTemplatesCache) > 10) {
                 $this->externalMacroTemplatesCache = array();
             }
             $this->externalMacroTemplatesCache[$file] = $tpl;
         }
         $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_");
         if (!function_exists($fun)) {
             throw new PHPTAL_MacroMissingException("Macro '{$macroName}' is not defined in {$file}", $this->_source->getRealPath());
         }
         $fun($tpl, $this);
     } else {
         // call local macro
         $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_");
         if (!function_exists($fun)) {
             throw new PHPTAL_MacroMissingException("Macro '{$path}' is not defined", $local_tpl->_source->getRealPath());
         }
         $fun($local_tpl, $this);
     }
 }
开发者ID:ShaeS,项目名称:Pine-Birch,代码行数:43,代码来源:PHPTAL.php

示例2: _executeMacroOfTempalte

 /**
  * This is PHPTAL's internal function that handles
  * execution of macros from templates.
  *
  * $this is caller's context (the file where execution had originally started)
  * @param $local_tpl is PHPTAL instance of the file in which macro is defined (it will be different from $this if it's external macro call)
  * @access private
  */
 public final function _executeMacroOfTempalte($path, PHPTAL $local_tpl)
 {
     // extract macro source file from macro name, if macro path does not
     // contain filename, then the macro is assumed to be local
     if (preg_match('/^(.*?)\\/([a-z0-9_-]*)$/i', $path, $m)) {
         list(, $file, $macroName) = $m;
         if (isset($this->externalMacroTempaltesCache[$file])) {
             $tpl = $this->externalMacroTempaltesCache[$file];
         } else {
             $tpl = new PHPTAL($file);
             $tpl->setConfigurationFrom($this);
             $tpl->prepare();
             // keep it small (typically only 1 or 2 external files are used)
             if (count($this->externalMacroTempaltesCache) > 10) {
                 $this->externalMacroTempaltesCache = array();
             }
             $this->externalMacroTempaltesCache[$file] = $tpl;
         }
         // save current file
         $currentFile = $this->_context->_file;
         $this->_context->_file = $tpl->_file;
         $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_");
         if (!function_exists($fun)) {
             throw new PHPTAL_MacroMissingException("Macro '{$macroName}' is not defined in {$file}", $this->_source->getRealPath());
         }
         try {
             $fun($tpl, $this);
         } catch (PHPTAL_TemplateException $e) {
             $e->hintSrcPosition($tpl->_context->_file . '/' . $macroName, $tpl->_context->_line);
             $this->_context->_file = $currentFile;
             throw $e;
         }
         // restore current file
         $this->_context->_file = $currentFile;
     } else {
         // call local macro
         $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_");
         if (!function_exists($fun)) {
             throw new PHPTAL_MacroMissingException("Macro '{$path}' is not defined", $local_tpl->_source->getRealPath());
         }
         $fun($local_tpl, $this);
     }
 }
开发者ID:rafalenden,项目名称:KioCMS,代码行数:51,代码来源:PHPTAL.class.php

示例3: executeMacro

 /**
  * Execute a template macro.
  * Should be used only from within generated template code!
  *
  * @param $path string Template macro path
  */
 public function executeMacro($path)
 {
     // extract macro source file from macro name, if not source file
     // found in $path, then the macro is assumed to be local
     if (preg_match('/^(.*?)\\/([a-z0-9_]*)$/i', $path, $m)) {
         list(, $file, $macroName) = $m;
         // TODO: stores a list of already prepared macro to avoid this
         // preparation on each call
         $tpl = new PHPTAL($file);
         $tpl->setConfigurationFrom($this);
         $tpl->prepare();
         // save current file
         $currentFile = $this->_context->__file;
         $this->_context->__file = $tpl->__file;
         // require PHP generated code and execute macro function
         require_once $tpl->getCodePath();
         $fun = $tpl->getFunctionName() . '_' . $macroName;
         if (!function_exists($fun)) {
             throw new PHPTAL_Exception("Macro '{$macroName}' is not defined in {$file}", $this->_source->getRealPath());
         }
         $fun($this, $this->_context);
         // restore current file
         $this->_context->__file = $currentFile;
     } else {
         // call local macro
         $fun = $this->getFunctionName() . '_' . trim($path);
         if (!function_exists($fun)) {
             throw new PHPTAL_Exception("Macro '{$macroName}' is not defined", $this->_source->getRealPath());
         }
         $fun($this, $this->_context);
     }
 }
开发者ID:nchiapol,项目名称:ecamp,代码行数:38,代码来源:PHPTAL.php

示例4: executeMacro

 /**
  * Execute a template macro.
  * Should be used only from within generated template code!
  *
  * @param $path string Template macro path
  */
 public function executeMacro($path)
 {
     // extract macro source file from macro name, if not source file
     // found in $path, then the macro is assumed to be local
     if (preg_match('/^(.*?)\\/([a-z0-9_]*)$/i', $path, $m)) {
         list(, $file, $macroName) = $m;
         if (isset($this->externalMacroTempaltesCache[$file])) {
             $tpl = $this->externalMacroTempaltesCache[$file];
         } else {
             $tpl = new PHPTAL($file);
             $tpl->setConfigurationFrom($this);
             $tpl->prepare();
             // require PHP generated code
             require_once $tpl->getCodePath();
             $this->externalMacroTempaltesCache[$file] = $tpl;
             if (count($this->externalMacroTempaltesCache) > 10) {
                 $this->externalMacroTempaltesCache = array();
             }
             // keep it small (typically only 1 or 2 external files are used)
         }
         // save current file
         $currentFile = $this->_context->__file;
         $this->_context->__file = $tpl->__file;
         $fun = $tpl->getFunctionName() . '_' . $macroName;
         if (!function_exists($fun)) {
             throw new PHPTAL_Exception("Macro '{$macroName}' is not defined in {$file}", $this->_source->getRealPath());
         }
         $fun($this, $this->_context);
         // restore current file
         $this->_context->__file = $currentFile;
     } else {
         // call local macro
         $fun = $this->getFunctionName() . '_' . trim($path);
         if (!function_exists($fun)) {
             throw new PHPTAL_Exception("Macro '{$path}' is not defined", $this->_source->getRealPath());
         }
         $fun($this, $this->_context);
     }
 }
开发者ID:alicam,项目名称:vanilla-theme,代码行数:45,代码来源:PHPTAL.php


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