當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twig_Autoloader::autoload方法代碼示例

本文整理匯總了PHP中Twig_Autoloader::autoload方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Autoloader::autoload方法的具體用法?PHP Twig_Autoloader::autoload怎麽用?PHP Twig_Autoloader::autoload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twig_Autoloader的用法示例。


在下文中一共展示了Twig_Autoloader::autoload方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAutoload

 public function testAutoload()
 {
     $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');
     $autoloader = new Twig_Autoloader();
     $this->assertTrue($autoloader->autoload('Twig_Parser'), '->autoload() returns true if it is able to load a class');
     $this->assertFalse($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class');
 }
開發者ID:nmcteam,項目名稱:Twig,代碼行數:7,代碼來源:AutoloaderTest.php

示例2: load_twig

function load_twig()
{
    global $twig, $config;
    require 'lib/Twig/Autoloader.php';
    Twig_Autoloader::register();
    Twig_Autoloader::autoload('Twig_Extensions_Node_Trans');
    Twig_Autoloader::autoload('Twig_Extensions_TokenParser_Trans');
    Twig_Autoloader::autoload('Twig_Extensions_Extension_I18n');
    Twig_Autoloader::autoload('Twig_Extensions_Extension_Tinyboard');
    $loader = new Twig_Loader_Filesystem($config['dir']['template']);
    $loader->setPaths($config['dir']['template']);
    $twig = new Twig_Environment($loader, array('autoescape' => false, 'cache' => is_writable('templates') && (!is_dir('templates/cache') || is_writable('templates/cache')) ? "{$config['dir']['template']}/cache" : false, 'debug' => $config['debug']));
    $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
    $twig->addExtension(new Twig_Extensions_Extension_I18n());
}
開發者ID:carriercomm,項目名稱:Tinyboard,代碼行數:15,代碼來源:template.php

示例3: dirname

<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../lib/lime/LimeAutoloader.php';
LimeAutoloader::register();
require_once dirname(__FILE__) . '/../../../lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$t = new LimeTest(3);
// ->autoload()
$t->diag('->autoload()');
$t->ok(!class_exists('Foo'), '->autoload() does not try to load classes that does not begin with Twig');
$autoloader = new Twig_Autoloader();
$t->is($autoloader->autoload('Twig_Parser'), true, '->autoload() returns true if it is able to load a class');
$t->is($autoloader->autoload('Foo'), false, '->autoload() returns false if it is not able to load a class');
開發者ID:vtprepo,項目名稱:Twig,代碼行數:21,代碼來源:AutoloaderTest.php

示例4: spl_autoload_register

<?php

/**
 * @Product: NanoCore
 * @Author: Maxim P.
 */
# System functions
include 'functions.php';
# Components autoloaders
include 'Symfony' . S . 'Component' . S . 'Twig' . S . 'Autoloader.php';
include 'ActiveRecord' . S . 'ActiveRecord.php';
/*
 * Registar class loader
 */
spl_autoload_register(function ($class) {
    $path = ROOT . S . 'engine' . S . str_replace('\\', S, $class) . '.php';
    if (is_file($path)) {
        include $path;
    } else {
        Twig_Autoloader::autoload($class);
    }
});
/*
 * Run engine container
 */
new \System\Engine\NCContainer();
開發者ID:Max201,項目名稱:nanocore,代碼行數:26,代碼來源:bootstrap.php

示例5: header

<?php

if ($_SERVER['SCRIPT_FILENAME'] == str_replace('\\', '/', __FILE__)) {
    // You cannot request this file directly.
    header('Location: ../', true, 302);
    exit;
}
require 'contrib/Twig/Autoloader.php';
Twig_Autoloader::register();
Twig_Autoloader::autoload('Twig_Extensions_Node_Trans');
Twig_Autoloader::autoload('Twig_Extensions_TokenParser_Trans');
Twig_Autoloader::autoload('Twig_Extensions_Extension_I18n');
Twig_Autoloader::autoload('Twig_Extensions_Extension_Tinyboard');
$loader = new Twig_Loader_Filesystem($config['dir']['template']);
function Element($templateFile, array $options)
{
    global $config, $debug, $loader;
    if (function_exists('create_pm_header') && (isset($options['mod']) && $options['mod'] || isset($options['__mod']))) {
        $options['pm'] = create_pm_header();
    }
    if (isset($options['body']) && $config['debug']) {
        if (isset($debug['start'])) {
            $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
            unset($debug['start']);
        }
        $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) . '</pre>';
    }
    $loader->setPaths($config['dir']['template']);
    $twig = new Twig_Environment($loader, array('autoescape' => false, 'cache' => "{$config['dir']['template']}/cache", 'debug' => $config['debug'] ? true : false));
    $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
    $twig->addExtension(new Twig_Extensions_Extension_I18n());
開發者ID:nabm,項目名稱:Tinyboard,代碼行數:31,代碼來源:template.php


注:本文中的Twig_Autoloader::autoload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。