本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::getClassMetaData方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::getClassMetaData方法的具体用法?PHP ObjectManager::getClassMetaData怎么用?PHP ObjectManager::getClassMetaData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::getClassMetaData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new Country()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$i = 1;
$file = dirname(__FILE__) . '/../countries.xml';
$doc = new \DOMDocument();
$doc->load($file);
$xpath = new \DOMXpath($doc);
$elements = $xpath->query('/Countries/Country');
if (!is_null($elements)) {
/** @var $element DOMNode */
foreach ($elements as $element) {
$country = new Country();
$country->setId($i);
$children = $element->childNodes;
/** @var $child DOMNode */
foreach ($children as $child) {
if (isset($child->nodeName)) {
if ($child->nodeName == 'Name') {
$country->setName($child->nodeValue);
}
if ($child->nodeName == 'Code') {
$country->setCode($child->nodeValue);
}
}
}
$manager->persist($country);
++$i;
}
}
$manager->flush();
}
示例2: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$class = new \ReflectionClass('SDLab\\Bundle\\SmartUtilsBundle\\Test\\Entity\\LevelB');
$propertyId = $class->getProperty('id');
$propertyId->setAccessible(true);
$metadata = $manager->getClassMetaData("SDLab\\Bundle\\SmartUtilsBundle\\Test\\Entity\\LevelB");
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$levelB1 = new \SDLab\Bundle\SmartUtilsBundle\Test\Entity\LevelB();
$propertyId->setValue($levelB1, 1);
$levelB1->setName('Test AA');
$levelB1->setParent($this->getReference('LevelA-1'));
$manager->persist($levelB1);
$levelB2 = new \SDLab\Bundle\SmartUtilsBundle\Test\Entity\LevelB();
$propertyId->setValue($levelB2, 2);
$levelB2->setName('Test AB');
$levelB2->setParent($this->getReference('LevelA-1'));
$manager->persist($levelB2);
$levelB3 = new \SDLab\Bundle\SmartUtilsBundle\Test\Entity\LevelB();
$propertyId->setValue($levelB3, 3);
$levelB3->setName('Test BA');
$levelB3->setParent($this->getReference('LevelA-2'));
$manager->persist($levelB3);
$manager->flush();
$this->addReference('LevelB-1', $levelB1);
$this->addReference('LevelB-2', $levelB2);
$this->addReference('LevelB-3', $levelB3);
}
示例3: load
public function load(ObjectManager $manager)
{
$sql = 'select id, cuenta_id, fecha, monto from cobro order by cuenta_id';
$username = DataFixturesConstants::DBUSER;
$password = DataFixturesConstants::DBPASS;
$database = DataFixturesConstants::DBSCHEMA;
return;
$conn = new \PDO(sprintf('mysql:host=localhost;dbname=%s', $database), $username, $password, array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
$stmt = $conn->prepare($sql);
$stmt->execute();
$metadata = $manager->getClassMetaData(get_class(new Cobro()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$cuenta = null;
$cuentaId = null;
while ($row = $stmt->fetch()) {
// Adding cobro
$cobro = new Cobro();
$cobro->setId($row['id']);
$fecha = $row['fecha'];
if ($fecha) {
$cobro->setFecha(new \DateTime($fecha));
}
$cobro->setMonto($row['monto']);
if ($cuentaId != $row['cuenta_id']) {
$cuenta = $manager->getRepository('AppBundle:Cuenta')->find($row['cuenta_id']);
}
$cobro->setCuenta($cuenta);
$manager->persist($cobro);
}
$manager->flush();
}
示例4: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$active = new Organizationstatus();
$inactive = new Organizationstatus();
$active->setName('Active');
$inactive->setName('Inactive');
$active->setId(1);
$inactive->setId(2);
$metadata = $manager->getClassMetaData(get_class($active));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$metadata = $manager->getClassMetaData(get_class($inactive));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$manager->persist($active);
$manager->persist($inactive);
$manager->flush();
}
示例5: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new OrderType()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
// manual
$type = new OrderType();
$type->setId(OrderType::MANUAL);
$this->createTypeTranslation($manager, $type, 'Manual', 'en');
$this->createTypeTranslation($manager, $type, 'Manuell', 'de');
$this->createTypeTranslation($manager, $type, 'Manuell', 'de_ch');
$manager->persist($type);
// shop
$type = new OrderType();
$type->setId(OrderType::SHOP);
$this->createTypeTranslation($manager, $type, 'Shop order', 'en');
$this->createTypeTranslation($manager, $type, 'Shopbestellung', 'de');
$this->createTypeTranslation($manager, $type, 'Shopbestellung', 'de_ch');
$manager->persist($type);
// anonymous
$type = new OrderType();
$type->setId(OrderType::ANONYMOUS);
$this->createTypeTranslation($manager, $type, 'Anonymous order', 'en');
$this->createTypeTranslation($manager, $type, 'Anonyme Bestellung', 'de');
$this->createTypeTranslation($manager, $type, 'Anonyme Bestellung', 'de_ch');
$manager->persist($type);
$manager->flush();
}
示例6: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$manager->getClassMetaData(get_class(new Game()))->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$item1 = new Game();
$item1->setId(1);
$item1->setWord("advantageous");
$item1->setGuessedLetters(unserialize('a:1:{i:0;s:1:"a";}'));
$item1->setTriedLetters(unserialize('a:1:{i:0;s:1:"a";}'));
$item1->setTriesLeft();
$item1->setDottedWord();
$item1->setStatus();
$manager->persist($item1);
$item2 = new Game();
$item2->setId(2);
$item2->setWord("ab");
$item2->setGuessedLetters(unserialize('a:2:{i:0;s:1:"a";i:1;s:1:"b";}'));
$item2->setTriedLetters(unserialize('a:2:{i:0;s:1:"a";i:1;s:1:"b";}'));
$item2->setTriesLeft();
$item2->setDottedWord();
$item2->setStatus();
$manager->persist($item2);
$manager->persist($item2);
$item3 = new Game();
$item3->setId(3);
$item3->setWord("aardvarks");
$item3->setGuessedLetters(unserialize('a:0:{}'));
$item3->setTriedLetters(unserialize('a:0:{}'));
$item3->setTriesLeft();
$item3->setDottedWord();
$item3->setStatus();
$manager->persist($item3);
$manager->flush();
}
示例7: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new SecurityType()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$file = $this->container->getParameter('sulu_security.security_types.fixture');
$doc = new \DOMDocument();
$doc->load($file);
$xpath = new \DOMXpath($doc);
$elements = $xpath->query('/security-types/security-type');
if (!is_null($elements)) {
/** @var $element \DOMNode */
foreach ($elements as $element) {
$securityType = new SecurityType();
$children = $element->childNodes;
/** @var $child \DOMNode */
foreach ($children as $child) {
if (isset($child->nodeName)) {
if ($child->nodeName == 'id') {
$securityType->setId($child->nodeValue);
}
if ($child->nodeName == 'name') {
$securityType->setName($child->nodeValue);
}
}
}
$manager->persist($securityType);
}
}
$manager->flush();
}
示例8: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$metadata = $manager->getClassMetaData(get_class(new Operator()));
$metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$i = 1;
$file = dirname(__FILE__) . '/../../operators.xml';
$doc = new \DOMDocument();
$doc->load($file);
$xpath = new \DOMXpath($doc);
$elements = $xpath->query('/operators/operator');
if (!is_null($elements)) {
/** @var $element DOMNode */
foreach ($elements as $element) {
$operator = new Operator();
$operator->setId($i);
$operator->setType($this->getTypeForString($element->getAttribute('type')));
$operator->setOperator($element->getAttribute('operator'));
$operator->setInputType($element->getAttribute('inputType'));
// translations
$translations = $xpath->query('translations/translation', $element);
$this->processTranslations($manager, $operator, $translations);
// values
$values = $xpath->query('values/value', $element);
$this->processValues($manager, $xpath, $operator, $values);
$manager->persist($operator);
++$i;
}
}
$manager->flush();
}
示例9: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new OrderStatus()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
// created
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_CREATED);
$this->createStatusTranslation($manager, $status, 'Created', 'en');
$this->createStatusTranslation($manager, $status, 'Erfasst', 'de');
$this->createStatusTranslation($manager, $status, 'Erfasst', 'de_ch');
$manager->persist($status);
// cart
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_IN_CART);
$this->createStatusTranslation($manager, $status, 'In Cart', 'en');
$this->createStatusTranslation($manager, $status, 'Im Warenkorb', 'de');
$this->createStatusTranslation($manager, $status, 'Im Warenkorb', 'de_ch');
$manager->persist($status);
// confirmed
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_CONFIRMED);
$this->createStatusTranslation($manager, $status, 'Order confirmed', 'en');
$this->createStatusTranslation($manager, $status, 'Bestätigt', 'de');
$this->createStatusTranslation($manager, $status, 'Bestätigt', 'de_ch');
$manager->persist($status);
// confirmed
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_CLOSED_MANUALLY);
$this->createStatusTranslation($manager, $status, 'Manually closed', 'en');
$this->createStatusTranslation($manager, $status, 'Manuell geschlossen', 'de');
$this->createStatusTranslation($manager, $status, 'Manuell geschlossen', 'de_ch');
$manager->persist($status);
// canceled
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_CANCELED);
$this->createStatusTranslation($manager, $status, 'Canceled', 'en');
$this->createStatusTranslation($manager, $status, 'Abgebrochen', 'de');
$this->createStatusTranslation($manager, $status, 'Abgebrochen', 'de_ch');
$manager->persist($status);
// canceled
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_COMPLETED);
$this->createStatusTranslation($manager, $status, 'Completed', 'en');
$this->createStatusTranslation($manager, $status, 'Abgeschlossen', 'de');
$this->createStatusTranslation($manager, $status, 'Abgeschlossen', 'de_ch');
$manager->persist($status);
// canceled
$status = new OrderStatus();
$status->setId(OrderStatus::STATUS_CART_PENDING);
$this->createStatusTranslation($manager, $status, 'Cart order pending', 'en');
$this->createStatusTranslation($manager, $status, 'Warenkorb in Bearbeitung', 'de');
$this->createStatusTranslation($manager, $status, 'Warenkorb in Bearbeitung', 'de_ch');
$manager->persist($status);
$manager->flush();
}
示例10: load
/**
* Load
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$metadata = $manager->getClassMetaData('Unifik\\SystemBundle\\Entity\\Navigation');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$sectionBar = new Navigation();
$sectionBar->setId(1);
$sectionBar->setCode('_section_bar');
$sectionBar->setName('Sections bar');
$sectionBar->setApp($manager->merge($this->getReference('app-backend')));
$sectionModuleBar = new Navigation();
$sectionModuleBar->setId(2);
$sectionModuleBar->setCode('_section_module_bar');
$sectionModuleBar->setName('Section modules');
$sectionModuleBar->setApp($manager->merge($this->getReference('app-backend')));
$globalModuleBar = new Navigation();
$globalModuleBar->setId(3);
$globalModuleBar->setCode('_global_module_bar');
$globalModuleBar->setName('Global modules');
$globalModuleBar->setApp($manager->merge($this->getReference('app-backend')));
$globalApp = new Navigation();
$globalApp->setId(4);
$globalApp->setCode('_app_module_bar');
$globalApp->setName('Application modules');
$globalApp->setApp($manager->merge($this->getReference('app-backend')));
$manager->persist($sectionBar);
$manager->persist($sectionModuleBar);
$manager->persist($globalModuleBar);
$manager->persist($globalApp);
$this->addReference('navigation-section-bar', $sectionBar);
$this->addReference('navigation-section-modules-bar', $sectionModuleBar);
$this->addReference('navigation-global-module-bar', $globalModuleBar);
$this->addReference('navigation-app-module-bar', $globalApp);
// Frontend navigations
$primary = new Navigation();
$primary->setId(5);
$primary->setCode('primary');
$primary->setName('Primary');
$primary->setApp($manager->merge($this->getReference('app-frontend')));
$secondary = new Navigation();
$secondary->setId(6);
$secondary->setCode('secondary');
$secondary->setName('Secondary');
$secondary->setApp($manager->merge($this->getReference('app-frontend')));
$footer = new Navigation();
$footer->setId(7);
$footer->setCode('footer');
$footer->setName('Footer');
$footer->setApp($manager->merge($this->getReference('app-frontend')));
$manager->persist($primary);
$manager->persist($secondary);
$manager->persist($footer);
$this->addReference('navigation-frontend-primary', $primary);
$this->addReference('navigation-frontend-secondary', $secondary);
$this->addReference('navigation-frontend-footer', $footer);
$manager->flush();
}
示例11: loadFaction
private function loadFaction(ObjectManager $manager)
{
$faction = new Faction();
$faction->fromArray(['id' => '3', 'name' => 'Fake Faction', 'type' => Faction::TYPE_FAKE]);
$manager->persist($faction);
$metadata = $manager->getClassMetaData(get_class($faction));
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$manager->flush();
return $faction;
}
开发者ID:mcg-web,项目名称:graphql-symfony-doctrine-sandbox,代码行数:10,代码来源:LoadFakeFactionWithManyShipsData.php
示例12: load
public function load(ObjectManager $manager)
{
$org = new Organization();
$org->setId(1);
$org->setTitle('TSK');
$manager->persist($org);
$metadata = $manager->getClassMetaData(get_class($org));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$manager->flush();
$this->addReference('tsk-org', $org);
$org = new Organization();
$org->setId(2);
$org->setTitle('MJH');
$manager->persist($org);
$metadata = $manager->getClassMetaData(get_class($org));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$manager->flush();
$this->addReference('mjh-org', $org);
}
示例13: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$english = new Language();
$nederlands = new Language();
$english->setName('English');
$nederlands->setName('Nederlands');
$english->setLocaleabr('en');
$nederlands->setLocaleabr('nl');
$english->setId(1);
$nederlands->setId(2);
$metadata = $manager->getClassMetaData(get_class($english));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$metadata = $manager->getClassMetaData(get_class($nederlands));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$manager->persist($english);
$manager->persist($nederlands);
$manager->flush();
$this->addReference('english', $english);
$this->addReference('nederlands', $nederlands);
}
示例14: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$organization = new Organization();
$organization->setId(1);
$organization->setName('Samsung');
$metadata = $manager->getClassMetaData(get_class($organization));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$manager->persist($organization);
$manager->flush();
$this->addReference('organization', $organization);
}
示例15: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
// force id = 1
$metadata = $manager->getClassMetaData(CollectionType::class);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
$defaultCollectionType = $this->createCollectionType(1, 'collection.default', 'Default');
$manager->persist($defaultCollectionType);
$systemCollectionType = $this->createCollectionType(2, 'collection.system', 'System Collections');
$manager->persist($systemCollectionType);
$manager->flush();
}