本文整理汇总了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');
}
示例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());
}
示例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');
示例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();
示例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());