本文整理汇总了PHP中sfCoreAutoload类的典型用法代码示例。如果您正苦于以下问题:PHP sfCoreAutoload类的具体用法?PHP sfCoreAutoload怎么用?PHP sfCoreAutoload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfCoreAutoload类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderPdf
public function renderPdf($data, $pageSize = 'a4', $pageOrientation = 'portrait')
{
$previous_error_reporting = ini_get('error_reporting');
// to avoid the complaining for fixing DOMPDF_FONT_DIR at
// siwappConfiguration.class.php
ini_set('error_reporting', E_ALL ^ E_NOTICE);
$input_data = $this->render($data, true);
sfCoreAutoload::getInstance()->unregister();
sfAutoload::getInstance()->unregister();
if (class_exists('sfAutoloadAgain')) {
sfAutoloadAgain::getInstance()->unregister();
}
require_once sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'sfDomPDFPlugin' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'sfDomPDFPlugin.class.php';
$q = new sfDomPDFPlugin($input_data);
sfCoreAutoload::getInstance()->register();
sfAutoload::getInstance()->register();
if (class_exists('sfAutoloadAgain')) {
sfAutoloadAgain::getInstance()->register();
}
$q->setProtocol('http://');
$q->setHost($_SERVER['HTTP_HOST']);
$q->setPaper($pageSize, $pageOrientation);
$q->render();
ini_set('error_reporting', $previous_error_reporting);
return $q->getPdf();
}
示例2: getInstance
/**
* Retrieves the singleton instance of this class.
*
* @return sfCoreAutoload A sfCoreAutoload implementation instance.
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new sfCoreAutoload();
}
return self::$instance;
}
示例3: register
/**
* Register sfCoreAutoload in spl autoloader.
*
* @return void
*/
public static function register()
{
if (self::$registered) {
return;
}
ini_set('unserialize_callback_func', 'spl_autoload_call');
if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) {
throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance())));
}
self::$registered = true;
}
示例4: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
require_once dirname(__FILE__) . '/../../vendor/lime/lime.php';
require_once dirname(__FILE__) . '/lime_symfony.php';
// cleanup
require_once dirname(__FILE__) . '/../../util/sfToolkit.class.php';
if ($files = glob(sys_get_temp_dir() . DIRECTORY_SEPARATOR . '/sf_autoload_unit_*')) {
foreach ($files as $file) {
unlink($file);
}
}
// update sfCoreAutoload
if ($options['update-autoloader']) {
require_once dirname(__FILE__) . '/../../autoload/sfCoreAutoload.class.php';
sfCoreAutoload::make();
}
$status = false;
$statusFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sprintf('/.test_symfony_%s_status', md5(dirname(__FILE__)));
if ($options['only-failed']) {
if (file_exists($statusFile)) {
$status = unserialize(file_get_contents($statusFile));
}
}
$h = new lime_symfony(array('force_colors' => $options['color'], 'verbose' => $options['trace']));
$h->base_dir = realpath(dirname(__FILE__) . '/../../../test');
// remove generated files
if ($options['rebuild-all']) {
$finder = sfFinder::type('dir')->name(array('base', 'om', 'map'));
foreach ($finder->in(glob($h->base_dir . '/../lib/plugins/*/test/functional/fixtures/lib')) as $dir) {
sfToolkit::clearDirectory($dir);
}
}
if ($status) {
foreach ($status as $file) {
$h->register($file);
}
} else {
$h->register(sfFinder::type('file')->prune('fixtures')->name('*Test.php')->in(array_merge(array($h->base_dir . '/unit'), glob($h->base_dir . '/../lib/plugins/*/test/unit'), array($h->base_dir . '/functional'), glob($h->base_dir . '/../lib/plugins/*/test/functional'), array($h->base_dir . '/other'))));
}
$ret = $h->run() ? 0 : 1;
file_put_contents($statusFile, serialize($h->get_failed_files()));
if ($options['xml']) {
file_put_contents($options['xml'], $h->to_xml());
}
return $ret;
}
示例5: __construct
/**
* Constructor.
*
* @param string $rootDir The project root directory
* @param sfEventDispatcher $dispatcher The event dispatcher
*/
public function __construct($rootDir = null, sfEventDispatcher $dispatcher = null)
{
if (is_null(sfProjectConfiguration::$active) || $this instanceof sfApplicationConfiguration) {
sfProjectConfiguration::$active = $this;
}
$this->rootDir = is_null($rootDir) ? self::guessRootDir() : realpath($rootDir);
$this->symfonyLibDir = realpath(dirname(__FILE__) . '/..');
// initializes autoloading for symfony core classes
require_once $this->symfonyLibDir . '/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
$this->dispatcher = is_null($dispatcher) ? new sfEventDispatcher() : $dispatcher;
ini_set('magic_quotes_runtime', 'off');
ini_set('register_globals', 'off');
sfConfig::set('sf_symfony_lib_dir', $this->symfonyLibDir);
$this->setRootDir($this->rootDir);
$this->setup();
}
示例6: bootstrap
public function bootstrap($app = 'frontend', $debug = true)
{
// so that all notices will appear
error_reporting(E_ALL);
// Load symfony core and lime testing framework
require_once $this->getSymfonyDir() . '/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
// Create configuration and context
require_once dirname(__FILE__) . '/../fixtures/project/config/ProjectConfiguration.class.php';
$this->configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', $debug);
require_once $this->configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$this->context = sfContext::createInstance($this->configuration);
new sfDatabaseManager($this->configuration);
// Register teardown / autoload functions
spl_autoload_register(array($this, 'autoload'));
register_shutdown_function(array($this, 'teardown'));
// Cleanup and copy over SQLite DB
$this->teardown();
$this->setup();
}
示例7: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
if (file_exists('symfony')) {
throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name']));
}
// create basic project structure
$finder = sfFinder::type('any')->discard('.sf');
$this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/project', sfConfig::get('sf_root_dir'), $finder);
// update project name and directory
$finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini', 'databases.yml');
$this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir')));
// update ProjectConfiguration class
$this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir')));
// update vhost sample file
$this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/vhost.sample', '##', '##', array('PROJECT_NAME' => $arguments['name'], 'SYMFONY_WEB_DIR' => sfConfig::get('sf_web_dir'), 'SYMFONY_SF_DIR' => realpath(sfCoreAutoload::getInstance()->getBaseDir() . '../data/web/sf')));
// fix permission for common directories
$fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
$fixPerms->setCommandApplication($this->commandApplication);
$fixPerms->run();
// publish assets for core plugins
$publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter);
$publishAssets->setCommandApplication($this->commandApplication);
$publishAssets->run(array(), array('--core-only'));
}
示例8: dirname
<?php
require_once dirname(__FILE__) . '/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin');
$this->enablePlugins('sfTCPDFPlugin');
$this->enablePlugins('sfDoctrineGuardPlugin');
}
}
示例9: unregister
/**
* Unregister sfCoreAutoload from spl autoloader.
*
* @return void
*/
public static function unregister()
{
spl_autoload_unregister(array(self::getInstance(), 'autoload'));
self::$registered = false;
}
示例10: lime_test
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please component the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(1);
$autoload = sfCoreAutoload::getInstance();
$t->is($autoload->getClassPath('sfaction'), $autoload->getBaseDir() . '/action/sfAction.class.php', '"sfCoreAutoload" is case-insensitive');
示例11: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__) . '/../../lib/vendor/lime/lime.php';
class lime_symfony extends lime_harness
{
protected function get_relative_file($file)
{
$file = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(array(realpath($this->base_dir) . DIRECTORY_SEPARATOR, realpath($this->base_dir . '/../lib/plugins') . DIRECTORY_SEPARATOR, $this->extension), '', $file));
return preg_replace('#^(.*?)Plugin/test/(unit|functional)/#', '[$1] $2/', $file);
}
}
require_once dirname(__FILE__) . '/../../lib/util/sfToolkit.class.php';
if ($files = glob(sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . '/sf_autoload_unit_*')) {
foreach ($files as $file) {
unlink($file);
}
}
// update sfCoreAutoload
require_once dirname(__FILE__) . '/../../lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::make();
$h = new lime_symfony(new lime_output_color());
$h->base_dir = realpath(dirname(__FILE__) . '/..');
$h->register(sfFinder::type('file')->prune('fixtures')->name('*Test.php')->in(array_merge(array($h->base_dir . '/unit'), glob($h->base_dir . '/../lib/plugins/*/test/unit'), array($h->base_dir . '/functional'), glob($h->base_dir . '/../lib/plugins/*/test/functional'), array($h->base_dir . '/other'))));
exit($h->run() ? 0 : 1);
示例12: bootstrap
public function bootstrap($app = 'frontend', $debug = true)
{
// so that all notices will appear
error_reporting(E_ALL);
// Load symfony core and lime testing framework
require_once $this->getSymfonyDir() . '/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
// Create configuration and context
require_once dirname(__FILE__) . '/../fixtures/project/config/ProjectConfiguration.class.php';
$dbms = 'sqlite';
if (isset($_SERVER['DB'])) {
$dbms = strtolower($_SERVER['DB']);
}
// Check if configuration for dbms exists
if (!file_exists(dirname(__FILE__) . '/../fixtures/project/config/database-' . $dbms . '.yml')) {
throw new Exception('Didnt find database-' . $dbms . 'yml for DBMS: "' . $dbms . '"');
}
copy(dirname(__FILE__) . '/../fixtures/project/config/database-' . $dbms . '.yml', dirname(__FILE__) . '/../fixtures/project/config/databases.yml');
$this->configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', $debug);
require_once $this->configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$this->context = sfContext::createInstance($this->configuration);
$this->databasemanager = new sfDatabaseManager($this->configuration);
// Register teardown / autoload functions
spl_autoload_register(array($this, 'autoload'));
register_shutdown_function(array($this, 'teardown'));
$this->teardown();
$this->setup();
}
示例13: setup
<?php
require_once sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
}
}
示例14: chdir
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
chdir(dirname(__FILE__));
require_once dirname(__FILE__) . '/config/ProjectConfiguration.class.php';
include sfCoreAutoload::getInstance()->getBaseDir() . '/command/cli.php';