function sfDoctrineGuardLoginHistoryPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->addDirectory(dirname(__FILE__) . '/../fixtures/project/lib/'); $autoload->reload(); return $autoload->autoload($class); }
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); } }
/** * 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) . "');"; }
/** * Retrieves the singleton instance of this class. * * @param string $cacheFile The file path to save the cache * * @return sfSimpleAutoload A sfSimpleAutoload implementation instance. */ public static function getInstance($cacheFile = null) { if (!isset(self::$instance)) { self::$instance = new sfSimpleAutoload($cacheFile); } return self::$instance; }
/** * @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()); }
/** * 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; }
/** * @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(); }
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; } }
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; }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $tmpdir = sfConfig::get('sf_cache_dir') . '/models_tmp'; $ymlTmp = $tmpdir . '/yaml'; $modelTmp = $tmpdir . '/model'; $this->getFileSystem()->mkdirs($ymlTmp); $this->getFileSystem()->mkdirs($modelTmp); $migrationsPath = sfConfig::get('sf_data_dir') . '/migrations/generated'; $config = $this->getCliConfig(); $manager = Doctrine_Manager::getInstance(); $oldAttr = $manager->getAttribute(Doctrine::ATTR_MODEL_LOADING); $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE); sfSimpleAutoload::unregister(); Doctrine::generateYamlFromDb($ymlTmp . '/from.yml', array(), array('generateBaseClasses' => false)); sfSimpleAutoload::register(); $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, $oldAttr); $models = sfFinder::type('file')->name('*.php')->in($config['models_path']); foreach ($models as $model) { $dirname = basename(dirname($model)); $filename = basename($model); if ('base' !== $dirname) { continue; } $normalModelName = str_replace('Base', '', basename($model, '.class.php')); $normalModelRefClass = new ReflectionClass($normalModelName); if ($normalModelRefClass && $normalModelRefClass->isAbstract()) { continue; } $content = file_get_contents($model); $content = str_replace('abstract class Base', 'class ToPrfx', $content); $content = str_replace('extends opDoctrineRecord', 'extends Doctrine_Record', $content); $matches = array(); if (preg_match('/\\$this->setTableName\\(\'([^\']+)\'\\);/', $content, $matches)) { $tableName = $matches[1]; $content = preg_replace('/class [a-zA-Z0-9_]+/', 'class ToPrfx' . Doctrine_Inflector::classify($tableName), $content); file_put_contents($modelTmp . '/ToPrfx' . Doctrine_Inflector::classify($tableName) . '.class.php', $content); } else { file_put_contents($modelTmp . '/' . str_replace('Base', 'ToPrfx', $filename), $content); } } $migration = new Doctrine_Migration($migrationsPath); $diff = new opMigrationDiff($ymlTmp . '/from.yml', $modelTmp, $migration); $changes = $diff->generateMigrationClasses(); $this->getFileSystem()->remove($ymlTmp); $this->getFileSystem()->remove($modelTmp); $numChanges = count($changes, true) - count($changes); if (!$numChanges) { throw new Doctrine_Task_Exception('Could not generate migration classes from difference'); } else { $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', 'Generated migration classes successfully from difference')))); } }
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; }
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); }
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'); } }
/** * Register sfSimpleAutoload 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()))); } if (self::getInstance()->cacheFile) { register_shutdown_function(array(self::getInstance(), 'saveCache')); } self::$registered = true; }
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); }
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'); } }
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; } }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * 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 = sfSimpleAutoload::getInstance(); $autoload->addFile(__DIR__ . '/../sfEventDispatcherTest.class.php'); $autoload->register(); $t->is(class_exists('myeventdispatchertest'), true, '"sfSimpleAutoload" is case insensitive');
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ $_test_dir = realpath(dirname(__FILE__) . '/..'); // configuration require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir . '/..')); // 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->addDirectory(sfConfig::get('sf_apps_dir')); $autoload->addDirectory($_test_dir); $autoload->register(); // lime include $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php'; // hamcrest set_include_path(get_include_path() . PATH_SEPARATOR . sfConfig::get("sf_lib_dir") . '/vendor/hamcrest/hamcrest'); require_once 'Hamcrest.php';
function ioEditableContentPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
function sfPluploadPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
/** * Initializes autoloading for the plugin. * * This method is called when a plugin is initialized in a project * configuration. Otherwise, autoload is handled in * {@link sfApplicationConfiguration} using {@link sfAutoload}. * * @see sfSimpleAutoload */ public function initializeAutoload() { $autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir') . '/project_autoload.cache'); if (is_readable($file = $this->rootDir . '/config/autoload.yml')) { $this->configuration->getEventDispatcher()->connect('autoload.filter_config', array($this, 'filterAutoloadConfig')); $autoload->loadConfiguration(array($file)); $this->configuration->getEventDispatcher()->disconnect('autoload.filter_config', array($this, 'filterAutoloadConfig')); } else { $autoload->addDirectory($this->rootDir . '/lib'); } $autoload->register(); }
/** * Unregister sfSimpleAutoload from spl autoloader. * * @return void */ public static function unregister() { spl_autoload_unregister(array(self::getInstance(), 'autoload')); self::$registered = false; }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ include dirname(__FILE__) . '/../../../../../test/bootstrap/unit.php'; include dirname(__FILE__) . '/../../../../autoload/sfSimpleAutoload.class.php'; $autoload = sfSimpleAutoload::getInstance(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sprintf('sf_autoload_unit_doctrine_%s.data', md5(__FILE__))); $autoload->addDirectory(realpath(dirname(__FILE__) . '/../../lib')); $autoload->register(); $_test_dir = realpath(dirname(__FILE__) . '/..');
function majaxDoctrineMediaPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
/** * 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(); } } }
function sfImageTransformExtraPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
function akDoctrineTemplateCacheInvaliderPlugin_autoload_again($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
public function autoload($class) { $autoload = sfSimpleAutoload::getInstance(); $autoload->reload(); return $autoload->autoload($class); }
<?php /** * This file is part of the ckWebServicePlugin * * @package ckWebServicePlugin * @author Christian Kerl <*****@*****.**> * @copyright Copyright (c) 2010, Christian Kerl * @license http://www.opensource.org/licenses/mit-license.php MIT License * @version SVN: $Id: unit.php 26432 2010-01-09 14:11:42Z chrisk $ */ if (!isset($_SERVER['SYMFONY'])) { throw new RuntimeException('Could not find symfony core libraries.'); } include $_SERVER['SYMFONY'] . '/../test/bootstrap/unit.php'; include $_SERVER['SYMFONY'] . '/autoload/sfSimpleAutoload.class.php'; $autoload = sfSimpleAutoload::getInstance(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sprintf('ckWebServicePluginUnitTestAutoload%s.data', md5(__FILE__))); $autoload->addDirectory(realpath(dirname(__FILE__) . '/../../lib')); $autoload->register();