本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationReader::setDefaultAnnotationNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationReader::setDefaultAnnotationNamespace方法的具体用法?PHP AnnotationReader::setDefaultAnnotationNamespace怎么用?PHP AnnotationReader::setDefaultAnnotationNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Annotations\AnnotationReader
的用法示例。
在下文中一共展示了AnnotationReader::setDefaultAnnotationNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$this->dm = DocumentManager::create(new Mongo(), $config);
$currencies = array('USD' => 1, 'EURO' => 1.7, 'JPN' => 0.0125);
foreach ($currencies as $name => &$multiplier) {
$multiplier = new Currency($name, $multiplier);
$this->dm->persist($multiplier);
}
$product = new ConfigurableProduct('T-Shirt');
$product->addOption(new Option('small', new Money(12.99, $currencies['USD']), new StockItem('T-shirt Size S', new Money(9.99, $currencies['USD']), 15)));
$product->addOption(new Option('medium', new Money(14.99, $currencies['USD']), new StockItem('T-shirt Size M', new Money(11.99, $currencies['USD']), 15)));
$product->addOption(new Option('large', new Money(17.99, $currencies['USD']), new StockItem('T-shirt Size L', new Money(13.99, $currencies['USD']), 15)));
$this->dm->persist($product);
$this->dm->flush();
foreach ($currencies as $currency) {
$this->dm->detach($currency);
}
$this->dm->detach($product);
unset($currencies, $product);
}
示例2: setUp
public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/../../../../Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setDefaultDB('doctrine_odm_tests');
/*
$config->setLoggerCallable(function(array $log) {
print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\');
$this->annotationDriver = new AnnotationDriver($reader, __DIR__ . '/../../../../Documents');
$config->setMetadataDriverImpl($this->annotationDriver);
$conn = new Connection(null, array(), $config);
$this->dm = DocumentManager::create($conn, $config);
$this->uow = $this->dm->getUnitOfWork();
}
示例3: setUp
public function setUp()
{
if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0RC4-DEV', '>=')) {
$this->markTestSkipped('Doctrine common is 2.1.0RC4-DEV version, skipping.');
} else {
if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$reader->setIgnoreNotImportedAnnotations(true);
$reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
$reader->setEnableParsePhpImports(false);
$reader->setAutoloadAnnotations(true);
$reader = new CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
} else {
$reader = new AnnotationReader();
$reader->setAutoloadAnnotations(true);
$reader->setAnnotationNamespaceAlias('Gedmo\\Mapping\\Annotation\\', 'gedmo');
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
}
}
$config = new \Doctrine\ORM\Configuration();
$config->setProxyDir(TESTS_TEMP_DIR);
$config->setProxyNamespace('Gedmo\\Mapping\\Proxy');
$config->setMetadataDriverImpl(new AnnotationDriver($reader));
$conn = array('driver' => 'pdo_sqlite', 'memory' => true);
//$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$evm = new \Doctrine\Common\EventManager();
$this->timestampable = new \Gedmo\Timestampable\TimestampableListener();
$evm->addEventSubscriber($this->timestampable);
$this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
$schemaTool->dropSchema(array());
$schemaTool->createSchema(array($this->em->getClassMetadata(self::ARTICLE)));
}
示例4: loadDriver
static private function loadDriver($namespace)
{
$cache = new ArrayCache();
$reader = new AnnotationReader($cache);
$reader->setDefaultAnnotationNamespace($namespace);
return new AnnotationDriver($reader);
}
示例5: setUp
public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/../../../../../Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__ . '/../../../../../Hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setDefaultDB('doctrine_odm_tests');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$this->dm = DocumentManager::create(new Connection(), $config);
$currencies = array('USD' => 1, 'EURO' => 1.7, 'JPN' => 0.0125);
foreach ($currencies as $name => &$multiplier) {
$multiplier = new Currency($name, $multiplier);
$this->dm->persist($multiplier);
}
$stockItems = array(new StockItem('stock_item_0', new Money(9.99 * 0 + 5, $currencies['USD']), 5), new StockItem('stock_item_1', new Money(9.99 * 1 + 5, $currencies['USD']), 15 * 1 - 4), new StockItem('stock_item_2', new Money(9.99 * 2 + 5, $currencies['USD']), 15 * 2 - 4), new StockItem('stock_item_3', new Money(9.99 * 3 + 5, $currencies['USD']), 15 * 3 - 4), new StockItem('stock_item_4', new Money(9.99 * 4 + 5, $currencies['USD']), 15 * 4 - 4), new StockItem('stock_item_5', new Money(9.99 * 5 + 5, $currencies['USD']), 15 * 5 - 4), new StockItem('stock_item_6', new Money(9.99 * 6 + 5, $currencies['USD']), 15 * 6 - 4), new StockItem('stock_item_7', new Money(9.99 * 7 + 5, $currencies['USD']), 15 * 7 - 4), new StockItem('stock_item_8', new Money(9.99 * 8 + 5, $currencies['USD']), 15 * 8 - 4), new StockItem('stock_item_9', new Money(9.99 * 9 + 5, $currencies['USD']), 15 * 9 - 4));
$options = array(new Option('option_0', new Money(13.99, $currencies['USD']), $stockItems[0]), new Option('option_1', new Money(14.99, $currencies['USD']), $stockItems[1]), new Option('option_2', new Money(15.99, $currencies['USD']), $stockItems[2]), new Option('option_3', new Money(16.99, $currencies['USD']), $stockItems[3]), new Option('option_4', new Money(17.99, $currencies['USD']), $stockItems[4]), new Option('option_5', new Money(18.99, $currencies['USD']), $stockItems[5]), new Option('option_6', new Money(19.99, $currencies['USD']), $stockItems[6]), new Option('option_7', new Money(20.99, $currencies['USD']), $stockItems[7]), new Option('option_8', new Money(21.99, $currencies['USD']), $stockItems[8]), new Option('option_9', new Money(22.99, $currencies['USD']), $stockItems[9]));
$products = array(new ConfigurableProduct('product_0'), new ConfigurableProduct('product_1'), new ConfigurableProduct('product_2'), new ConfigurableProduct('product_3'), new ConfigurableProduct('product_4'), new ConfigurableProduct('product_5'), new ConfigurableProduct('product_6'), new ConfigurableProduct('product_7'), new ConfigurableProduct('product_8'), new ConfigurableProduct('product_9'));
$products[0]->addOption($options[0]);
$products[0]->addOption($options[4]);
$products[0]->addOption($options[6]);
$products[1]->addOption($options[1]);
$products[1]->addOption($options[2]);
$products[1]->addOption($options[5]);
$products[1]->addOption($options[7]);
$products[1]->addOption($options[8]);
$products[2]->addOption($options[3]);
$products[2]->addOption($options[5]);
$products[2]->addOption($options[7]);
$products[2]->addOption($options[9]);
$products[3]->addOption($options[0]);
$products[3]->addOption($options[1]);
$products[3]->addOption($options[2]);
$products[3]->addOption($options[3]);
$products[3]->addOption($options[4]);
$products[3]->addOption($options[5]);
$products[4]->addOption($options[4]);
$products[4]->addOption($options[7]);
$products[4]->addOption($options[2]);
$products[4]->addOption($options[8]);
$products[5]->addOption($options[9]);
$products[6]->addOption($options[7]);
$products[6]->addOption($options[8]);
$products[6]->addOption($options[9]);
$products[7]->addOption($options[4]);
$products[7]->addOption($options[5]);
$products[8]->addOption($options[2]);
$products[9]->addOption($options[4]);
$products[9]->addOption($options[3]);
$products[9]->addOption($options[7]);
foreach ($products as $product) {
$this->dm->persist($product);
}
$this->dm->flush();
$this->dm->clear();
}
示例6: __construct
public function __construct()
{
// Is the config file in the environment folder?
if (!defined('ENVIRONMENT') or !file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php')) {
$file_path = APPPATH . 'config/database.php';
}
// load database configuration from CodeIgniter
require $file_path;
// Set up class loading
require_once APPPATH . 'third_party/doctrine-orm/Doctrine/Common/ClassLoader.php';
$loader = new ClassLoader('Doctrine', APPPATH . 'third_party/doctrine-orm');
$loader->register();
// Set up models loading
$loader = new ClassLoader('models', APPPATH);
$loader->register();
foreach (glob(APPPATH . 'modules/*', GLOB_ONLYDIR) as $m) {
$module = str_replace(APPPATH . 'modules/', '', $m);
$loader = new ClassLoader($module, APPPATH . 'modules');
$loader->register();
}
// Set up proxies loading
$loader = new ClassLoader('Proxies', APPPATH . 'Proxies');
$loader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$reader = new AnnotationReader($cache);
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
// Set up models
$models = array(APPPATH . 'models');
foreach (glob(APPPATH . 'modules/*/models', GLOB_ONLYDIR) as $m) {
array_push($models, $m);
}
$driver = new AnnotationDriver($reader, $models);
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH . '/Proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new EchoSqlLogger;
//$config->setSqlLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connection = array('driver' => 'pdo_mysql', 'user' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'host' => $db[$active_group]['hostname'], 'dbname' => $db[$active_group]['database']);
// Create EntityManager
$this->em = EntityManager::create($connection, $config);
// Force UTF-8
$this->em->getEventManager()->addEventSubscriber(new MysqlSessionInit('utf8', 'utf8_unicode_ci'));
// Schema Tool
$this->tool = new SchemaTool($this->em);
//auto generate entities from database
//$this->generate_entities();
}
示例7: setUp
public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/../../../../../Proxies');
$config->setProxyNamespace('Proxies');
$config->setEnvironment('test');
$config->setDefaultDB($this->defaultDB);
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$this->dm = DocumentManager::create(new Mongo(), $config);
}
示例8: create
public function create()
{
if (!isset($this->options['connection_options'])) {
throw new \Exception("The connection_options configuration setting is not defined.");
}
if (!isset($this->options['metadata']['driver'])) {
throw new \Exception("The metadata.driver configuration setting is not defined.");
}
if (!isset($this->options['metadata']['paths'])) {
throw new \Exception("The metadata.paths configuration setting is not defined.");
}
if (!isset($this->options['directories']['proxies'])) {
throw new \Exception("The directories.proxies configuration setting is not defined.");
}
$config = new Configuration();
// Setup the caches
if (extension_loaded("apc")) {
$cache = new ApcCache();
} else {
$cache = new ArrayCache();
}
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Setup the proxies
$config->setProxyDir(APP_PATH . "/" . $this->options['directories']['proxies']);
$config->setProxyNamespace("Proxies");
$config->setAutoGenerateProxyClasses(isset($this->options['autoGenerateProxies']) && $this->options['autoGenerateProxies']);
// Get the paths from the metadata.paths configuration entry. This can either be a single item (paths: entities), or a
// list of paths (paths: [path1, path2]). The code below deals with both cases, and prepends the APP_PATH to them.
$paths = is_array($this->options['metadata']['paths']) ? $this->options['metadata']['paths'] : array($this->options['metadata']['paths']);
array_walk($paths, function (&$item, $key) {
$item = APP_PATH . DIRECTORY_SEPARATOR . $item;
});
// Set the metadata driver implementation based on the metadata.driver configuration entry. Note that Annotations are
// slightly different to the others implementations so are dealt with seperately.
switch ($this->options['metadata']['driver']) {
case 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver':
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
//$driverImpl = new $this->options['metadata']['driver']($reader, $paths);
$driverImpl = $config->newDefaultAnnotationDriver($paths);
break;
default:
$driverImpl = new $this->options['metadata']['driver']($paths);
break;
}
// Set the metadata driver implementation
$config->setMetadataDriverImpl($driverImpl);
// Finally create and return the EntityManager. If a $connectionOptions variable is set in the registry this takes precedence over
// config.yml, which allows us to override database setting for test suites
return EntityManager::create(Zend_Registry::isRegistered("connectionOptions") ? Zend_Registry::get("connectionOptions") : $this->options['connection_options'], $config);
}
示例9: setUp
public function setUp()
{
parent::setUp();
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$annotationDriver = new AnnotationDriver($reader);
$xmlDriver = new XmlDriver(__DIR__ . '/../Driver/Xml');
$chain = new DriverChain();
$chain->addDriver($annotationDriver, 'Gedmo\\Loggable');
$chain->addDriver($xmlDriver, 'Mapping\\Fixture\\Xml');
$this->loggable = new LoggableListener();
$this->evm = new EventManager();
$this->evm->addEventSubscriber($this->loggable);
$this->em = $this->getMockSqliteEntityManager(array('Gedmo\\Loggable\\Entity\\LogEntry', 'Mapping\\Fixture\\Xml\\Loggable', 'Mapping\\Fixture\\Xml\\Status'), $chain);
}
示例10: setUp
public function setUp()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
/*
$config->setLoggerCallable(function(array $log) {
print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$this->dm = DocumentManager::create(new Mongo(), $config);
}
示例11: createDocumentManager
public function createDocumentManager()
{
$couchDBClient = $this->createCouchDBClient();
$httpClient = $couchDBClient->getHttpClient();
$database = $couchDBClient->getDatabase();
$httpClient->request('DELETE', '/' . $database);
$resp = $httpClient->request('PUT', '/' . $database);
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\');
$paths = __DIR__ . "/../../Models";
$metaDriver = new AnnotationDriver($reader, $paths);
$config = new Configuration();
$config->setProxyDir(\sys_get_temp_dir());
$config->setMetadataDriverImpl($metaDriver);
$setMetadataCacheImpl = $config->setMetadataCacheImpl(new ArrayCache());
$config->setLuceneHandlerName('_fti');
return DocumentManager::create($couchDBClient, $config);
}
示例12: instantiateDocumentManager
/**
* generates the needed document manager
*
* @param string $db
* @return Doctrine\ODM\MongoDB\DocumentManager
*/
private static function instantiateDocumentManager($db = null)
{
if ($db == "stats") {
$db = sfConfig::get("app_mongodb_database_name_stats");
} else {
$db = sfConfig::get("app_mongodb_database_name");
}
$config = new Configuration();
$config->setProxyDir(sfConfig::get('sf_lib_dir') . '/mongo/Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(sfConfig::get('sf_lib_dir') . '/mongo/Hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setDefaultDB($db);
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
return DocumentManager::create(new Connection(sfConfig::get("app_mongodb_host")), $config);
}
示例13: setUp
public function setUp()
{
parent::setUp();
// EM with standard annotation mapping
$this->em1 = $this->getMockSqliteEntityManager(array('Sluggable\\Fixture\\Article'));
// EM with yaml and annotation mapping
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$annotationDriver = new AnnotationDriver($reader);
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$annotationDriver2 = new AnnotationDriver($reader);
$yamlDriver = new YamlDriver(__DIR__ . '/Driver/Yaml');
$chain = new DriverChain();
$chain->addDriver($annotationDriver, 'Translatable\\Fixture');
$chain->addDriver($yamlDriver, 'Mapping\\Fixture\\Yaml');
$chain->addDriver($annotationDriver2, 'Gedmo\\Translatable');
$this->em2 = $this->getMockSqliteEntityManager(array('Translatable\\Fixture\\PersonTranslation', 'Mapping\\Fixture\\Yaml\\User'), $chain);
// DM with standard annotation mapping
$this->dm1 = $this->getMockDocumentManager('gedmo_extensions_test');
}
示例14: ClassLoader
<?php
require_once __DIR__ . '/../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
use Doctrine\Common\ClassLoader, Doctrine\Common\Annotations\AnnotationReader, Doctrine\ODM\MongoDB\Configuration, Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver, Doctrine\MongoDB\Connection, Doctrine\ODM\MongoDB\DocumentManager;
$classLoader = new ClassLoader('Doctrine\\Common', __DIR__ . '/../../lib/vendor/doctrine-common/lib');
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\ODM\\MongoDB', __DIR__ . '/../../lib');
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\MongoDB', __DIR__ . '/../../lib/vendor/doctrine-mongodb/lib');
$classLoader->register();
$classLoader = new ClassLoader('Symfony', __DIR__ . '/../../lib/vendor');
$classLoader->register();
$classLoader = new ClassLoader('Documents', __DIR__);
$classLoader->register();
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__ . '/Hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setDefaultDB('doctrine_odm_sandbox');
/*
$config->setLoggerCallable(function(array $log) {
print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
$dm = DocumentManager::create(new Connection(), $config);
示例15: getDocumentManager
protected function getDocumentManager()
{
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/../../../../Proxies');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
$config->setHydratorNamespace('Hydrators');
$config->setDefaultDB('doctrine_odm_tests');
/*
$config->setLoggerCallable(function(array $log) {
print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
return DocumentManager::create($this->getConnection(), $config);
}