本文整理汇总了PHP中Doctrine\ORM\EntityManager::getReference方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getReference方法的具体用法?PHP EntityManager::getReference怎么用?PHP EntityManager::getReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityManager
的用法示例。
在下文中一共展示了EntityManager::getReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postFlush
/**
* @param PostFlushEventArgs $args
*/
public function postFlush(PostFlushEventArgs $args)
{
if ($this->isInProgress) {
return;
}
$this->initializeFromEventArgs($args);
if (count($this->queued) > 0) {
$toOutDate = [];
foreach ($this->queued as $customerIdentity => $groupedByEntityUpdates) {
foreach ($groupedByEntityUpdates as $data) {
/** @var Account $account */
$account = is_object($data['account']) ? $data['account'] : $this->em->getReference('OroCRMAccountBundle:Account', $data['account']);
/** @var Channel $channel */
$channel = is_object($data['channel']) ? $data['channel'] : $this->em->getReference('OroCRMChannelBundle:Channel', $data['channel']);
$entity = $this->createHistoryEntry($customerIdentity, $account, $channel);
$toOutDate[] = [$account, $channel, $entity];
$this->em->persist($entity);
}
}
$this->isInProgress = true;
$this->em->flush();
foreach (array_chunk($toOutDate, self::MAX_UPDATE_CHUNK_SIZE) as $chunks) {
$this->lifetimeRepo->massStatusUpdate($chunks);
}
$this->queued = [];
$this->isInProgress = false;
}
}
示例2: unpack
/**
* {@inheritdoc}
*/
public function unpack($object)
{
if ($object instanceof ObjectSignature) {
return $this->em->getReference($object->getClass(), $object->getIdentity());
}
return null;
}
示例3: fillChannelToEntity
/**
* @param Channel $channel
* @param string $entity
*
* @throws \Exception
*/
protected function fillChannelToEntity(Channel $channel, $entity)
{
$interfaces = class_implements($entity) ?: [];
if (!in_array('OroCRM\\Bundle\\ChannelBundle\\Model\\ChannelAwareInterface', $interfaces)) {
return;
}
/** @var QueryBuilder $qb */
$qb = $this->em->getRepository($entity)->createQueryBuilder('e');
$iterator = new BufferedQueryResultIterator($qb);
$writeCount = 0;
$toWrite = [];
try {
$this->em->beginTransaction();
/** @var ChannelAwareInterface $data */
foreach ($iterator as $data) {
$writeCount++;
if (!$data->getDataChannel()) {
$channelReference = $this->em->getReference(ClassUtils::getClass($channel), $channel->getId());
$data->setDataChannel($channelReference);
$toWrite[] = $data;
}
if (0 === $writeCount % static::BATCH_SIZE) {
$this->write($toWrite);
$toWrite = [];
}
}
if (count($toWrite) > 0) {
$this->write($toWrite);
}
$this->em->commit();
} catch (\Exception $exception) {
$this->em->rollback();
throw $exception;
}
}
示例4: excluir
/**
* @param $id
* @return integer
*/
public function excluir($id)
{
$entity = $this->em->getReference('Admin\\Domain\\Entity\\OtherEntity', (int) $id);
$this->em->remove($entity);
$this->em->flush();
return (int) $id;
}
示例5: addPushMessage
/**
* @param Notification $notification
* @param int $userId
*/
protected function addPushMessage(Notification $notification, $userId)
{
$pushMessage = new PushMessage();
$pushMessage->setNotification($notification);
$pushMessage->setUser($this->entityManager->getReference(User::CLASS_NAME, $userId));
$notification->addPushMessage($pushMessage);
}
示例6: getRegionReference
/**
* @param string $countryCode ISO2 code
* @param string $code region code
*
* @return null|Region
*/
protected function getRegionReference($countryCode, $code)
{
if (null === $this->regionByCountryMap) {
$this->regionByCountryMap = $this->loadRegionByCountryMap();
}
return isset($this->regionByCountryMap[$countryCode], $this->regionByCountryMap[$countryCode][$code]) ? $this->em->getReference('OroAddressBundle:Region', $this->regionByCountryMap[$countryCode][$code]) : null;
}
示例7: deleteAction
/**
* @param Request $request
* @return RedirectResponse
* @throws \Doctrine\ORM\ORMException
*/
public function deleteAction(Request $request)
{
$invoiceId = $request->get('invoiceId');
$invoiceReference = $this->entityManager->getReference('Invoicity\\Business\\Entity\\Invoice', $invoiceId);
$this->entityManager->remove($invoiceReference);
$this->entityManager->flush();
return new RedirectResponse($this->router->generate('invoicity_invoice_index'));
}
示例8: update
public function update(array $data)
{
$entity = $this->em->getReference('Advocacia\\Entity\\Cadastro', $data['id']);
$entity = Configurator::configure($entity, $data);
$this->em->persist($entity);
$this->em->flush();
return $entity;
}
示例9: delete
public function delete($id) {
$cod_cli = $id;
$entity = $this->em->getReference ( 'Pc_help\Entity\Cliente', $cod_cli );
if ($entity) {
$this->em->remove ( $entity );
$this->em->flush ();
return $id;
}
}
示例10: delete
public function delete($id)
{
$entity = $this->em->getReference($this->entity, $id);
if ($entity) {
$this->em->remove($entity);
$this->em->flush();
return $id;
}
}
示例11: insert
public function insert(array $data) {
$entity = new solucaoService ( $data );
$problema = $this->em->getReference ( "Pc_help\Entity\Problema", $data ['id'] );
$entity->setProblema ( $problema );
$this->em->persist ( $entity );
$this->em->flush ();
return $entity;
}
示例12: insertMessage
/**
* Insert un message de team en base
*
* @param User $user
* @param integer $teamId
* @param string $message
*
* @author Benjamin Levoir <ben@levoir.fr>
*/
public function insertMessage(User $user, $teamId, $message)
{
$m = new \CoreBundle\Entity\TeamMessage();
$m->setContent($message);
$m->setSender($this->em->getReference('CoreBundle:User', $user->getId()));
$m->setTeam($this->em->getReference('CoreBundle:Team', $teamId));
$this->em->persist($m);
$this->em->flush();
return $this;
}
示例13: addPushMessage
/**
* @param Notification $notification
* @param int $userId
*/
protected function addPushMessage(Notification $notification, $userId)
{
if ($this->frequencyFilter->filter($userId)) {
return;
}
$this->frequencyFilter->addPushedUser($userId);
$pushMessage = new PushMessage();
$pushMessage->setNotification($notification);
$pushMessage->setUser($this->entityManager->getReference(User::CLASS_NAME, $userId));
$notification->addPushMessage($pushMessage);
}
示例14: insert
public function insert(array $data) {
$maquina = new clienteService ( $data );
$cliente = $this->em->getReference ( "Pc_help\Entity\Cliente", $data ['id'] );
$maquina->setCliente ( $cliente );
$this->em->persist ( $maquina );
$this->em->flush ();
return $maquina;
}
示例15: update
public function update(array $data) {
// find
// da set automaticamnete
$entity = $this->em->getReference ( 'Pc_help\Entity\Problema', $data ['id'] );
$entity = Configurator::configure ( $entity, $data );
$this->em->persist ( $entity );
$this->em->flush ();
return $entity;
}