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


PHP Swift::autoload方法代码示例

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


在下文中一共展示了Swift::autoload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getenv

<?php

/****************************************************************************/
/*                                                                          */
/* YOU MAY WISH TO MODIFY OR REMOVE THE FOLLOWING LINES WHICH SET DEFAULTS  */
/*                                                                          */
/****************************************************************************/
Swift::autoload("Swift_Preferences");
$preferences = Swift_Preferences::getInstance();
// Sets the default charset so that setCharset() is not needed elsewhere
$preferences->setCharset('utf-8');
// Without these lines the default caching mechanism is "array" but this uses a lot of memory.
// If possible, use a disk cache to enable attaching large attachments etc.
// You can override the default temporary directory by setting the TMPDIR environment variable.
// The @ operator in front of is_writable calls is to avoid PHP warnings
// when using open_basedir
$tmp = getenv('TMPDIR');
if ($tmp && @is_writable($tmp)) {
    $preferences->setTempDir($tmp)->setCacheType('disk');
} elseif (function_exists('sys_get_temp_dir') && @is_writable(sys_get_temp_dir())) {
    $preferences->setTempDir(sys_get_temp_dir())->setCacheType('disk');
}
// this should only be done when Swiftmailer won't use the native QP content encoder
// see mime_deps.php
if (version_compare(phpversion(), '5.4.7', '<')) {
    $preferences->setQPDotEscape(false);
}
开发者ID:musicsnap,项目名称:Cdoco_Yaf_Ext,代码行数:27,代码来源:preferences.php


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