/** * {@inheritDoc} */ public function boot() { // Register an autoloader for proxies to avoid issues when unserializing them // when the ORM is used. if ($this->container->hasParameter('doctrine.orm.proxy_namespace')) { $namespace = $this->container->getParameter('doctrine.orm.proxy_namespace'); $dir = $this->container->getParameter('doctrine.orm.proxy_dir'); $proxyGenerator = null; if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes')) { // See https://github.com/symfony/symfony/pull/3419 for usage of references $container =& $this->container; $proxyGenerator = function ($proxyDir, $proxyNamespace, $class) use(&$container) { $originalClassName = ClassUtils::getRealClass($class); /** @var $registry Registry */ $registry = $container->get('doctrine'); // Tries to auto-generate the proxy file /** @var $em \Doctrine\ORM\EntityManager */ foreach ($registry->getManagers() as $em) { if (!$em->getConfiguration()->getAutoGenerateProxyClasses()) { continue; } $metadataFactory = $em->getMetadataFactory(); if ($metadataFactory->isTransient($originalClassName)) { continue; } $classMetadata = $metadataFactory->getMetadataFor($originalClassName); $em->getProxyFactory()->generateProxyClasses(array($classMetadata)); clearstatcache(true, Autoloader::resolveFile($proxyDir, $proxyNamespace, $class)); break; } }; } $this->autoloader = Autoloader::register($dir, $namespace, $proxyGenerator); } }
public function testAutoload() { if (file_exists(sys_get_temp_dir() . "/AutoloaderTestClass.php")) { unlink(sys_get_temp_dir() . "/AutoloaderTestClass.php"); } $autoloader = Autoloader::register(sys_get_temp_dir(), 'ProxyAutoloaderTest', function ($proxyDir, $proxyNamespace, $className) { file_put_contents(sys_get_temp_dir() . "/AutoloaderTestClass.php", "<?php namespace ProxyAutoloaderTest; class AutoloaderTestClass {} "); }); $this->assertTrue(class_exists('ProxyAutoloaderTest\\AutoloaderTestClass', true)); unlink(sys_get_temp_dir() . "/AutoloaderTestClass.php"); }
/** * @return Container */ public function init() { $options = $this->getOptions(); foreach ($options['orm']['entityManagers'] as $k => $v) { if (!isset($v['proxy'])) { continue; } $autoloader = ProxyAutoloader::register($v['proxy']['dir'], $v['proxy']['namespace']); } $container = parent::init(); $entityManager = $container->getEntityManager(); $eventManager = $entityManager->getEventManager(); $eventManager->addEventSubscriber(new ExtensionMetadataListener()); return $container; }
/* * Copyright 2015 Jack Sleight <http://jacksleight.com/> * This source file is subject to the MIT license that is bundled with this package in the file LICENCE.md. */ use Doctrine\ORM\Configuration; use Doctrine\Common\EventManager; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Proxy\Autoloader; use Chalk\Doctrine\ORM\EntityManager as ChalkEntityManager; use Chalk\Doctrine\NamingStrategy; use Chalk\Listener; \Coast\Doctrine\register_dbal_types(); if (!isset($app->config->database)) { throw new \Chalk\Exception('Database connection details are required'); } $config = new Configuration(); $config->setNamingStrategy(new NamingStrategy()); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); $config->setProxyDir($app->config->dataDir->dir('proxy')); $config->setProxyNamespace('Chalk\\Proxy'); $config->setAutoGenerateProxyClasses(false); $config->setQueryCacheImpl($app->cache->value()); $config->setResultCacheImpl($app->cache->value()); $config->setMetadataCacheImpl($app->cache->value()); Autoloader::register($app->config->dataDir->dir('proxy'), 'Chalk\\Proxy'); $evm = new EventManager(); $evm->addEventSubscriber(new Listener()); $em = new ChalkEntityManager(EntityManager::create($app->config->database + ['driver' => 'pdo_mysql', 'charset' => 'utf8'], $config, $evm)); $em->getConnection()->exec("SET NAMES utf8"); Toast\Wrapper::$em = $em; return $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; }
/** * Desarrollo::appConsolaOpciones() * * Genera la carga de las opciones adicionales * que se requieren para la autocarga de las diferentes * opciones que se requieren para ejecutar el archivo * * @return void */ private function appConsolaOpciones() { define('ENV_ENTORNO', $this->entorno); define('ENV_TIPO', 'MVC'); date_default_timezone_set(ConfigAcceso::leer($this->aplicacion, 'sistema', 'tiempo', 'zona')); require implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Configuracion', 'Parametros.php')); $consola = new \AutoCargador('Consola', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos'))); $consola->registrar(); $entidades = new \AutoCargador('Entidades', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos', 'ORM'))); $entidades->registrar(); $formulario = new \AutoCargador('Formularios', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos'))); $formulario->registrar(); $interface = new \AutoCargador('Interfaces', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos'))); $interface->registrar(); Autoloader::register(implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos', 'ORM', 'Proxy')), 'Proxy'); $utilidades = new \AutoCargador('Utilidades', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Complementos'))); $utilidades->registrar(); $modeloMVC = new \AutoCargador('Modelo', implode(DIRECTORY_SEPARATOR, array($this->appRuta, $this->entorno, 'Fuente', 'Sistema'))); $modeloMVC->registrarModelo(); $this->consolaObjeto(); }
/** * Register the autoload function for the Doctrine library * * @return void */ protected static function registerDoctrineAutoloader() { static::registerCustom('Doctrine'); static::registerCustom('Symfony'); // Proxy classes autoloader \Doctrine\ORM\Proxy\Autoloader::register(rtrim(LC_DIR_CACHE_PROXY, LC_DS), LC_MODEL_PROXY_NS); }
/** * 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 = []) { if ($this->_initiated) { return $this; } $this->_initiated = true; if ($config['slim.debug']) { error_reporting(E_ALL ^ E_STRICT); } session_start(); if ($config['app.offline']) { $bypass_callable = $config['app.offlineBypassFunction']; if (!is_callable($bypass_callable) || !$bypass_callable()) { http_response_code(307); header('Location: ' . $config['app.offlineUrl']); } } // =============== 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(); } $this->_cache->setNamespace($config['app.cache.namespace']); spl_autoload_register(function ($class) use($config) { $cache_id = "AUTOLOAD_CLASS:{$class}"; if ($config['app.useRegisteredAutoloadCache'] && $this->cache->contains($cache_id)) { $path = $this->cache->fetch($cache_id); require_once $path; return true; } foreach ($config['namespaces'] as $namespace => $base_dir) { if (strpos($class, $namespace) === 0) { $path = str_replace('\\', '/', str_replace($namespace, $base_dir, $class) . '.php'); if (\file_exists($path)) { require_once $path; if ($config['app.useRegisteredAutoloadCache']) { $this->cache->save($cache_id, $path, $config['app.registeredAutoloadCache.lifetime']); } return true; } } } }); // extende a config with theme config files $theme_class = "\\" . $config['themes.active'] . '\\Theme'; $theme_path = $theme_class::getThemeFolder() . '/'; if (file_exists($theme_path . 'conf-base.php')) { $theme_config = (require $theme_path . 'conf-base.php'); $config = array_merge($config, $theme_config); } if (file_exists($theme_path . 'config.php')) { $theme_config = (require $theme_path . 'config.php'); $config = array_merge($config, $theme_config); } $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; } $theme_class = $config['themes.active'] . '\\Theme'; parent::__construct(['log.level' => $config['slim.log.level'], 'log.enabled' => $config['slim.log.enabled'], 'debug' => $config['slim.debug'], 'templates.path' => $this->_config['path.templates'], 'view' => new $theme_class($config['themes.assetManager']), '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']); } // 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([__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->setMetadataCacheImpl($this->_cache); $doctrine_config->setQueryCacheImpl($this->_cache); $doctrine_config->setResultCacheImpl($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'] : []); $this->applyHookBoundTo($this, 'mapasculturais.init'); $this->register(); // =============== AUTH ============== // if ($token = $this->request()->headers->get('authorization')) { $this->_auth = new AuthProviders\JWT(['token' => $token]); } else { $auth_class_name = strpos($config['auth.provider'], '\\') !== false ? $config['auth.provider'] : 'MapasCulturais\\AuthProviders\\' . $config['auth.provider']; $this->_auth = new $auth_class_name($config['auth.config']); $this->_auth->setCookies(); } // initialize theme $this->view->init(); // ===================================== // // 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; }
/** * Produccion::opcionesConsola() * * Genera la carga de archivos * correspondientes para el proceso de * consola * * @param object $input * @param object $output * @return raw */ private function opcionesConsola(InputInterface $input, OutputInterface $output) { define('ENV_ENTORNO', $this->entorno); define('ENV_TIPO', 'MVC'); date_default_timezone_set(ConfigAcceso::leer($input->getArgument('app'), 'sistema', 'tiempo', 'zona')); require implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Configuracion', 'Parametros.php')); $consola = new \AutoCargador('Consola', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos'))); $entidades = new \AutoCargador('Entidades', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos', 'ORM'))); $formulario = new \AutoCargador('Formularios', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos'))); $interface = new \AutoCargador('Interfaces', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos'))); $utilidades = new \AutoCargador('Utilidades', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos'))); $modeloMVC = new \AutoCargador('Modelo', implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Sistema'))); Autoloader::register(implode(DIRECTORY_SEPARATOR, array($input->appDir, 'Complementos', 'ORM', 'Proxy')), 'Proxy'); $consola->registrar(); $entidades->registrar(); $formulario->registrar(); $interface->registrar(); $utilidades->registrar(); $modeloMVC->registrarModelo(); $this->existenciaClaseControlador($input, $output); }
/** * Boot::adicionalesIncluir() * * Genera la carga de procesos adicionales * necesarios dentro de la aplicacion * * @return void */ private function adicionalesIncluir() { date_default_timezone_set($this->confg['sistema']['tiempo']['zona']); require implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Configuracion', 'Parametros.php')); $consola = new \AutoCargador('Consola', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos'))); $consola->registrar(); $entidades = new \AutoCargador('Entidades', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos', 'ORM'))); $entidades->registrar(); $formulario = new \AutoCargador('Formularios', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos'))); $formulario->registrar(); $interface = new \AutoCargador('Interfaces', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos'))); $interface->registrar(); Autoloader::register(implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos', 'ORM', 'Proxy')), 'Proxy'); $utilidades = new \AutoCargador('Utilidades', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Complementos'))); $utilidades->registrar(); $controladorMVC = new \AutoCargador('Controlador', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Sistema'))); $controladorMVC->registrarControlador(); $modeloMVC = new \AutoCargador('Modelo', implode(DIRECTORY_SEPARATOR, array(ROOT_APPS, $this->confg['fuente']['directorio'], ENV_ENTORNO, 'Fuente', 'Sistema'))); $modeloMVC->registrarModelo(); }
/** * Register the autoload function for the Doctrine library * * @return void */ protected static function registerDoctrineAutoloader() { static::registerCustom('Doctrine'); static::registerCustom('Symfony'); static::registerCustom('Rah'); // Proxy classes autoloader \Doctrine\ORM\Proxy\Autoloader::register(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS), LC_MODEL_PROXY_NS); }