本文整理汇总了PHP中sfAutoload类的典型用法代码示例。如果您正苦于以下问题:PHP sfAutoload类的具体用法?PHP sfAutoload怎么用?PHP sfAutoload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfAutoload类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: autoload
/**
* Reloads the autoloader.
*
* @param string $class
*
* @return boolean
*/
public function autoload($class)
{
// only reload once
if ($this->reloaded) {
return false;
}
$autoloads = spl_autoload_functions();
// as of PHP 5.2.11, spl_autoload_functions() returns the object as the first element of the array instead of the class name
if (version_compare(PHP_VERSION, '5.2.11', '>=')) {
foreach ($autoloads as $position => $autoload) {
if ($this === $autoload[0]) {
break;
}
}
} else {
$position = array_search(array(__CLASS__, 'autoload'), $autoloads, true);
}
if (isset($autoloads[$position + 1])) {
$this->unregister();
$this->register();
// since we're rearranged things, call the chain again
spl_autoload_call($class);
return class_exists($class, false) || interface_exists($class, false);
}
$autoload = sfAutoload::getInstance();
$autoload->reloadClasses(true);
$this->reloaded = true;
return $autoload->autoload($class);
}
开发者ID:seven07ve,项目名称:vendorepuestos,代码行数:36,代码来源:sfAutoloadAgain.class.php
示例2: 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();
}
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:26,代码来源:Printer.class.php
示例3: register
public static function register()
{
if (!self::$registered) {
set_include_path(realpath(dirname(__FILE__) . '/vendor/Elastica/lib') . PATH_SEPARATOR . get_include_path());
sfAutoload::register(array('sfElasticSearch', 'autoload'));
self::$registered = true;
}
}
开发者ID:jamespaulmuir,项目名称:sfElasticSearchPlugin,代码行数:8,代码来源:sfElasticSearch.class.php
示例4: initConfiguration
/**
* Various initializations.
*/
public function initConfiguration()
{
$configCache = $this->getConfigCache();
// in debug mode, start global timer
if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) {
sfWebDebugPanelTimer::startTime();
}
// required core classes for the framework
if (!$this->isDebug() && !sfConfig::get('sf_test') && !self::$coreLoaded) {
$configCache->import('config/core_compile.yml', false);
}
// autoloader(s)
$this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
sfAutoload::getInstance()->register();
if ($this->isDebug()) {
sfAutoloadAgain::getInstance()->register();
}
// load base settings
include $configCache->checkConfig('config/settings.yml');
if ($file = $configCache->checkConfig('config/app.yml', true)) {
include $file;
}
if (false !== sfConfig::get('sf_csrf_secret')) {
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
}
sfWidget::setCharset(sfConfig::get('sf_charset'));
sfValidatorBase::setCharset(sfConfig::get('sf_charset'));
// force setting default timezone if not set
if ($default_timezone = sfConfig::get('sf_default_timezone')) {
date_default_timezone_set($default_timezone);
} else {
if (sfConfig::get('sf_force_default_timezone', true)) {
date_default_timezone_set(@date_default_timezone_get());
}
}
// error settings
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
error_reporting(sfConfig::get('sf_error_reporting'));
// initialize plugin configuration objects
$this->initializePlugins();
// compress output
if (!self::$coreLoaded) {
// ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null);
}
self::$coreLoaded = true;
}
开发者ID:specPET-ML,项目名称:FirstProject,代码行数:50,代码来源:sfApplicationConfiguration.class.php
示例5: configure
public function configure()
{
unset($this['moderated']);
unset($this['post_id']);
unset($this['moderated']);
unset($this['created_at']);
unset($this['updated_at']);
if (!sfAutoload::getInstance()->loadClass('sfWidgetFormReCaptcha')) {
throw new LogicException('Please install sfFormExtra : http://svn.symfony-project.com/plugins/sfFormExtraPlugin/');
}
$config = sfConfig::get('app_recaptcha_' . sfContext::getInstance()->getRequest()->getHost());
$this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => $config['public_key'], 'use_ssl' => true));
$this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => $config['private_key']));
$this->validatorSchema['url'] = new sfValidatorUrl(array('required' => false));
$this->validatorSchema['email'] = new sfValidatorEmail(array('required' => false));
$this->validatorSchema['name'] = new swValidatorText(array('required' => true));
$this->validatorSchema['message'] = new swValidatorText(array('required' => true));
}
开发者ID:rande,项目名称:swBlogPlugin,代码行数:18,代码来源:swBlogAddCommentForm.class.php
示例6: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
$b->get('/autoload/myAutoload')->with('request')->begin()->isParameter('module', 'autoload')->isParameter('action', 'myAutoload')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body div', 'foo')->end();
$t = $b->test();
$autoload = sfAutoload::getInstance();
$t->ok(@file_get_contents($autoload->getClassPath('sfpropel'), FILE_USE_INCLUDE_PATH), '"sfAutoload" is case insensitive');
$t->ok(class_exists('BaseExtendMe'), 'plugin lib directory added to autoload');
$r = new ReflectionClass('ExtendMe');
$t->like(str_replace(DIRECTORY_SEPARATOR, '/', $r->getFilename()), '~fixtures/lib/ExtendMe~', 'plugin class can be replaced by project');
$t->ok(class_exists('NotInLib'), 'plugin autoload sets class paths');
$t->ok(!class_exists('ExcludedFromAutoload'), 'plugin autoload excludes directories');
开发者ID:sensorsix,项目名称:app,代码行数:23,代码来源:autoloadTest.php
示例7: initializeAutoload
/**
* Initializes autoloaders.
*
* @param sfProjectConfiguration $configuration The current project or application configuration
* @param boolean $reload If true, all autoloaders will be reloaded
*/
protected function initializeAutoload(sfProjectConfiguration $configuration, $reload = false)
{
// sfAutoload
if ($reload) {
$this->logSection('autoload', 'Resetting application autoloaders');
$finder = sfFinder::type('file')->name('*autoload.yml.php');
$this->getFilesystem()->remove($finder->in(sfConfig::get('sf_cache_dir')));
sfAutoload::getInstance()->reloadClasses(true);
}
// sfSimpleAutoload
if (!$configuration instanceof sfApplicationConfiguration) {
// plugins
if ($reload) {
foreach ($configuration->getPlugins() as $name) {
$configuration->getPluginConfiguration($name)->initializeAutoload();
}
}
// project
$autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir') . '/project_autoload.cache');
$autoload->loadConfiguration(sfFinder::type('file')->name('autoload.yml')->in(array(sfConfig::get('sf_symfony_lib_dir') . '/config/config', sfConfig::get('sf_config_dir'))));
$autoload->register();
if ($reload) {
$this->logSection('autoload', 'Resetting CLI autoloader');
$autoload->reload();
}
}
}
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:33,代码来源:sfBaseTask.class.php
示例8: initConfiguration
/**
* @see sfProjectConfiguration
*/
public function initConfiguration()
{
$configCache = $this->getConfigCache();
// in debug mode, start global timer
if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted()) {
sfWebDebugPanelTimer::startTime();
}
// required core classes for the framework
if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) {
$configCache->import('config/core_compile.yml', false);
}
$this->dispatcher->connect('autoload.filter_config', array($this, 'filterAutoloadConfig'));
sfAutoload::getInstance()->register();
// load base settings
include $configCache->checkConfig('config/settings.yml');
if ($file = $configCache->checkConfig('config/app.yml', true)) {
include $file;
}
if (false !== sfConfig::get('sf_csrf_secret')) {
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
}
sfWidget::setCharset(sfConfig::get('sf_charset'));
sfValidatorBase::setCharset(sfConfig::get('sf_charset'));
// force setting default timezone if not set
if ($default_timezone = sfConfig::get('sf_default_timezone')) {
date_default_timezone_set($default_timezone);
} else {
if (sfConfig::get('sf_force_default_timezone', true)) {
date_default_timezone_set(@date_default_timezone_get());
}
}
// error settings
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
error_reporting(sfConfig::get('sf_error_reporting'));
// initialize plugin configuration objects
$this->initializePlugins();
// Disabled by default in symfony 1.1 because it causes problems with Doctrine.
// If you want to enable it in your application, just copy the spl_autoload_register() line
// in your configuration class.
if (0 && $this->isDebug()) {
spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain'));
}
// compress output
if (!self::$coreLoaded) {
if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) {
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
}
}
self::$coreLoaded = true;
}
开发者ID:mediasadc,项目名称:alba,代码行数:53,代码来源:sfApplicationConfiguration.class.php
示例9: initConfiguration
/**
* @see sfProjectConfiguration
*/
public function initConfiguration()
{
// in debug mode, start global timer
if ($this->isDebug() && !sfConfig::get('sf_timer_start')) {
sfConfig::set('sf_timer_start', microtime(true));
}
$configCache = $this->getConfigCache();
// required core classes for the framework
if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) {
$configCache->import('config/core_compile.yml', false);
self::$coreLoaded = true;
}
sfAutoload::getInstance()->register();
// load base settings
include $configCache->checkConfig('config/settings.yml');
if ($file = $configCache->checkConfig('config/app.yml', true)) {
include $file;
}
if (false !== sfConfig::get('sf_csrf_secret')) {
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
}
// force setting default timezone if not set
if ($default_timezone = sfConfig::get('sf_default_timezone')) {
date_default_timezone_set($default_timezone);
} else {
if (sfConfig::get('sf_force_default_timezone', true)) {
date_default_timezone_set(@date_default_timezone_get());
}
}
// error settings
ini_set('display_errors', $this->isDebug() ? 'on' : 'off');
error_reporting(sfConfig::get('sf_error_reporting'));
// include all config.php from plugins
$this->loadPluginConfig();
// Disabled by default in symfony 1.1 because it causes problems with Doctrine.
// If you want to enable it in your application, just copy the spl_autoload_register() line
// in your configuration class.
if (0 && $this->isDebug()) {
spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain'));
}
// compress output
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');
}
开发者ID:ajith24,项目名称:ajithworld,代码行数:46,代码来源:sfApplicationConfiguration.class.php
示例10: standardBootstrap
protected function standardBootstrap($app, $env = 'search')
{
$this->bootstrapSymfony($app, $env, true);
sfAutoload::getInstance()->autoload('Propel');
// see ticket #2613
}
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:6,代码来源:sfLuceneBaseTask.class.php
示例11: reloadClasses
public function reloadClasses($force = false)
{
if (self::$freshCache && !$force)
{
return false;
}
$configuration = sfProjectConfiguration::getActive();
if (!$configuration || !$configuration instanceof sfApplicationConfiguration)
{
return false;
}
self::$freshCache = true;
if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
{
self::$freshCache = false;
if ($force)
{
unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
}
}
$file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
$this->classes = include($file);
foreach ($this->overriden as $class => $path)
{
$this->classes[$class] = $path;
}
return true;
}
开发者ID:rieteke,项目名称:guizmed,代码行数:28,代码来源:config_core_compile.yml.php
示例12: reloadClasses
/**
* Reloads the autoloader.
*
* @param boolean $force Whether to force a reload
*
* @return boolean True if the reload was successful, otherwise false
*/
public function reloadClasses($force = false)
{
// only (re)load the autoloading cache once per request
if (self::$freshCache && !$force) {
return false;
}
$configuration = sfProjectConfiguration::getActive();
if (!$configuration || !$configuration instanceof sfApplicationConfiguration) {
return false;
}
self::$freshCache = true;
if (is_file($configuration->getConfigCache()->getCacheName('config/autoload.yml'))) {
self::$freshCache = false;
if ($force) {
if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml'))) {
unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
}
}
}
$file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
if ($force && defined('HHVM_VERSION')) {
// workaround for https://github.com/facebook/hhvm/issues/1447
$this->classes = eval(str_replace('<?php', '', file_get_contents($file)));
} else {
$this->classes = (include $file);
}
foreach ($this->overriden as $class => $path) {
$this->classes[$class] = $path;
}
return true;
}
开发者ID:lexpress,项目名称:symfony1,代码行数:38,代码来源:sfAutoload.class.php
注:本文中的sfAutoload类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论