本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::getReference方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::getReference方法的具体用法?PHP ObjectManager::getReference怎么用?PHP ObjectManager::getReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::getReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reverseTransform
/**
* (non-PHPdoc)
* @see \Symfony\Component\Form\DataTransformerInterface::reverseTransform()
*/
public function reverseTransform($value)
{
if (null === $value || '' === $value) {
return null;
}
return $this->om->getReference($this->class, $value);
}
示例2: load
public function load(ObjectManager $manager)
{
$role = new Role();
$role->setNome('visitante');
$manager->persist($role);
$visitante = $manager->getReference('SONAcl\\Entity\\Role', 1);
$role = new Role();
$role->setNome('registrado');
$role->setParent($visitante);
$manager->persist($role);
$registrado = $manager->getReference('SONAcl\\Entity\\Role', 2);
$role = new Role();
$role->setNome('redator');
$role->setParent($registrado);
$manager->persist($role);
$redator = $manager->getReference('SONAcl\\Entity\\Role', 3);
$role = new Role();
$role->setNome('editor');
$role->setParent($redator);
$manager->persist($role);
$editor = $manager->getReference('SONAcl\\Entity\\Role', 4);
$role = new Role();
$role->setNome('admin');
$role->setIsAdmin(true);
$role->setParent($editor);
$manager->persist($role);
$manager->flush();
}
示例3: getResourceProxy
/**
* {@inheritdoc}
*/
public function getResourceProxy($className, $identifier)
{
if ($this->objectManager instanceof EntityManagerInterface) {
return $this->objectManager->getReference($className, $identifier);
}
return $this->getResource($className, $identifier);
}
示例4: load
/**
* @param ObjectManager|EntityManager $manager
*/
public function load(ObjectManager $manager)
{
$settingsProvider = $this->container->get('orocrm_channel.provider.settings_provider');
$lifetimeSettings = $settingsProvider->getLifetimeValueSettings();
if (!array_key_exists(ChannelType::TYPE, $lifetimeSettings)) {
return;
}
$magentoChannelSettings = $lifetimeSettings[ChannelType::TYPE];
$customerIdentityClass = $magentoChannelSettings['entity'];
$lifetimeField = $magentoChannelSettings['field'];
$accountClass = $this->container->getParameter('orocrm_account.account.entity.class');
$channelClass = $this->container->getParameter('orocrm_channel.entity.class');
/** @var LifetimeHistoryRepository $lifetimeRepo */
$lifetimeRepo = $manager->getRepository('OroCRMChannelBundle:LifetimeValueHistory');
$brokenAccountQb = $this->getBrokenAccountsQueryBuilder($customerIdentityClass, $lifetimeField, $lifetimeRepo);
$brokenAccountsData = new BufferedQueryResultIterator($brokenAccountQb);
$toOutDate = [];
foreach ($brokenAccountsData as $brokenDataRow) {
/** @var Account $account */
$account = $manager->getReference($accountClass, $brokenDataRow['account_id']);
/** @var Channel $channel */
$channel = $manager->getReference($channelClass, $brokenDataRow['channel_id']);
$lifetimeAmount = $lifetimeRepo->calculateAccountLifetime($customerIdentityClass, $lifetimeField, $account, $channel);
$history = new LifetimeValueHistory();
$history->setAmount($lifetimeAmount);
$history->setDataChannel($channel);
$history->setAccount($account);
$manager->persist($history);
$toOutDate[] = [$account, $channel, $history];
}
$manager->flush();
foreach (array_chunk($toOutDate, self::MAX_UPDATE_CHUNK_SIZE) as $chunks) {
$lifetimeRepo->massStatusUpdate($chunks);
}
}
示例5: load
public function load(ObjectManager $manager)
{
$dev = $manager->getReference('Zf2User\\Entity\\User', 1);
$admin = $manager->getReference('Zf2User\\Entity\\User', 2);
$boot = $manager->getReference('Zf2User\\Entity\\User', 3);
$perfil = new Perfil();
$perfil->setUser($dev)->setName("Developer")->setDateBirth("14-05-1992");
$manager->persist($perfil);
$perfil = new Perfil();
$perfil->setUser($admin)->setName("Administrator")->setDateBirth("14-05-1992");
$manager->persist($perfil);
$perfil = new Perfil();
$perfil->setUser($boot)->setName("Boot Functionary")->setDateBirth("14-05-1992");
$manager->persist($perfil);
$manager->flush();
}
示例6: handleAssociations
/**
* Add associations to call item
*
* @param Call $entity
*/
protected function handleAssociations(Call $entity)
{
$associationsFormField = $this->form->get('associations');
if (!$associationsFormField) {
return;
}
$associations = $associationsFormField->getData();
if (empty($associations)) {
return;
}
foreach ($associations as $association) {
$associationType = isset($association['type']) ? $association['type'] : null;
$target = $this->manager->getReference($association['entityName'], $association['entityId']);
call_user_func([$entity, AssociationNameGenerator::generateAddTargetMethodName($associationType)], $target);
}
}
示例7: load
public function load(ObjectManager $manager)
{
/** @var EntityManager $manager */
$this->customerRepository = $manager->getRepository('OroCRMMagentoBundle:Customer');
// Calculate lifetime value for all customers
$queryBuilder = $this->customerRepository->createQueryBuilder('customer');
$queryBuilder->select('SUM(
CASE WHEN customerOrder.subtotalAmount IS NOT NULL THEN customerOrder.subtotalAmount ELSE 0 END -
CASE WHEN customerOrder.discountAmount IS NOT NULL THEN ABS(customerOrder.discountAmount) ELSE 0 END
) AS lifetime', 'customer.id as customerId', 'customer.lifetime AS oldLifetime', 'IDENTITY(customer.dataChannel) as dataChannelId')->leftJoin('customer.orders', 'customerOrder', 'WITH', $queryBuilder->expr()->neq($queryBuilder->expr()->lower('customerOrder.status'), ':status'))->groupBy('customer.account, customer.id')->orderBy('customer.account')->setParameter('status', Order::STATUS_CANCELED);
// Get lifetime value only for customers that have canceled orders
$this->addFilterByOrderStatus($queryBuilder, Order::STATUS_CANCELED);
$iterator = new BufferedQueryResultIterator($queryBuilder);
$iterator->setBufferSize(self::BUFFER_SIZE);
$channels = [];
foreach ($iterator as $row) {
if ($row['lifetime'] == $row['oldLifetime']) {
continue;
}
$this->updateCustomerLifetimeValue($row['customerId'], $row['lifetime']);
if (!isset($channels[$row['dataChannelId']])) {
$channels[$row['dataChannelId']] = $row['dataChannelId'];
}
}
foreach ($channels as $channelId) {
/** @var Channel $channel */
$channel = $manager->getReference('OroCRMChannelBundle:Channel', $channelId);
$this->updateLifetimeForAccounts($channel);
}
}
示例8: createOrderAddress
/**
* @param ObjectManager $manager
* @param string $name
* @param array $address
* @return OrderAddress
*/
protected function createOrderAddress(ObjectManager $manager, $name, array $address)
{
/** @var Country $country */
$country = $manager->getReference('OroAddressBundle:Country', $address['country']);
if (!$country) {
throw new \RuntimeException('Can\'t find country with ISO ' . $address['country']);
}
/** @var Region $region */
$region = $manager->getReference('OroAddressBundle:Region', $address['region']);
if (!$region) {
throw new \RuntimeException(sprintf('Can\'t find region with code %s', $address['country']));
}
$orderAddress = new OrderAddress();
$orderAddress->setCountry($country)->setCity($address['city'])->setRegion($region)->setStreet($address['street'])->setPostalCode($address['postalCode']);
$manager->persist($orderAddress);
$this->addReference($name, $orderAddress);
return $orderAddress;
}
示例9: load
public function load(ObjectManager $manager)
{
$role = new Role();
$role->setNome('Visitante');
$manager->persist($role);
$visitante = $manager->getReference('EOSAcl\\Entity\\Role', 1);
$role = new Role();
$role->setNome('Registrado')->setParent($visitante);
$manager->persist($role);
$registrado = $manager->getReference('EOSAcl\\Entity\\Role', 2);
$role = new Role();
$role->setNome('Redator')->setParent($registrado);
$manager->persist($role);
$role = new Role();
$role->setNome('Admin')->setIsAdmin(TRUE);
$manager->persist($role);
$manager->flush();
}
示例10: load
public function load(ObjectManager $manager)
{
$visit = $manager->getReference('Zf2Acl\\Entity\\Role', 1);
$client = $manager->getReference('Zf2Acl\\Entity\\Role', 2);
$functionary = $manager->getReference('Zf2Acl\\Entity\\Role', 3);
$admin = $manager->getReference('Zf2Acl\\Entity\\Role', 4);
$developer = $manager->getReference('Zf2Acl\\Entity\\Role', 5);
$user = new User();
$user->setEmail("jhon@developer.com.br")->setUsername("developer")->setPassword(123456)->setPasswordClue('123456')->setStatus(true)->setRole($developer);
$manager->persist($user);
$user = new User();
$user->setEmail("admin@admin.com.br")->setUsername("admin")->setPassword(123456)->setPasswordClue('123456')->setStatus(true)->setRole($admin);
$manager->persist($user);
$user = new User();
$user->setEmail("boo1@teste.com.br")->setUsername("functionary")->setPassword(123456)->setPasswordClue('123456')->setStatus(true)->setRole($functionary);
$manager->persist($user);
$manager->flush();
}
示例11: load
public function load(ObjectManager $manager)
{
$role = new Role();
$role->setNome("Visitante");
$manager->persist($role);
$visitante = $manager->getReference('SONAcl\\Entity\\Role', 1);
$role = new Role();
$role->setNome("Registrado")->setParent($visitante);
$manager->persist($role);
$registrado = $manager->getReference('SONAcl\\Entity\\Role', 2);
$role = new Role();
$role->setNome("Redator")->setParent($registrado);
$manager->persist($role);
$role = new Role();
$role->setNome("Admin")->setIsAdmin(true);
$manager->persist($role);
$manager->flush();
}
示例12: load
public function load(ObjectManager $manager)
{
$role = new Role();
$role->setName("Visit");
$manager->persist($role);
$visit = $manager->getReference('Zf2Acl\\Entity\\Role', 1);
$role = new Role();
$role->setName("Client")->setParent($visit)->setRedirect("dashboard");
$manager->persist($role);
$role = new Role();
$role->setName("Functionary")->setParent($visit)->setRedirect("dashboard");
$manager->persist($role);
$functionary = $manager->getReference('Zf2Acl\\Entity\\Role', 3);
$role = new Role();
$role->setName("Administrator")->setParent($functionary)->setRedirect("dashboard");
$manager->persist($role);
$role = new Role();
$role->setName("Developer")->setDeveloper(1)->setRedirect("dashboard");
$manager->persist($role);
$manager->flush();
}
示例13: getReference
/**
* Loads an object using stored reference
* named by $name
*
* @param string $name
* @return object
*/
public function getReference($name)
{
$reference = $this->references[$name];
$meta = $this->manager->getClassMetadata(get_class($reference));
$uow = $this->manager->getUnitOfWork();
if (!$uow->isInIdentityMap($reference) && isset($this->identities[$name])) {
$reference = $this->manager->getReference($meta->name, $this->identities[$name]);
$this->references[$name] = $reference;
// allready in identity map
}
return $reference;
}
示例14: getReference
/**
* Loads an object using stored reference
* named by $name
*
* @param string $name
* @throws OutOfBoundsException - if repository does not exist
* @return object
*/
public function getReference($name)
{
if (!$this->hasReference($name)) {
throw new \OutOfBoundsException("Reference to: ({$name}) does not exist");
}
$reference = $this->references[$name];
$meta = $this->manager->getClassMetadata(get_class($reference));
if (!$this->manager->contains($reference) && isset($this->identities[$name])) {
$reference = $this->manager->getReference($meta->name, $this->identities[$name]);
$this->references[$name] = $reference;
// already in identity map
}
return $reference;
}
示例15: getObjectByIdentifier
/**
* Returns the object with the (internal) identifier, if it is known to the
* backend. Otherwise NULL is returned.
*
* @param mixed $identifier
* @param string $objectType
* @param boolean $useLazyLoading Set to TRUE if you want to use lazy loading for this object
* @return object The object for the identifier if it is known, or NULL
* @throws \RuntimeException
* @api
*/
public function getObjectByIdentifier($identifier, $objectType = null, $useLazyLoading = false)
{
if ($objectType === null) {
throw new \RuntimeException('Using only the identifier is not supported by Doctrine 2. Give classname as well or use repository to query identifier.', 1296646103);
}
if (isset($this->newObjects[$identifier])) {
return $this->newObjects[$identifier];
}
if ($useLazyLoading === true) {
return $this->entityManager->getReference($objectType, $identifier);
} else {
return $this->entityManager->find($objectType, $identifier);
}
}