/** * Retrieves the singleton instance of this class. * * @return PropelAutoloader A PropelAutoloader instance. */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new PropelAutoloader(); } return self::$instance; }
public function boot(ContainerInterface $container) { require_once $container->getParameter('propel.path') . '/runtime/lib/Propel.php'; if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) { set_include_path($container->getParameter('propel.phing_path') . '/classes' . PATH_SEPARATOR . get_include_path()); } $kernel = $container->getKernelService(); if (!file_exists($autoload = $kernel->getCacheDir() . '/propel_autoload.php')) { $map = array(); foreach ($kernel->getBundles() as $bundle) { if (!file_exists($file = $bundle->getPath() . '/Resources/config/classmap.php')) { continue; } $local = (include $file); foreach ($local as $class => $path) { $map[$class] = $bundle->getPath() . '/' . $path; } } file_put_contents($autoload, '<?php return ' . var_export($map, true) . ';'); } $autoloader = \PropelAutoloader::getInstance(); $autoloader->addClassPaths(include $autoload); $autoloader->register(); $container->getPropelService(); }
protected static function autoloadMeshingClasses($testMode = false) { // Propel needs to autoload our custom base classes too $projectRoot = self::getProjectRoot(); $loader = PropelAutoloader::getInstance(); $path = $projectRoot . self::getPaths()->getPathCustomBases(); $loader->addClassPath('MeshingBaseObject', $path . '/MeshingBaseObject.php'); $loader->addClassPath('MeshingBasePeer', $path . '/MeshingBasePeer.php'); // Optionally add in test classes if ($testMode) { $loader->addClassPaths(array('TestMeshingBaseObject' => $path . '/TestMeshingBaseObject.php', 'TestMeshingBaseObject2' => $path . '/TestMeshingBaseObject2.php')); } }
/** * Initializes Propel * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function initialize() { if (self::$configuration === null) { throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); } self::configureLogging(); // reset the connection map (this should enable runtime changes of connection params) self::$connectionMap = array(); if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); PropelAutoloader::getInstance()->register(); } self::$isInit = true; }
/** * Initializes Propel * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function initialize() { if (self::$configuration === null) { throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); } self::configureLogging(); // check whether the generated model has the same version as the runtime, see gh-#577 // we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version if (isset(self::$configuration['generator_version']) && self::$configuration['generator_version'] != self::VERSION) { $warning = "Version mismatch: The generated model was build using propel '" . self::$configuration['generator_version'] . "' while the current runtime is at version '" . self::VERSION . "'"; if (self::$logger) { self::$logger->warning($warning); } else { trigger_error($warning, E_USER_WARNING); } } // reset the connection map (this should enable runtime changes of connection params) self::$connectionMap = array(); if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); PropelAutoloader::getInstance()->register(); } self::$isInit = true; }
/** * Initializes Propel. */ protected function initPropel() { if (!file_exists($this['propel.conf'])) { $this->logger->notice("Propel configuration missing, skipping propel initialization."); return; } // Use Composer autoloader instead of the built-in propel autoloader \Propel::configure($this['propel.conf']); $config = \Propel::getConfiguration(\PropelConfiguration::TYPE_OBJECT); $classmap = array(); $projectClassPath = $this['propel.projectClassPath']; foreach ($config['classmap'] as $className => $file) { $classmap[$className] = $projectClassPath . DIRECTORY_SEPARATOR . $file; } $level = error_reporting(error_reporting() & ~E_USER_WARNING); \Propel::initialize(); \PropelAutoloader::getInstance()->unregister(); $this->autoloader->addClassMap($classmap); error_reporting($level); // Initialize debugging/logging if ($this['propel.debug']) { \Propel::getConnection()->useDebug(true); if ($this['propel.logging']) { \Propel::setLogger($this->logger); } } }
/** * Initializes Propel. */ private static function initPropel() { if (!file_exists(self::$config->curry->propel->conf)) { self::log("Propel configuration missing, skipping propel initialization."); return; } // Use Composer autoloader instead of the built-in propel autoloader Propel::configure(self::$config->curry->propel->conf); $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); $classmap = array(); $projectClassPath = self::$config->curry->propel->projectClassPath; foreach ($config['classmap'] as $className => $file) { $classmap[$className] = $projectClassPath . DIRECTORY_SEPARATOR . $file; } $level = error_reporting(error_reporting() & ~E_USER_WARNING); Propel::initialize(); PropelAutoloader::getInstance()->unregister(); self::getAutoloader()->addClassMap($classmap); error_reporting($level); // Initialize debugging/logging if (self::$config->curry->propel->debug) { Propel::getConnection()->useDebug(true); if (self::$logger && self::$config->curry->propel->logging) { Propel::setLogger(self::$logger); } } }