/** * @param EventInterface|MvcEvent $e * @return void */ public function onBootstrap(EventInterface $e) { $app = $e->getParam('application'); /** @var ServiceManager $sm */ $sm = $app->getServiceManager(); /** @var Options $options */ $options = $sm->get('SMSSenderOptions'); // Add the default entity driver only if specified in configuration if ($options->getEnableEntity()) { $chain = $sm->get('doctrine.driver.orm_default'); $driver = new AnnotationDriver(new AnnotationReader()); $driver->addPaths(array(__DIR__ . "/Entity")); $chain->addDriver($driver, 'SMSSender\\Entity'); } }
/** * Set up the metadata configuration * * @param $value array * @return void */ public function setMetadata(array $value) { if (!isset($value['driver']) || !is_string($value['driver'])) { throw new Zend_Application_Resource_Exception('No Valid Doctrine2 Metadata driver specified'); } if (!isset($value['mappingDir']) || !is_string($value['mappingDir'])) { throw new Zend_Application_Resource_Exception('Doctrine2 Metadata directory not set'); } switch ($value['driver']) { case 'annotation': $driver = \Doctrine\ORM\Mapping\Driver\AnnotationDriver::create($value['mappingDir']); break; case 'php': $driver = new \Doctrine\ORM\Mapping\Driver\PhpDriver($value['mappingDir']); break; case 'xml': $driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver($value['mappingDir']); break; case 'yaml': $driver = new \Doctrine\ORM\Mapping\Driver\YamlDriver($value['mappingDir']); break; default: throw new Zend_Application_Resource_Exception('No valid driver found matching ' . $value['mappingDir']); } $this->_driver = $driver; $config = $this->getConfig(); $config->setMetadataDriverImpl($driver); }
/** * Returns whether the class with the specified name is transient. Only non-transient * classes, that is entities and mapped superclasses, should have their metadata loaded. * * A class is non-transient if it is annotated with an annotation * from the {@see AnnotationDriver::entityAnnotationClasses}. * * @param string $className * * @return boolean */ public function isTransient($className) { $isTransient = parent::isTransient($className); if (!$isTransient && isset($this->extendedEntities[$className])) { $isTransient = true; } return $isTransient; }
/** * Creates an entity manager to use for all tests * * @return Doctrine\ORM\EntityManager */ protected function _createEntityManager() { $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'memory' => true)); $config = new \Doctrine\ORM\Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('DoctrineExtensions\\NestedSet\\Tests\\Proxies'); $config->setMetadataDriverImpl(\Doctrine\ORM\Mapping\Driver\AnnotationDriver::create()); return \Doctrine\ORM\EntityManager::create($conn, $config); }
/** * Updates the DB schema using Doctrine's SchemaTool. The $safeMode flag is passed * to SchemaTool unchanged. * * @Fraym\Annotation\Route("updateSchema", name="databaseUpdateSchema") * @param boolean $safeMode * @param string $outputPathAndFilename A file to write SQL to, instead of executing it * @return string */ public function updateSchema($safeMode = true, $outputPathAndFilename = null) { // Generate new module dir cache $this->createModuleDirCache(); // Add new entity paths $this->annotationDriver->addPaths($this->getModuleDirCache()); if ($outputPathAndFilename === null) { return $this->getSchemaTool()->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata(), $safeMode); } else { return file_put_contents($outputPathAndFilename, implode(PHP_EOL, $this->getSchemaTool()->getUpdateSchemaSql($this->entityManager->getMetadataFactory()->getAllMetadata(), $safeMode))); } }
/** * @return Config */ protected function registerDoctrine() : Config { // Configure Database Layer (Doctrine) $this->getContainer()->add('doctrine_connection', ['url' => 'sqlite://' . $this->getContainer()->get('vars_directory') . '/database.sqlite']); // Doctrine Metatadata Driver $this->getContainer()->share(MappingDriver::class, function () { // register the doctrine annotations AnnotationRegistry::registerFile(realpath(__DIR__ . '/../../../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php')); return AnnotationDriver::create([realpath(__DIR__ . '/../Models')]); }); return $this; }
/** * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading phpdoc annotations. * * @param string|array $paths One or multiple paths where mapping classes can be found. * @param Annotations\AnnotationReader|Annotations\Reader $reader The AnnotationReader to use, duck-typed. * @param CacheProvider $cache */ public function __construct(array $paths, Annotations\Reader $reader, CacheProvider $cache = NULL) { foreach ($paths as &$path) { if (($pos = strrpos($path, '*')) === FALSE) { continue; } $ext = substr($path, $pos + 1); $path = rtrim(substr($path, 0, $pos), '/'); $this->fileExtensions[$path][] = $ext; } parent::__construct($reader, $paths); $this->cache = $cache; }
/** * Mock factory method to create an EntityManager. * * @param unknown_type $conn * @param unknown_type $name * @param Doctrine_Configuration $config * @param Doctrine_EventManager $eventManager * @return Doctrine\ORM\EntityManager */ public static function create($conn, \Doctrine\ORM\Configuration $config = null, \Doctrine\Common\EventManager $eventManager = null) { if (is_null($config)) { $config = new \Doctrine\ORM\Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('Doctrine\\Tests\\Proxies'); $config->setMetadataDriverImpl(\Doctrine\ORM\Mapping\Driver\AnnotationDriver::create()); } if (is_null($eventManager)) { $eventManager = new \Doctrine\Common\EventManager(); } return new EntityManagerMock($conn, $config, $eventManager); }
public function boot() { if (\Config::get('doctrine')) { $em = $this->app->make('Doctrine\\ORM\\EntityManager'); $driver = \Doctrine\ORM\Mapping\Driver\AnnotationDriver::create(__DIR__); $driverChain = $em->getConfiguration()->getMetadataDriverImpl(); $driverChain->addDriver($driver, 'Barnetik\\DoctrineAuth'); } Auth::extend('doctrine', function ($app) { $provider = new DoctrineUserProvider($app->make('Doctrine\\ORM\\EntityManager'), config('auth.model')); return new \Illuminate\Auth\Guard($provider, $app['session.store']); }); $this->commands(['Barnetik\\DoctrineAuth\\Console\\Commands\\CreateUser', 'Barnetik\\DoctrineAuth\\Console\\Commands\\PublishUserModel']); }
public function setUp() { $reader = new AnnotationReader(); $driver = new AnnotationDriver($reader); $driver->addPaths(array(__DIR__ . '/Fixtures')); $config = new Configuration(); $config->setMetadataCacheImpl(new ArrayCache()); $config->setQueryCacheImpl(new ArrayCache()); $config->setProxyDir(sys_get_temp_dir()); $config->setProxyNamespace('SimpleThings\\EntityAudit\\Tests\\Proxies'); $config->setMetadataDriverImpl($driver); $conn = array('driver' => $GLOBALS['DOCTRINE_DRIVER'], 'memory' => $GLOBALS['DOCTRINE_MEMORY'], 'dbname' => $GLOBALS['DOCTRINE_DATABASE'], 'user' => $GLOBALS['DOCTRINE_USER'], 'password' => $GLOBALS['DOCTRINE_PASSWORD'], 'host' => $GLOBALS['DOCTRINE_HOST']); if (isset($GLOBALS['DOCTRINE_PATH'])) { $conn['path'] = $GLOBALS['DOCTRINE_PATH']; } $auditConfig = new AuditConfiguration(); $auditConfig->setCurrentUsername("beberlei"); $auditConfig->setAuditedEntityClasses($this->auditedEntities); $auditConfig->setGlobalIgnoreColumns(array('ignoreme')); $this->auditManager = new AuditManager($auditConfig); $this->auditManager->registerEvents($evm = new EventManager()); if (php_sapi_name() == 'cli' && isset($_SERVER['argv']) && (in_array('-v', $_SERVER['argv']) || in_array('--verbose', $_SERVER['argv']))) { $config->setSQLLogger(new EchoSQLLogger()); } $this->em = EntityManager::create($conn, $config, $evm); $schemaTool = new SchemaTool($this->em); $em = $this->em; try { $schemaTool->createSchema(array_map(function ($value) use($em) { return $em->getClassMetadata($value); }, $this->schemaEntities)); } catch (\Exception $e) { if ($GLOBALS['DOCTRINE_DRIVER'] != 'pdo_mysql' || !($e instanceof \PDOException && strpos($e->getMessage(), 'Base table or view already exists') !== false)) { throw $e; } } }
/** * @param string * @param \Doctrine\ORM\Mapping\ClassMetadataInfo */ public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) { parent::loadMetadataForClass($className, $metadata); if ($metadata instanceof \Nella\Doctrine\Mapping\ClassMetadata) { $class = \Nette\Reflection\ClassType::from($className); if ($class->hasAnnotation('service')) { $service = $class->getAnnotation('service'); if (!isset($service['class'])) { throw new \Doctrine\ORM\Mapping\MappingException("Missing service class."); } $metadata->setServiceClass($service['class']); } } }
/** * 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; }
/** * 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; }
/** * Creates the EntityManager instance. * * @return \Doctrine\ORM\EntityManager */ protected static function createEntityManager() { $config = new DoctrineConfiguration(); // entity namespaces for the test environment $namespaces = array('BedRest\\TestFixtures\\Models\\Company' => TESTS_BASEDIR . '/BedRest/TestFixtures/Models/Company/'); $config->setEntityNamespaces(array_keys($namespaces)); // basic Proxy config $config->setProxyDir(TESTS_BASEDIR . '/BedRest/TestFixtures/Proxies'); $config->setProxyNamespace('BedRest\\TestFixtures\\Proxies'); // ArrayCache, to avoid persistent caching in test environment $config->setMetadataCacheImpl(new ArrayCache()); // basic AnnotationDriver configuration for parsing Doctrine annotations $metaDriver = new AnnotationDriver(new AnnotationReader()); $metaDriver->addPaths(array_values($namespaces)); $config->setMetadataDriverImpl($metaDriver); // create the EntityManager $connectionOptions = array('driver' => 'pdo_sqlite', 'path' => TESTS_BASEDIR . '/test_db.sqlite'); $em = EntityManager::create($connectionOptions, $config); self::$doctrineEntityManager = $em; }
/** * @return \Doctrine\Common\Annotations\AnnotationReader * @throws LogicException */ protected function getAnnotationReader() { return $this->doctrine->getReader(); }
public function __construct($reader, $paths = null) { parent::__construct($reader, $paths); }
/** * @group DDC-3272 */ public function testMappedSuperclassAnnotationGeneration() { $metadata = new ClassMetadataInfo($this->_namespace . '\\EntityGeneratorBook'); $metadata->namespace = $this->_namespace; $metadata->isMappedSuperclass = true; $this->_generator->setAnnotationPrefix('ORM\\'); $this->_generator->writeEntityClass($metadata, $this->_tmpDir); $this->newInstance($metadata); // force instantiation (causes autoloading to kick in) $driver = new AnnotationDriver(new AnnotationReader(), array()); $cm = new ClassMetadata($metadata->name); $cm->initializeReflection(new RuntimeReflectionService()); $driver->loadMetadataForClass($cm->name, $cm); $this->assertTrue($cm->isMappedSuperclass); }
/** * @param AnnotationReader $reader duck-typed annotationreader * @param null $paths wird ignoriert! * @param array $classes ein Array von Strings die Klassennamen sind, die der Treiber laden will (müssen lazyloadable sein */ public function __construct($reader, $paths = null, array $classes = array()) { parent::__construct($reader); $this->classes = $classes; }