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


PHP FileCache::getInstance方法代码示例

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


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

示例1: __autoload

/**
 * Class autoloader
 *
 * Include classes automatically when they are instantiated.
 * @param string
 */
function __autoload($strClassName)
{
    $objCache = FileCache::getInstance('autoload');
    // Try to load the class name from the session cache
    if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->{$strClassName})) {
        if (@(include_once TL_ROOT . '/' . $objCache->{$strClassName})) {
            return;
            // The class could be loaded
        } else {
            unset($objCache->{$strClassName});
            // The class has been removed
        }
    }
    $strLibrary = TL_ROOT . '/system/libraries/' . $strClassName . '.php';
    // Check for libraries first
    if (file_exists($strLibrary)) {
        include_once $strLibrary;
        $objCache->{$strClassName} = 'system/libraries/' . $strClassName . '.php';
        return;
    }
    // Then check the modules folder
    foreach (scan(TL_ROOT . '/system/modules/') as $strFolder) {
        if (substr($strFolder, 0, 1) == '.') {
            continue;
        }
        $strModule = TL_ROOT . '/system/modules/' . $strFolder . '/' . $strClassName . '.php';
        if (file_exists($strModule)) {
            include_once $strModule;
            $objCache->{$strClassName} = 'system/modules/' . $strFolder . '/' . $strClassName . '.php';
            return;
        }
    }
    // HOOK: include Swift classes
    if (class_exists('Swift', false)) {
        Swift::autoload($strClassName);
        return;
    }
    // HOOK: include DOMPDF classes
    if (function_exists('DOMPDF_autoload')) {
        DOMPDF_autoload($strClassName);
        return;
    }
    trigger_error(sprintf('Could not load class %s', $strClassName), E_USER_ERROR);
}
开发者ID:jens-wetzel,项目名称:use2,代码行数:50,代码来源:functions.php

示例2: deleteFromTemplateCache

 /**
  * Update the file cache if a template is deleted
  * @return string
  */
 public function deleteFromTemplateCache($strFile)
 {
     $objCache = FileCache::getInstance('templates');
     $strKey = preg_replace('/^.*\\/([^\\/]+)\\.[a-z0-9]{3,5}$/i', '$1', $strFile);
     unset($objCache->{$strKey});
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:10,代码来源:tl_templates.php

示例3: getTemplate

 /**
  * Find a particular template file and return its path
  * @param string
  * @param string
  * @return string
  * @throws Exception
  */
 protected function getTemplate($strTemplate, $strFormat = 'html5', $blnFailIfNotFound = false)
 {
     $strTemplate = basename($strTemplate);
     // Contao 3.X only.
     if (version_compare(VERSION, '3.0', '>=')) {
         // Check for a theme folder
         if (TL_MODE == 'FE') {
             global $objPage;
             $strCustom = str_replace('../', '', $objPage->templateGroup);
             if ($strCustom != '') {
                 return \TemplateLoader::getPath($strTemplate, $strFormat, $strCustom);
             }
         }
         return \TemplateLoader::getPath($strTemplate, $strFormat);
     }
     // Contao 2.X from here on.
     $strKey = $strFilename = $strTemplate . '.' . $strFormat;
     // Check for a theme folder
     if (TL_MODE == 'FE') {
         global $objPage;
         $strTemplateGroup = str_replace(array('../', 'templates/'), '', $objPage->templateGroup);
         if ($strTemplateGroup != '') {
             $strKey = $strTemplateGroup . '/' . $strKey;
         }
     }
     $objCache = FileCache::getInstance('templates');
     // Try to load the template path from the cache
     if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->{$strKey})) {
         if (file_exists(TL_ROOT . '/' . $objCache->{$strKey})) {
             return TL_ROOT . '/' . $objCache->{$strKey};
         } else {
             unset($objCache->{$strKey});
         }
     }
     $strPath = TL_ROOT . '/templates';
     // Check the theme folder first
     if (TL_MODE == 'FE' && $strTemplateGroup != '') {
         $strFile = $strPath . '/' . $strTemplateGroup . '/' . $strFilename;
         if (file_exists($strFile)) {
             $objCache->{$strKey} = 'templates/' . $strTemplateGroup . '/' . $strFilename;
             return $strFile;
         }
     }
     // Then check the global templates directory
     $strFile = $strPath . '/' . $strFilename;
     if (file_exists($strFile)) {
         $objCache->{$strKey} = 'templates/' . $strFilename;
         return $strFile;
     }
     // At last browse all module folders in reverse order
     foreach (array_reverse(Config::getInstance()->getActiveModules()) as $strModule) {
         $strFile = TL_ROOT . '/system/modules/' . $strModule . '/templates/' . $strFilename;
         if (file_exists($strFile)) {
             $objCache->{$strKey} = 'system/modules/' . $strModule . '/templates/' . $strFilename;
             return $strFile;
         }
     }
     if ($blnFailIfNotFound) {
         throw new Exception('Could not find template file "' . $strFilename . '"');
     }
 }
