本文整理汇总了PHP中sfSimpleAutoload::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP sfSimpleAutoload::getInstance方法的具体用法?PHP sfSimpleAutoload::getInstance怎么用?PHP sfSimpleAutoload::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfSimpleAutoload
的用法示例。
在下文中一共展示了sfSimpleAutoload::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRun
/**
* @see sfTask
*/
protected function doRun(sfCommandManager $commandManager, $options)
{
$this->process($commandManager, $options);
$this->checkProjectExists();
$application = $commandManager->getArgumentSet()->hasArgument('application') ? $commandManager->getArgumentValue('application') : null;
$env = $commandManager->getOptionSet()->hasOption('env') ? $commandManager->getOptionValue('env') : 'test';
if (!is_null($application)) {
$this->checkAppExists($application);
require_once sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
$isDebug = $commandManager->getOptionSet()->hasOption('debug') ? $commandManager->getOptionValue('debug') : true;
$this->configuration = ProjectConfiguration::getApplicationConfiguration($application, $env, $isDebug, null, $this->dispatcher);
} else {
if (file_exists(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php')) {
require_once sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
$this->configuration = new ProjectConfiguration(null, $this->dispatcher);
} else {
$this->configuration = new sfProjectConfiguration(getcwd(), $this->dispatcher);
}
}
$autoloader = sfSimpleAutoload::getInstance();
foreach ($this->configuration->getModelDirs() as $dir) {
$autoloader->addDirectory($dir);
}
if (!is_null($this->commandApplication) && !$this->commandApplication->withTrace()) {
sfConfig::set('sf_logging_enabled', false);
}
return $this->execute($commandManager->getArgumentValues(), $commandManager->getOptionValues());
}
示例2: execute
protected function execute($arguments = array(), $options = array())
{
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsLightPlugin/lib');
$configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'],
$options['env'], true);
$databaseManager = new sfDatabaseManager($configuration);
$migrator = new sfMigrator;
if (isset($arguments['schema-version']) && ctype_digit($arguments['schema-version'])) {
$max = $arguments['schema-version'];
} else {
$max = $migrator->getMaxVersion();
}
$migrations = $migrator->getMigrationsToRunUpTo($max);
foreach ($migrations as $migration) {
echo "Marking as Migrated: $migration\n";
$migrator->markMigration($migration);
}
}
开发者ID:nationalfield,项目名称:nfPropelMigrationsLightPlugin,代码行数:25,代码来源:sfPropelMarkAsMigratedTask.class.php
示例3: generate
/**
* Generates classes and templates in cache.
* Usable parameters are
* - decorated_class required Defines the class to be decorated
* - generated_class required The name of the generated decorator class
* - file_format optional format of the filename of the file, default %s.class.php
* - path optional location of the generated decorator to be saved, default \cache\decorator
*
* @param array The parameters
*
* @return string The data to put in configuration cache
*/
public function generate($params = array())
{
if (!isset($params['decorated_class'], $params['generated_class'])) {
throw new InvalidArgumentException('To generate a decorator the \'decorated_class\' and \'generated_class\' parameters are required');
}
$this->decoratedClass = $params['decorated_class'];
if (!class_exists($this->decoratedClass)) {
throw new RuntimeException('Cannot create decorator for non existing class \'' . $this->decoratedClass . '\'');
}
$this->generatedClass = $params['generated_class'];
if (class_exists($this->generatedClass)) {
throw new RuntimeException('Cannot redeclare decorator as the class already exists \'' . $this->generatedClass . '\'');
}
$path = isset($params['path']) ? $params['path'] : sfConfig::get('sf_cache_dir') . '/decorator';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$fileFormat = isset($params['file_format']) ? $params['file_format'] : '%s.class.php';
file_put_contents($path . '/' . sprintf($fileFormat, $this->generatedClass), $this->evalTemplate('sfDecoratorTemplate.php'));
$conf = $this->getGeneratorManager()->getConfiguration();
if ($conf instanceof sfApplicationConfiguration && !$conf->isDebug()) {
//register the generated class in the autoloader
sfSimpleAutoload::getInstance()->setClassPath($this->generatedClass, $path . '/' . sprintf($fileFormat, $this->generatedClass));
}
return "require_once('" . $path . '/' . sprintf($fileFormat, $this->generatedClass) . "');";
}
示例4: autoload
/**
* Autoloads symfony
* Note: This is not compatible with ->bootstrap()
* Code adopted from command/sfSymfonyCommandApplication.class.php
*/
public function autoload()
{
if ($this->autoload) {
return;
}
$this->autoload = 'simple';
require_once $this->sf_lib_dir . '/util/sfCore.class.php';
require_once $this->sf_lib_dir . '/config/sfConfig.class.php';
require_once $this->sf_lib_dir . '/util/sfSimpleAutoload.class.php';
require_once $this->sf_lib_dir . '/util/sfToolkit.class.php';
require_once $this->sf_lib_dir . '/util/sfFinder.class.php';
sfConfig::add(array('sf_symfony_lib_dir' => $this->sf_lib_dir, 'sf_symfony_data_dir' => $this->sf_lib_dir));
// directory layout
sfCore::initDirectoryLayout($this->sf_lib_dir);
// include path
set_include_path(sfConfig::get('sf_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_app_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_model_dir') . PATH_SEPARATOR . get_include_path());
$cache = sfToolkit::getTmpDir() . DIRECTORY_SEPARATOR . sprintf('limeade_autoload_%s.data', md5(__FILE__));
$autoloader = sfSimpleAutoload::getInstance($cache);
$autoloader->register();
$finder = sfFinder::type('file')->ignore_version_control()->prune('test')->prune('vendor')->name('*.php');
$autoloader->addFiles($finder->in(sfConfig::get('sf_symfony_lib_dir')));
$autoloader->addFiles($finder->in($this->project_root));
$autoloader->addDirectory(sfConfig::get('sf_root_dir') . '/plugins');
return $this;
}
示例5: sfDoctrineGuardLoginHistoryPlugin_autoload_again
function sfDoctrineGuardLoginHistoryPlugin_autoload_again($class)
{
$autoload = sfSimpleAutoload::getInstance();
$autoload->addDirectory(dirname(__FILE__) . '/../fixtures/project/lib/');
$autoload->reload();
return $autoload->autoload($class);
}
示例6: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->schemaToXML(self::DO_NOT_CHECK_SCHEMA, 'generated-');
$this->copyXmlSchemaFromPlugins('generated-');
$this->callPhing('om', self::CHECK_SCHEMA);
$this->cleanup();
$this->logSection('autoload', 'reloading autoloading');
sfSimpleAutoload::getInstance()->reload();
}
示例7: boot
public function boot($app = 'admin', $env = 'test', $debug = true)
{
$this->bootFast($app, $env, $debug);
// autoloader
$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();
$this->initialize();
dmDb::table('DmPage')->checkBasicPages();
return $this;
}
示例8: initialize
public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter)
{
parent::initialize($dispatcher, $formatter);
if (!self::$done) {
$libDir = dirname(__FILE__) . '/..';
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory($libDir);
$autoloader->register();
self::$done = true;
}
}
示例9: execute
protected function execute($arguments = array(), $options = array())
{
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsLightPlugin/lib');
$migrator = new sfMigrator();
if (!is_dir($migrator->getMigrationsDir())) {
$this->getFilesystem()->mkDirs($migrator->getMigrationsDir());
}
$this->logSection('migrations', 'generating new migration stub');
$filename = $migrator->generateMigration($arguments['name']);
$this->logSection('file+', $filename);
}
示例10: createConfiguration
protected function createConfiguration($application, $env)
{
$configuration = parent::createConfiguration($application, $env);
$autoloader = sfSimpleAutoload::getInstance();
$config = new sfAutoloadConfigHandler();
$mapping = $config->evaluate($configuration->getConfigPaths('config/autoload.yml'));
foreach ($mapping as $class => $file) {
$autoloader->setClassPath($class, $file);
}
$autoloader->register();
return $configuration;
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
$autoload = sfSimpleAutoload::getInstance();
$autoload->reload();
$autoload->saveCache();
$items = array();
if (file_exists(sfConfig::get('sf_upload_dir'))) {
$items[] = sfConfig::get('sf_upload_dir');
}
$items[] = sfConfig::get('sf_cache_dir');
$items[] = sfConfig::get('sf_web_dir') . '/cache';
$items[] = sfConfig::get('sf_config_dir');
$items[] = sfConfig::get('sf_data_dir');
$items[] = sfConfig::get('sf_log_dir');
$items[] = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'symfony';
// add the application
$apps = glob(sfConfig::get('sf_apps_dir') . '/*/config');
foreach ($apps as $app) {
$items[] = $app;
}
$appUsers = glob(sfConfig::get('sf_apps_dir') . '/*/lib/myUser.class.php');
foreach ($appUsers as $appUser) {
$items[] = $appUser;
}
$dirFinder = sfFinder::type('dir');
$fileFinder = sfFinder::type('file');
foreach ($items as $item) {
if ($this->isUnix()) {
try {
if (is_dir($item)) {
$this->getFilesystem()->execute('chmod -R 0777 ' . $item);
} else {
$this->getFilesystem()->execute('chmod 0777 ' . $item);
}
} catch (RuntimeException $e) {
$this->failed[] = $item;
}
} else {
@$this->getFilesystem()->chmod($item, 0777);
if (is_file($item)) {
continue;
}
@$this->getFilesystem()->chmod($dirFinder->in($items), 0777);
@$this->getFilesystem()->chmod($fileFinder->in($items), 0666);
}
}
// note those files that failed
if (count($this->failed)) {
$this->logBlock(array_merge(array('Permissions on the following file(s) or dir(s) could not be fixed:', ''), array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->failed)), 'ERROR_LARGE');
}
}
示例12: execute
protected function execute($arguments = array(), $options = array())
{
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsLightPlugin/lib');
$configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
$databaseManager = new sfDatabaseManager($configuration);
$migrator = new sfMigrator();
if (isset($arguments['schema-version']) && ctype_digit($arguments['schema-version'])) {
$runMigrationsCount = $migrator->migrate((int) $arguments['schema-version']);
} else {
$runMigrationsCount = $migrator->migrate();
}
$currentVersion = $migrator->getCurrentVersion();
$this->logSection('migrations', 'migrated ' . $runMigrationsCount . ' step(s)');
$this->logSection('migrations', 'current database version: ' . $currentVersion);
}
示例13: execute
protected function execute($arguments = array(), $options = array())
{
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . 'sfPropelMigrationsPlugin' . DIRECTORY_SEPARATOR . 'lib');
$migrator = new sfPropelMigrator();
if (!is_dir(sfPropelMigrationsPluginConfiguration::getMigrationsDir())) {
$this->getFilesystem()->mkDirs(sfPropelMigrationsPluginConfiguration::getMigrationsDir());
}
try {
$this->logSection('migrations', 'generating new migration stub');
$filename = $migrator->initializeMigration($arguments['name']);
$this->logSection('file+', $filename);
} catch (RuntimeException $e) {
$this->logSection('migrations', $e->getMessage(), null, 'ERROR');
} catch (InvalidArgumentException $e) {
$this->logSection('migrations', $e->getMessage(), null, 'ERROR');
}
}
示例14: initialize
public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter)
{
parent::initialize($dispatcher, $formatter);
if (!self::$done) {
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../vendor');
$libDir = dirname(__FILE__) . '/..';
$autoloader = sfSimpleAutoload::getInstance();
$autoloader->addDirectory($libDir . '/vendor/creole');
$autoloader->addDirectory($libDir . '/vendor/propel');
$autoloader->addDirectory($libDir . '/creole');
$autoloader->addDirectory($libDir . '/propel');
$autoloader->setClassPath('Propel', $libDir . '/propel/sfPropelAutoload.php');
$autoloader->addDirectory(sfConfig::get('sf_lib_dir') . '/model');
$autoloader->addDirectory(sfConfig::get('sf_lib_dir') . '/form');
$autoloader->register();
self::$done = true;
}
}
示例15: ioEditableContentPlugin_autoload_again
function ioEditableContentPlugin_autoload_again($class)
{
$autoload = sfSimpleAutoload::getInstance();
$autoload->reload();
return $autoload->autoload($class);
}