当前位置: 首页>>代码示例>>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;未经允许,请勿转载。