/** * Initialize the Doctrine2 ORM. * * @param AgaviDatabaseManager The database manager of this instance. * @param array An assoc array of initialization params. * * @author David Zülke <*****@*****.**> * @since 1.0.6 */ public function initialize(AgaviDatabaseManager $databaseManager, array $parameters = array()) { parent::initialize($databaseManager, $parameters); if (!class_exists('Doctrine\\Common\\ClassLoader')) { // no soup for you! require 'Doctrine/Common/ClassLoader.php'; // let's assume Doctrine2 is on ze include path... } // iterate over all declared class loaders and register them if necessary (checks performed to avoid duplicates for Doctrine's own namespaces) // by default, we assume an install via PEAR, with all of Doctrine in one folder and on the include path // if people want to do the smart thing and ship a Doctrine release with their app, they just need to point the entire "Doctrine" namespace to the path // for bleeding edge git stuff or similar, the paths for the namespaces can be given individually, see the Doctrine manual for examples foreach ((array) $this->getParameter('class_loaders', array('Doctrine' => null)) as $namespace => $includePath) { if ($namespace == 'Doctrine' && class_exists('Doctrine\\ORM\\Version')) { // the ORM namespace's Version class exists or could be autloaded; let's assume that the class loader for any Doctrine stuff won't need registration then continue; } if (strpos($namespace, 'Doctrine\\') === 0 && class_exists($namespace . '\\Version')) { // it is a Doctrine namespace, and the namespace's Version class exists or could be autloaded; let's assume that the class loader won't need registration then continue; } // register the class loader for this namespace without further checks (there's unlikely to be further duplicates) $cl = new \Doctrine\Common\ClassLoader($namespace, $includePath); $cl->register(); } }
public function initialize() { sfConfig::set('sf_orm', 'doctrine'); if (!sfConfig::get('sf_admin_module_web_dir')) { sfConfig::set('sf_admin_module_web_dir', '/sfDoctrine2Plugin'); } if (sfConfig::get('sf_web_debug')) { require_once __DIR__ . '/../lib/debug/sfWebDebugPanelDoctrine.class.php'; $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelDoctrine', 'listenToAddPanelEvent')); } require_once __DIR__ . '/../lib/vendor/doctrine/lib/Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions'); $classLoader->setIncludePath(__DIR__ . '/../lib/vendor/active_entity'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->setIncludePath(__DIR__ . '/../lib/vendor/doctrine/lib'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Symfony'); $classLoader->setIncludePath(__DIR__ . '/../lib/vendor/doctrine/lib/vendor'); $classLoader->register(); // Entities Classes $classLoader = new \Doctrine\Common\ClassLoader('Entities', sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Repositories', sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'entities' . DIRECTORY_SEPARATOR . 'doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Proxies', sfConfig::get('sf_lib_dir')); $classLoader->register(); // Document classes $classLoader = new \Doctrine\Common\ClassLoader('Documents', sfConfig::get('sf_lib_dir')); $classLoader->register(); $this->dispatcher->connect('component.method_not_found', array($this, 'componentMethodNotFound')); }
/** * Initialize Doctrine * @return Doctrine_Manager */ public function _initDoctrine() { // include and register Doctrine's class loader require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPLICATION_PATH . '/../library/'); $classLoader->register(); // create the Doctrine configuration $config = new \Doctrine\ORM\Configuration(); // setting the cache ( to ArrayCache. Take a look at // the Doctrine manual for different options ! ) $cache = new \Doctrine\Common\Cache\ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // choosing the driver for our database schema // we'll use annotations $driver = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/models'); $config->setMetadataDriverImpl($driver); // set the proxy dir and set some options $config->setProxyDir(APPLICATION_PATH . '/models/Proxies'); $config->setAutoGenerateProxyClasses(true); $config->setProxyNamespace('App\\Proxies'); // now create the entity manager and use the connection // settings we defined in our application.ini $connectionSettings = $this->getOption('doctrine'); $conn = array('driver' => $connectionSettings['conn']['driv'], 'user' => $connectionSettings['conn']['user'], 'password' => $connectionSettings['conn']['pass'], 'dbname' => $connectionSettings['conn']['dbname'], 'host' => $connectionSettings['conn']['host']); $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config); // push the entity manager into our registry for later use $registry = Zend_Registry::getInstance(); $registry->entitymanager = $entityManager; return $entityManager; }
public function __construct() { try { $conn = array("driver" => "pdo_mysql", "host" => "localhost", "port" => "3306", "user" => "root", "password" => "", "dbname" => "controle_gastos"); /* var_dump(__DIR__); var_dump(PP); exit; */ $loader = new \Doctrine\Common\ClassLoader("Entities", __DIR__); $loader->register(); $config = Setup::createAnnotationMetadataConfiguration(array("../../" . __DIR__ . "/app/models"), false); $em = EntityManager::create($conn, $config); $cmf = new DisconnectedClassMetadataFactory(); $cmf->setEntityManager($em); $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string'); $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); $driver = new DatabaseDriver($em->getConnection()->getSchemaManager()); $em->getConfiguration()->setMetadataDriverImpl($driver); $metadata = $cmf->getAllMetadata(); $generator = new EntityGenerator(); $generator->setGenerateAnnotations(true); $generator->setGenerateStubMethods(true); $generator->setRegenerateEntityIfExists(true); $generator->setUpdateEntityIfExists(true); $generator->generate($metadata, "../../" . __DIR__ . "/app/models"); } catch (\Exception $e) { throw $e; } }
public function setup() { $this->connectEventListeners(); sfConfig::set('sf_upload_dir_name', 'uploads'); $this->enablePlugins(array('sfDoctrinePlugin', 'yiidPlugin', 'sfFormExtraPlugin', 'sfImageTransformPlugin', 'sfDoctrineGuardPlugin', 'sfForkedDoctrineApplyPlugin', 'sfDoctrineActAsTaggablePlugin')); // load common doctrine 2 files $classLoader = new Doctrine\Common\ClassLoader('Doctrine\\Common', dirname(__FILE__) . '/../lib/vendor'); $classLoader->register(); // load mongo odm mapper $classLoader = new Doctrine\Common\ClassLoader('Doctrine\\ODM\\MongoDB', dirname(__FILE__) . '/../lib/vendor'); $classLoader->register(); // load mongodb libs $classLoader = new Doctrine\Common\ClassLoader('Doctrine\\MongoDB', dirname(__FILE__) . '/../lib/vendor'); $classLoader->register(); // load some symfony 2 files $classLoader = new Doctrine\Common\ClassLoader('Symfony', dirname(__FILE__) . '/../lib/vendor'); $classLoader->register(); // load mongo-documents $classLoader = new Doctrine\Common\ClassLoader('Documents', dirname(__FILE__) . '/../lib/mongo'); $classLoader->register(); // load mongo-documents $classLoader = new Doctrine\Common\ClassLoader('Repositories', dirname(__FILE__) . '/../lib/mongo'); $classLoader->register(); // load queue stuff $classLoader = new Doctrine\Common\ClassLoader('Queue', dirname(__FILE__) . '/../lib'); $classLoader->register(); }
/** * @return \Paiva\Doctrine\Container */ public function init() { $config = $this->getOptions(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); $this->_container = new Paiva\Doctrine\Container($config); \Zend_Registry::set('Paiva_Doctrine', $this->_container); return $this->_container; }
public function loadDoctrine() { // Initialize Doctrine2 Autoloader require ROOT . 'libraries/Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', realpath(ROOT . 'libraries/')); $classLoader->register(); // Register "Doctrine Extensions" with the Autoloader $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', realpath(ROOT . 'libraries/')); $classLoader->register(); }
/** * Initialize auto loader of Doctrine * * This script loads Doctrine 2.5 into Zend Framework. Older Versions of Doctrine may have slightly different directory structures * * @return Doctrine\ORM\EntityManager */ protected function _initDoctrine() { // Fetch the global Zend Autoloader $autoloader = Zend_Loader_Autoloader::getInstance(); //Load Doctrine classloader to load all doctrine elements without namespaces require_once $this->_docRoot . '/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php'; //Doctrine Common $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common', $this->_docRoot . '/vendor/doctrine/common/lib'); $classLoader->register(); //Doctrine DBAL $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL', $this->_docRoot . '/vendor/doctrine/dbal/lib'); $classLoader->register(); //Doctrin ORM $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\ORM', $this->_docRoot . '/vendor/doctrine/orm/lib'); $classLoader->register(); //Doctrine Common Cache $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common\\Cache', $this->_docRoot . '/vendor/doctrine/cache/lib'); $classLoader->register(); //Doctrine Common Annotations $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common\\Annotations', $this->_docRoot . '/vendor/doctrine/annotations/lib'); $classLoader->register(); //Doctrine Common Collections $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common\\Collections', $this->_docRoot . '/vendor/doctrine/collections/lib'); $classLoader->register(); //Doctrine Common Inflector $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common\\Inflector', $this->_docRoot . '/vendor/doctrine/inflector/lib'); $classLoader->register(); //Doctrine Instantiator $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Instantiator', $this->_docRoot . '/vendor/doctrine/instantiator/src'); $classLoader->register(); //Doctrine Common Lexer $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common\\Lexer', $this->_docRoot . '/vendor/doctrine/lexer/lib'); $classLoader->register(); //Push the doctrine autoloader to load for the Doctrine\ namespace $autoloader->pushAutoloader($classLoader, 'Doctrine\\'); //init arraycache $cache = new \Doctrine\Common\Cache\ArrayCache(); //setup configuration as seen from the sandbox application from the doctrine2 docs //http://www.doctrine-project.org/documentation/manual/2_0/en/configuration $config = new \Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/doctrine/entities'); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir(APPLICATION_PATH . '/../data/doctrine/proxies'); $config->setProxyNamespace('Application\\Proxies'); $config->setAutoGenerateProxyClasses(true); //Load db connection credntials from application.ini $doctrineConfig = $this->getOption('doctrine'); $connectionOptions = array('driver' => $doctrineConfig['conn']['driv'], 'user' => $doctrineConfig['conn']['user'], 'password' => $doctrineConfig['conn']['pass'], 'dbname' => $doctrineConfig['conn']['dbname'], 'host' => $doctrineConfig['conn']['host']); //Bulid entitymanager and put into Zend Register $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); Zend_Registry::set('em', $em); return $em; }
public static function register_autoload() { static $has_run = false; if ($has_run) { return true; } $directory = api_get_path(LIBRARY_PATH) . 'symfony'; if (!class_exists('Doctrine\\Common\\ClassLoader', false)) { require_once $directory . '/Doctrine/Common/ClassLoader.php'; } $loader = new Doctrine\Common\ClassLoader('Monolog', $directory); $loader->register(); $has_run = true; }
public function init() { $conf = Core::conf(); $em = Core::em(); $classLoader = new \Doctrine\Common\ClassLoader('Modules\\Entities', $conf->root_dir . '/system/modules'); $classLoader->register(); $modules = $em->getRepository('Modules\\Entities\\Module')->findBy(array('active' => 1)); foreach ($modules as $module) { $classLoader = new \Doctrine\Common\ClassLoader($module->name, $conf->root_dir . '/' . $module->group . '/modules'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader($module->name . '\\Entities', $conf->root_dir . '/' . $module->group . '/modules'); $classLoader->register(); } }
/** * Loads third party libraries. * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public static function loadThirdParty() { $ds = DIRECTORY_SEPARATOR; $vendorDir = sprintf('%1$s%2$svendor%2$s', HOMEPATH, $ds); if (file_exists($vendorDir . 'doctrine')) { $path = '%1$sdoctrine%2$scommon%2$slib%2$sDoctrine%2$sCommon%2$sClassLoader.php'; require sprintf($path, $vendorDir, $ds); $commonLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'common' . $ds . 'lib'); $commonLoader->register(); $dbalLoader = new \Doctrine\Common\ClassLoader('Doctrine', $vendorDir . 'doctrine' . $ds . 'dbal' . $ds . 'lib'); $dbalLoader->register(); } if (file_exists($vendorDir . $ds . 'symfony' . $ds . 'debug')) { ErrorHandler::register(); } }
public function __construct() { // include our CodeIgniter application's database configuration require APPPATH . 'config/database.php'; // include Doctrine's fancy ClassLoader class require_once APPPATH . 'libraries/Doctrine/Common/ClassLoader.php'; // load the Doctrine classes $doctrineClassLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPPATH . 'libraries'); $doctrineClassLoader->register(); // load Symfony2 helpers // Don't be alarmed, this is necessary for YAML mapping files $symfonyClassLoader = new \Doctrine\Common\ClassLoader('Symfony', APPPATH . 'libraries/Doctrine'); $symfonyClassLoader->register(); // load the entities $entityClassLoader = new \Doctrine\Common\ClassLoader('Entities', APPPATH . 'models'); $entityClassLoader->register(); // load the proxy entities $proxyClassLoader = new \Doctrine\Common\ClassLoader('Proxies', APPPATH . 'models'); $proxyClassLoader->register(); // set up the configuration $config = new \Doctrine\ORM\Configuration(); if (ENVIRONMENT == 'development') { // set up simple array caching for development mode $cache = new \Doctrine\Common\Cache\ArrayCache(); } else { // set up caching with APC for production mode $cache = new \Doctrine\Common\Cache\ApcCache(); } $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // set up proxy configuration $config->setProxyDir(APPPATH . 'models/Proxies'); $config->setProxyNamespace('Proxies'); // auto-generate proxy classes if we are in development mode $config->setAutoGenerateProxyClasses(ENVIRONMENT == 'development'); // set up annotation driver // $yamlDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(APPPATH.'models/Mappings'); // $config->setMetadataDriverImpl($yamlDriver); $driverImpl = $config->newDefaultAnnotationDriver(APPPATH . 'models'); $config->setMetadataDriverImpl($driverImpl); // Database connection information $connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']); // create the EntityManager $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); // store it as a member, for use in our CodeIgniter controllers. $this->em = $em; }
public function __construct() { // load database configuration and custom config from CodeIgniter require APPPATH . 'config/database.php'; // Set up class loading. require_once APPPATH . 'libraries/Doctrine/Common/ClassLoader.php'; $doctrineClassLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPPATH . 'libraries'); $doctrineClassLoader->register(); $entitiesClassLoader = new \Doctrine\Common\ClassLoader('models', rtrim(APPPATH, '/')); $entitiesClassLoader->register(); $proxiesClassLoader = new \Doctrine\Common\ClassLoader('Proxies', APPPATH . 'models'); $proxiesClassLoader->register(); $symfonyClassLoader = new \Doctrine\Common\ClassLoader('Symfony', APPPATH . 'libraries/Doctrine'); $symfonyClassLoader->register(); // Choose caching method based on application mode if (ENVIRONMENT == 'production') { $cache = new \Doctrine\Common\Cache\ApcCache(); } else { $cache = new \Doctrine\Common\Cache\ArrayCache(); } // Set some configuration options $config = new Configuration(); // Metadata driver $driverImpl = $config->newDefaultAnnotationDriver(APPPATH . 'models'); $config->setMetadataDriverImpl($driverImpl); // Caching $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // Proxies $config->setProxyDir(APPPATH . 'models/Proxies'); $config->setProxyNamespace('Proxies'); if (ENVIRONMENT == 'development') { $config->setAutoGenerateProxyClasses(TRUE); } else { $config->setAutoGenerateProxyClasses(FALSE); } // SQL query logger if (DEBUGGING) { $logger = new \Doctrine\DBAL\Logging\EchoSQLLogger(); $config->setSQLLogger($logger); } // Database connection information $connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database'], 'charset' => $db['default']['char_set'], 'driverOptions' => array('charset' => $db['default']['char_set'])); // Create EntityManager $this->em = EntityManager::create($connectionOptions, $config); }
private function initDoctrine() { $this->modelPath = APPLICATION_PATH . '/configs/models'; $classLoader = new \Doctrine\Common\ClassLoader('Entities', $this->modelPath); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Symfony', BASE_PATH . '/library/Doctrine'); $classLoader->register(); $config = new \Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache()); $driverImpl = $config->newDefaultAnnotationDriver($this->modelPath); $config->setMetadataDriverImpl($driverImpl); $config->setProxyDir(BASE_PATH . '/library/Orm/Proxies'); $config->setProxyNamespace('\\Orm\\Proxies'); $em = \Doctrine\ORM\EntityManager::create($this->connectionOptions, $config); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em))); $this->entityManager = $em; }
private static function register_autoload() { static $has_run = false; if ($has_run) { return true; } require_once api_get_path(LIBRARY_PATH) . 'symfony/Doctrine/ORM/Tools/Setup.php'; $directory = api_get_path(LIBRARY_PATH) . 'symfony'; if (!class_exists('Doctrine\\Common\\ClassLoader', false)) { require_once $directory . '/doctrine/Common/ClassLoader.php'; } $loader = new Doctrine\Common\ClassLoader('Doctrine', $directory); $loader->register(); $loader = new Doctrine\Common\ClassLoader('Symfony\\Component', $directory); $loader->register(); $has_run = true; }
/** * Setup system, not included in benchmark. */ public function setUp() { require_once $this->rootPath . "/lib/Doctrine/ORM/Version.php"; if (version_compare(\Doctrine\ORM\Version::VERSION, '2.3.99') > 0) { require_once $this->rootPath . "/vendor/autoload.php"; $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Orm")); } else { if (version_compare(\Doctrine\ORM\Version::VERSION, '2.2.99') > 0) { require_once $this->rootPath . "/lib/Doctrine/ORM/Tools/Setup.php"; \Doctrine\ORM\Tools\Setup::registerAutoloadGit($this->rootPath); $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Orm")); } else { require_once $this->rootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php"; $loader = new \Doctrine\Common\ClassLoader("Doctrine\\ORM", $this->rootPath . "/lib/"); $loader->register(); $loader = new \Doctrine\Common\ClassLoader("Doctrine\\DBAL", $this->rootPath . "/lib/vendor/doctrine-dbal/lib"); $loader->register(); $loader = new \Doctrine\Common\ClassLoader("Doctrine\\Common", $this->rootPath . "/lib/vendor/doctrine-common/lib"); $loader->register(); $config = new \Doctrine\ORM\Configuration(); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . "/Orm")); } } $cache = new \Doctrine\Common\Cache\ArrayCache(); $this->queryCount = new DbalQueryCountLogger(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // not sql query cache, but dql query parsing cache. $config->setProxyDir(__DIR__ . "/proxies"); $config->setProxyNamespace('Proxies'); $config->setAutoGenerateProxyClasses(false); $config->setSQLLogger($this->queryCount); $dbParams = array('driver' => 'pdo_sqlite', 'memory' => true); $this->em = \Doctrine\ORM\EntityManager::create($dbParams, $config); $classes = $this->em->getMetadataFactory()->getAllMetadata(); $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em); try { $schemaTool->dropSchema($classes); } catch (Exception $e) { echo $e->getMessage(); } $schemaTool->createSchema($classes); $this->em->getProxyFactory()->generateProxyClasses($classes, __DIR__ . '/proxies'); }
/** * Initialize all object and datas that Doctrine's need */ public static function initialize() { $paths = array(APP_PATH . "application/models"); $isDevMode = true; $iniFile = APP_PATH . 'application/settings.ini'; if (!is_file($iniFile)) { exit("Fichier de configuration non trouvé !"); } $dataInifile = parse_ini_file($iniFile); if (!is_array($dataInifile) || empty($dataInifile['user'])) { exit("Erreur du fichier de configuration"); } // the connection configuration $dbParams = array('driver' => 'pdo_mysql', 'user' => $dataInifile['user'], 'password' => $dataInifile['pass'], 'dbname' => $dataInifile['base']); $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false); self::$entityManager = EntityManager::create($dbParams, $config); $classLoader = new \Doctrine\Common\ClassLoader('Entity', 'application/models/'); $classLoader->register(); }
private function doctrine() { # doctrine loader require_once './../library/Doctrine/Common/ClassLoader.php'; $doctrineAutoloader = new \Doctrine\Common\ClassLoader('Doctrine', './../library'); $doctrineAutoloader->register(); # configure doctrine $cache = new Doctrine\Common\Cache\ArrayCache(); $config = new Configuration(); $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver('/entities'); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir('/proxies'); $config->setProxyNamespace('Proxies'); $config->setAutoGenerateProxyClasses(true); # database connection $this->_em = EntityManager::create($this->appConfig->doctrine->connection->toArray(), $config); }
/** * Creates and returns a new instance of doctrine * @return EntityManager The Doctrine Entity Manager */ public function getDoctrineEntityManager() { try { require_once PATH_3RD_PARTY . '/doctrine-orm/vendor/autoload.php'; $config = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration(array(PATH_INCLUDE . '/models/mapping/yml'), true); $config->setProxyDir(PATH_INCLUDE . '/models/Proxies'); $config->setProxyNamespace('Babesk\\Proxies'); $config->addEntityNamespace('DM', 'Babesk\\ORM'); $conn = array('driver' => 'pdo_mysql', 'dbname' => $this->_databaseName, 'user' => $this->_username, 'password' => $this->_password, 'host' => $this->_host); $loader = new \Doctrine\Common\ClassLoader('Babesk', PATH_INCLUDE . '/models/Entities'); $loader->register(); $loader = new \Doctrine\Common\ClassLoader('Repository', PATH_INCLUDE . '/models'); $loader->register(); $entityManager = Doctrine\ORM\EntityManager::create($conn, $config); $entityManager->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')); return $entityManager; } catch (Exception $e) { throw new Exception('Could not set up doctrine entity manager!'); } }
/** * NeuralConexionBaseDatos($Base) * * Genera la conexión a la base de datos previamente configurada * Este metodo utiliza Doctrine 2 DBAL para el crud correspondiente * * $Aplicacion: nombre en mayusculas de la aplicacion correspondiente * en caso de no seleccionar aplicacion tomara el valor de la aplicacion actual * si no se reconoce configuracion de la aplicacion o no existe envia valores null * generando error en doctrine */ public static function ObtenerConexionBase($Aplicacion = 'DEFAULT') { //Leemos el archivo de configuraciones de bases de datos $DatosBaseDatos = SysNeuralNucleo::CargarArchivoJsonConfiguracion('ConfigBasesDatos.json'); //Validamos si existe la base de datos if (array_key_exists(mb_strtoupper($Aplicacion), $DatosBaseDatos)) { foreach ($DatosBaseDatos[trim(mb_strtoupper($Aplicacion))] as $key => $value) { $ParametrosConexion[trim($key)] = trim($value); } //Validamos si se encuentra la libreria de Doctrine se encuentra en el archivo de configuracion activo o inactivo $ListadoVendors = SysNeuralNucleo::CargarArchivoJsonConfiguracion('ConfigVendors.json'); //Validamos si el estado es true o false if ($ListadoVendors['DBAL Doctrine 2']['Activo'] == false) { require_once __SysNeuralFileRootVendors__ . 'Doctrine/Common/ClassLoader.php'; } //Incluimos y retornamos la conexion correspondiente $ClassLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $ClassLoader->register(); //Retornamos los datos de la conexion correspondiente return \Doctrine\DBAL\DriverManager::getConnection($ParametrosConexion); } }
public static function init() { $instance = self::getInstance(); $conf = self::conf(); require_once $conf->root_dir . '/system/lib/Doctrine/Common/ClassLoader.php'; // Set up class loading $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', $conf->root_dir . '/system/lib'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\ORM', realpath(__DIR__ . '/../../lib')); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); $classLoader->register(); // Set up caches $config = new \Doctrine\ORM\Configuration(); $cache = new \Doctrine\Common\Cache\ArrayCache(); $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver(array($conf->root_dir . '/system/Entities')); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); // Proxy configuration $config->setProxyDir($conf->root_dir . '/system/models'); $config->setProxyNamespace('Proxies'); // Set up logger // $logger = new EchoSQLLogger; // $config->setSQLLogger($logger); $config->setAutoGenerateProxyClasses(true); // Database connection information $connectionParams = array('dbname' => $conf->db_name, 'user' => $conf->db_username, 'password' => $conf->db_password, 'host' => $conf->db_hostname, 'driver' => 'pdo_' . $conf->db_driver, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'); // Create EntityManager $instance->db = \Doctrine\ORM\EntityManager::create($connectionParams, $config); // Table Prefix $evm = new \Doctrine\Common\EventManager(); $tablePrefix = new \Doctrine\Extensions\TablePrefix($conf->db_prefix); $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix); // Create EntityManager $instance->em = \Doctrine\ORM\EntityManager::create($connectionParams, $config, $evm); }
/** * NeuralConexionBaseDatos($Base) * * Genera la conexi�n a la base de datos previamente configurada * Este metodo utiliza Doctrine 2 DBAL para el crud correspondiente * * $Aplicacion: nombre en mayusculas de la aplicacion correspondiente * en caso de no seleccionar aplicacion tomara el valor de la aplicacion actual * si no se reconoce configuracion de la aplicacion o no existe envia valores null * generando error en doctrine */ public static function ObtenerConexionBase($Aplicacion = 'DEFAULT') { //Leemos el archivo de configuraciones de bases de datos $DatosBaseDatos = SysMisNeural::CargarArchivoYAMLAplicacion('Configuracion/BasesDatos.yaml'); //Validamos si existe la base de datos if (array_key_exists(mb_strtoupper($Aplicacion), $DatosBaseDatos['BASEDATOS'])) { foreach ($DatosBaseDatos['BASEDATOS'][trim(mb_strtoupper($Aplicacion))] as $key => $value) { $ParametrosConexion[trim($key)] = trim($value); } } else { //Tomamos la variable del Mod_Rewrite y validamos el url para determinar el path correspondiente $Url = SysMisNeural::LeerURLModReWrite(); if (!empty($Url[0])) { //Leemos el archivo de configuracion de accesos y lo convertimos en un array $AplicacionActiva = SysMisNeural::CargarArchivoYAMLAplicacion('Configuracion\\ConfiguracionAcceso.yaml'); //Validamos si se encuentra la aplicacion correspondiente if (array_key_exists(mb_strtoupper($Url[0]), $AplicacionActiva['APLICACIONES'])) { //Cargamos los parametros de la aplicacion correspondiente if (array_key_exists(trim(mb_strtoupper($Url[0])), $DatosBaseDatos['BASEDATOS'])) { foreach ($DatosBaseDatos['BASEDATOS'][trim(mb_strtoupper($Url[0]))] as $key => $value) { $ParametrosConexion[trim($key)] = trim($value); } } else { $ParametrosConexion = array(); } } else { $ParametrosConexion = array(); } } else { $ParametrosConexion = array(); } } require_once __SysNeuralFileRootVendors__ . 'Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); return \Doctrine\DBAL\DriverManager::getConnection($ParametrosConexion); }
public function install($modules_installed) { $modules_list = $this->getList('system'); if (empty($modules_list)) { return 'Модули не найдены'; } $modules = array(); foreach ($modules_list as $module_name => $module) { $classLoader = new \Doctrine\Common\ClassLoader($module_name, $this->conf->root_dir . '/system/modules'); $classLoader->register(); } foreach ($modules_list as $module_name => $module) { if (empty($modules_installed) || !in_array($module_name, $modules_installed)) { $modules[] = new \Modules\Module($module_name, false); } } $output = ''; if (empty($modules)) { return 'Система уже установлена и готова к работе!'; } $output .= '<h3>1. Импорт системных таблиц базы данных</h3>'; foreach ($modules as $module) { $module->createTables(); } $output .= 'Успешно.<br/><br/>'; $output .= '<h3>2. Импорт типов данных</h3>'; foreach ($modules as $module) { $module->createDataTypes(); } $output .= 'Успешно.<br/><br/>'; $output .= '<h3>3. Установка модулей</h3>'; foreach ($modules as $module) { $module->install(); } $output .= 'Успешно.<br/><br/>'; return $output; }
/** * Init Doctrine * */ protected function _initDoctrine() { $classLoader = new Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); $classLoader = new Doctrine\Common\ClassLoader('Symfony'); $classLoader->register(); $cache = new Doctrine\Common\Cache\ArrayCache(); $config = new Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl($cache); $path = APPLICATION_PATH . '/entities/metadata'; $driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver($path); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir(sys_get_temp_dir()); $config->setAutoGenerateProxyClasses(true); // database configuration parameters $connOptions = $this->_config->db->toArray(); $conn = array('driver' => $connOptions['adapter'], 'host' => $connOptions['params']['host'], 'user' => $connOptions['params']['user'], 'password' => $connOptions['params']['password'], 'dbname' => $connOptions['params']['dbname']); // obtaining the entity manager $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config); \Yaf\Registry::set('EntityManager', $entityManager); }
<?php chdir('..'); require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine'); $classLoader->register(); //$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; $configFile = 'bin/cli-config.php'; $helperSet = null; if (file_exists($configFile)) { if (!is_readable($configFile)) { trigger_error('Configuration file [' . $configFile . '] does not have read permission.', E_ERROR); } require $configFile; foreach ($GLOBALS as $helperSetCandidate) { if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { $helperSet = $helperSetCandidate; break; } } } $helperSet = $helperSet ?: new \Symfony\Component\Console\Helper\HelperSet(); $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION); $cli->setCatchExceptions(true); $cli->setHelperSet($helperSet); $cli->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand())); $cli->run();
/** * Register the autoload function for the custom library * * @param string $namespace Root library namespace * @param string $path Library path OPTIONAL * * @return void */ public static function registerCustom($namespace, $path = LC_DIR_LIB) { require_once LC_DIR_LIB . 'Doctrine' . LC_DS . 'Common' . LC_DS . 'ClassLoader.php'; $loader = new \Doctrine\Common\ClassLoader($namespace, rtrim($path, LC_DS)); $loader->register(); }
/** * Initialize auto loader of Doctrine. * * @return \Doctrine\ORM\EntityManager */ public static function init($config) { self::optionsContainDSN($config); $vendor = VENDOR_PATH . '/doctrine/common/lib/'; // ensure doctrine2 exists in the libraries folder if (is_file($vendor . 'Doctrine/Common/ClassLoader.php') === false) { throw new \Koch\Exception\Exception('Doctrine2 not found. Check Libraries Folder.', 100); } // get isolated loader require $vendor . 'Doctrine/Common/ClassLoader.php'; // setup autoloaders with namespace and path to search in $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', VENDOR_PATH); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Symfony', VENDOR_PATH . 'Doctrine/Symfony'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Entity', APPLICATION_PATH . 'Doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Repository', APPLICATION_PATH . 'Doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Proxy', APPLICATION_PATH . 'Doctrine'); $classLoader->register(); // include Doctrine Extensions $classLoader = new \Doctrine\Common\ClassLoader('doctrine-extensions', VENDOR_PATH . 'gedmo/doctrine-extensions/lib/Gedmo'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', VENDOR_PATH . 'beberlei/DoctrineExtensions/lib'); $classLoader->register(); // fetch doctrine config handler for configuring $D2Config = new \Doctrine\ORM\Configuration(); // fetch cache driver - APC in production and Array in development mode if (extension_loaded('apc') and DEBUG === false) { $cache = new \Doctrine\Common\Cache\ApcCache(); } else { $cache = new \Doctrine\Common\Cache\ArrayCache(); } // set cache driver $D2Config->setMetadataCacheImpl($cache); $D2Config->setQueryCacheImpl($cache); // set annotation driver for entities $D2Config->setMetadataDriverImpl($D2Config->newDefaultAnnotationDriver(self::getModelPathsForAllModules())); /* * This is slow like hell, because getAllClassNames traverses all * dirs and files and includes them. Its a workaround, till i find * a better way to acquire all the models. * @todo optimize this for performance reasons */ $D2Config->getMetadataDriverImpl()->getAllClassNames(); #\Koch\Debug\Debug::firebug($config->getMetadataDriverImpl()->getAllClassNames()); // set proxy dirs $D2Config->setProxyDir(APPLICATION_PATH . 'Doctrine'); $D2Config->setProxyNamespace('Proxy'); // regenerate proxies only in debug and not in production mode if (DEBUG === true) { $D2Config->setAutoGenerateProxyClasses(true); } else { $D2Config->setAutoGenerateProxyClasses(false); } // use main configuration values for setting up the connection $connectionOptions = ['driver' => $config['database']['driver'], 'user' => $config['database']['user'], 'password' => $config['database']['password'], 'dbname' => $config['database']['dbname'], 'host' => $config['database']['host'], 'charset' => $config['database']['charset'], 'driverOptions' => ['charset' => $config['database']['charset']]]; // set up Logger #$config->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger); /* * Events */ $event = new \Doctrine\Common\EventManager(); /* * Database Prefix * * The constant definition is for building (raw) sql queries manually. * The database prefixing is registered via an event. */ define('DB_PREFIX', $config['database']['prefix']); $tablePrefix = new TablePrefix(DB_PREFIX); $event->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix); /* * Custom Functions * * We need some more functions for MySQL, like RAND for random values. */ $D2Config->addCustomNumericFunction('RAND', 'Koch\\Doctrine\\Extensions\\Query\\Mysql\\Rand'); // Entity manager $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $D2Config, $event); // set DBAL DebugStack Logger (also needed for counting queries) if (defined('DEBUG') and DEBUG === 1) { self::$sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); $em->getConfiguration()->setSQLLogger(self::$sqlLoggerStack); // Echo SQL Queries directly on the page. $em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); } self::$em = $em; // the D2 initalization is done, remove vars to safe memory unset($config, $em, $event, $cache, $classLoader, $D2Config); return self::$em; }
/** * Initializes the application instance. * * This method * starts the session, * call Slim constructor, * set the custom log writer (if is defined in config), * bootstraps the Doctrine, * bootstraps the Auth Manager, * creates the cache and rcache components, * sets the file storage, * adds midlewares, * instantiates the Route Manager and * includes the theme.php file of the active theme if the file exists. * * * If the application was previously initiated, this method returns the application in the first line. * * @return \MapasCulturais\App */ public function init($config = array()) { if ($this->_initiated) { return $this; } $this->_initiated = true; if ($config['slim.debug']) { error_reporting(E_ALL ^ E_STRICT); } session_start(); $config['app.mode'] = key_exists('app.mode', $config) ? $config['app.mode'] : 'production'; $this->_config = $config; $this->_config['path.layouts'] = APPLICATION_PATH . 'themes/active/layouts/'; $this->_config['path.templates'] = APPLICATION_PATH . 'themes/active/views/'; $this->_config['path.metadata_inputs'] = APPLICATION_PATH . 'themes/active/metadata-inputs/'; if (!key_exists('app.sanitize_filename_function', $this->_config)) { $this->_config['app.sanitize_filename_function'] = null; } parent::__construct(array('log.level' => $config['slim.log.level'], 'log.enabled' => $config['slim.log.enabled'], 'debug' => $config['slim.debug'], 'templates.path' => $this->_config['path.templates'], 'view' => new View(), 'mode' => $this->_config['app.mode'])); $config = $this->_config; // custom log writer if (isset($config['slim.log.writer']) && is_object($config['slim.log.writer']) && method_exists($config['slim.log.writer'], 'write')) { $log = $this->getLog(); $log->setWriter($config['slim.log.writer']); } // =============== CACHE =============== // if (key_exists('app.cache', $config) && is_object($config['app.cache']) && is_subclass_of($config['app.cache'], '\\Doctrine\\Common\\Cache\\CacheProvider')) { $this->_cache = $config['app.cache']; } else { $this->_cache = new \Doctrine\Common\Cache\ArrayCache(); } // creates runtime cache component $this->_rcache = new \Doctrine\Common\Cache\ArrayCache(); // ===================================== // // ========== BOOTSTRAPING DOCTRINE ========== // // annotation driver $doctrine_config = Setup::createConfiguration($config['doctrine.isDev']); $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); $classLoader->register(); $driver = new AnnotationDriver(new AnnotationReader()); $driver->addPaths(array(__DIR__ . '/Entities/')); // tells the doctrine to ignore hook annotation. AnnotationReader::addGlobalIgnoredName('hook'); // driver must be pdo_pgsql $config['doctrine.database']['driver'] = 'pdo_pgsql'; // registering noop annotation autoloader - allow all annotations by default AnnotationRegistry::registerLoader('class_exists'); $doctrine_config->setMetadataDriverImpl($driver); $proxy_dir = APPLICATION_PATH . 'lib/MapasCulturais/DoctrineProxies'; $proxy_namespace = 'MapasCulturais\\DoctrineProxies'; $doctrine_config->setProxyDir($proxy_dir); $doctrine_config->setProxyNamespace($proxy_namespace); \Doctrine\ORM\Proxy\Autoloader::register($proxy_dir, $proxy_namespace); /** DOCTRINE2 SPATIAL */ $doctrine_config->addCustomStringFunction('st_asbinary', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STAsBinary'); $doctrine_config->addCustomStringFunction('st_astext', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STAsText'); $doctrine_config->addCustomNumericFunction('st_area', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STArea'); $doctrine_config->addCustomStringFunction('st_centroid', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STCentroid'); $doctrine_config->addCustomStringFunction('st_closestpoint', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STClosestPoint'); $doctrine_config->addCustomNumericFunction('st_contains', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STContains'); $doctrine_config->addCustomNumericFunction('st_containsproperly', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STContainsProperly'); $doctrine_config->addCustomNumericFunction('st_covers', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STCovers'); $doctrine_config->addCustomNumericFunction('st_coveredby', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STCoveredBy'); $doctrine_config->addCustomNumericFunction('st_crosses', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STCrosses'); $doctrine_config->addCustomNumericFunction('st_disjoint', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STDisjoint'); $doctrine_config->addCustomNumericFunction('st_distance', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STDistance'); $doctrine_config->addCustomStringFunction('st_envelope', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STEnvelope'); $doctrine_config->addCustomStringFunction('st_geomfromtext', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STGeomFromText'); $doctrine_config->addCustomNumericFunction('st_length', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STLength'); $doctrine_config->addCustomNumericFunction('st_linecrossingdirection', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STLineCrossingDirection'); $doctrine_config->addCustomStringFunction('st_startpoint', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STStartPoint'); $doctrine_config->addCustomStringFunction('st_summary', 'CrEOF\\Spatial\\ORM\\Query\\AST\\Functions\\PostgreSql\\STSummary'); $doctrine_config->addCustomStringFunction('string_agg', 'MapasCulturais\\DoctrineMappings\\Functions\\StringAgg'); $doctrine_config->addCustomStringFunction('unaccent', 'MapasCulturais\\DoctrineMappings\\Functions\\Unaccent'); $doctrine_config->addCustomStringFunction('recurring_event_occurrence_for', 'MapasCulturais\\DoctrineMappings\\Functions\\RecurringEventOcurrenceFor'); $doctrine_config->addCustomNumericFunction('st_dwithin', 'MapasCulturais\\DoctrineMappings\\Functions\\STDWithin'); $doctrine_config->addCustomNumericFunction('st_makepoint', 'MapasCulturais\\DoctrineMappings\\Functions\\STMakePoint'); $doctrine_config->setQueryCacheImpl($this->_cache); // obtaining the entity manager $this->_em = EntityManager::create($config['doctrine.database'], $doctrine_config); \MapasCulturais\DoctrineMappings\Types\Frequency::register(); \MapasCulturais\DoctrineMappings\Types\Point::register(); \MapasCulturais\DoctrineMappings\Types\Geography::register(); \MapasCulturais\DoctrineMappings\Types\Geometry::register(); if (@$config['app.log.query']) { $doctrine_config->setSQLLogger($config['app.queryLogger']); } $this->_em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point'); $this->_em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'geography'); $this->_em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('geometry', 'geometry'); // ============= STORAGE =============== // if (key_exists('storage.driver', $config) && class_exists($config['storage.driver']) && is_subclass_of($config['storage.driver'], '\\MapasCulturais\\Storage')) { $storage_class = $config['storage.driver']; $this->_storage = key_exists('storage.config', $config) ? $storage_class::i($config['storage.config']) : $storage_class::i(); } else { $this->_storage = \MapasCulturais\Storage\FileSystem::i(); } // ===================================== // // add middlewares if (is_array($config['slim.middlewares'])) { foreach ($config['slim.middlewares'] as $middleware) { $this->add($middleware); } } // instantiate the route manager $this->_routesManager = new RoutesManager(key_exists('routes', $config) ? $config['routes'] : array()); $this->applyHookBoundTo($this, 'mapasculturais.init'); $this->register(); // =============== AUTH ============== // $auth_class_name = $config['auth.provider'][0] === '\\' ? $config['auth.provider'] : 'MapasCulturais\\AuthProviders\\' . $config['auth.provider']; $this->_auth = new $auth_class_name($config['auth.config']); $this->_auth->setCookies(); // run theme theme.php if (file_exists(ACTIVE_THEME_PATH . 'theme.php')) { include ACTIVE_THEME_PATH . 'theme.php'; } // ===================================== // // run plugins foreach ($config['plugins.enabled'] as $plugin) { include PLUGINS_PATH . $plugin . '.php'; } // ===================================== // if (defined('DB_UPDATES_FILE') && file_exists(DB_UPDATES_FILE)) { $this->_dbUpdates(); } return $this; }
if (file_exists($candidate . 'config/bootstrap.php')) { $appPath = $candidate; break; } } } if (!isset($appPath)) { trigger_error('Can\'t locate lithium\'s application path (looking for config/bootstrap.php file). Set the environment var LITHIUM_APP accordingly', E_USER_ERROR); } require_once $appPath . 'config/bootstrap/libraries.php'; require_once $appPath . 'config/bootstrap/connections.php'; $connection = \lithium\data\Connections::get('default'); $em = $connection->getEntityManager(); $config = $em->getConfiguration(); /** * Include models from plugins */ $libraryModelPaths = glob($appPath . "libraries/*/models"); if (is_array($libraryModelPaths)) { $existingDrivers = $config->getMetadataDriverImpl(); $driverImpl = $config->newDefaultAnnotationDriver($existingDrivers->getPaths() + $libraryModelPaths); $config->setMetadataDriverImpl($driverImpl); } /** * Continue with doctrine cli config */ $loader = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL\\Migrations', PLUGIN_PATH . '/_source/migrations/lib'); $loader->register(); //Doctrine\ORM\Tools\Setup::registerAutoloadGit(PLUGIN_PATH . '/_source/doctrine2'); $em = $connection->getEntityManager(); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper()));
/** * Initialize Doctrine * * @return void */ protected function initializeDoctrine() { require ROOT . 'Library/Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); }