开发者ID:amenk,项目名称:MetaModels-core,代码行数:68,代码来源:MetaModelTemplate.php

示例4: classFileExists

 /**
  * Return true if a class file exists
  * @param string
  * @param boolean
  */
 protected function classFileExists($strClass, $blnNoCache = false)
 {
     if ($strClass == '') {
         return false;
     }
     // Try to load from cache
     if (!$blnNoCache) {
         // Handle multiple requests for the same class
         if (isset($this->arrCache[$strClass])) {
             return $this->arrCache[$strClass];
         }
         $objCache = FileCache::getInstance('classes');
         // Check the file cache
         if (isset($objCache->{$strClass})) {
             $this->arrCache[$strClass] = $objCache->{$strClass};
             return $objCache->{$strClass};
         } else {
             unset($objCache->{$strClass});
         }
     }
     $this->import('Config');
     // see ticket #152
     $this->arrCache[$strClass] = false;
     // Browse all modules
     foreach ($this->Config->getActiveModules() as $strModule) {
         $strFile = 'system/modules/' . $strModule . '/' . $strClass . '.php';
         if (file_exists(TL_ROOT . '/' . $strFile)) {
             // Also store the result in the autoloader cache, so the
             // function does not have to browse the module folders again
             $objAutoload = FileCache::getInstance('autoload');
             $objAutoload->{$strClass} = $strFile;
             $this->arrCache[$strClass] = true;
             break;
         }
     }
     // Remember the result
     if (!$blnNoCache) {
         $objCache->{$strClass} = $this->arrCache[$strClass];
     }
     return $this->arrCache[$strClass];
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:46,代码来源:Controller.php

示例5: scanTwigCacheDirectories

        scanTwigCacheDirectories('system/cache/twig');
    }
} else {
    /**
     * Maintenance
     */
    $GLOBALS['TL_MAINTENANCE'][] = 'PurgeTwigCache';
}
if (!file_exists(TL_ROOT . '/system/cache/twig')) {
    mkdir(TL_ROOT . '/system/cache/twig', 0777, true);
}
/**
 * Content elements
 */
$GLOBALS['TL_CTE']['texts']['twig'] = 'ContentTwig';
/**
 * Front end modules
 */
$GLOBALS['FE_MOD']['miscellaneous']['twig'] = 'ModuleTwig';
if (version_compare(VERSION, '3', '<')) {
    spl_autoload_unregister('__autoload');
    require_once TL_ROOT . '/system/modules/twig/classes/vendor/autoload.php';
    spl_autoload_register('__autoload');
    $classes = array('TwigHybrid', 'ContaoTwig', 'TwigModule', 'ModuleTwig', 'ContaoTwigExtension', 'ContaoTwigRefererAccessObject', 'ContaoTwigEnvironmentAccessObject', 'TwigFrontendTemplate', 'TwigBackendModule', 'PurgeTwigCache', 'TwigHelper', 'ContaoTwigGlobalAccessObject', 'TwigTemplate', 'TwigBackendTemplate', 'TwigCustomPagination', 'TwigSimpleHybrid', 'TwigPagination', 'ContentTwig', 'TwigContentElement');
    $cache = FileCache::getInstance('classes');
    foreach ($classes as $class) {
        if (!$cache->{$class}) {
            $cache->{$class} = true;
        }
    }
}
开发者ID:hoevelmanns,项目名称:antrago-products-connector,代码行数:31,代码来源:config.php

示例6: classFileExists

	/**
	 * Return true if a class file exists
	 * @param string
	 * @param boolean
	 * @return boolean
	 */
	protected function classFileExists($strClass, $blnNoCache=false)
	{
		if ($strClass == '')
		{
			return false;
		}

		$this->import('Cache');
		$strKey = __METHOD__ . '-' . $strClass;

		// Try to load from cache
		if (!$blnNoCache)
		{
			// Handle multiple requests for the same class
			if (isset($this->Cache->$strKey))
			{
				return $this->Cache->$strKey;
			}

			$objCache = FileCache::getInstance('classes');

			// Check the file cache
			if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->$strClass))
			{
				$this->Cache->$strKey = $objCache->$strClass;
				return $objCache->$strClass;
			}
		}

		$this->import('Config'); // see ticket #152
		$this->Cache->$strKey = false;

		// Browse all modules
		foreach ($this->Config->getActiveModules() as $strModule)
		{
			$strFile = 'system/modules/' . $strModule . '/' . $strClass . '.php';

			if (file_exists(TL_ROOT . '/' . $strFile))
			{
				// Also store the result in the autoloader cache, so the
				// function does not have to browse the module folders again
				$objAutoload = FileCache::getInstance('autoload');
				$objAutoload->$strClass = $strFile;

				$this->Cache->$strKey = true;
				break;
			}
		}

		// Remember the result
		if (!$blnNoCache)
		{
			$objCache->$strClass = $this->Cache->$strKey;
		}

		return $this->Cache->$strKey;
	}
开发者ID:narrenfrei,项目名称:core,代码行数:63,代码来源:Controller.php


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