本文整理匯總了PHP中Symfony\Bridge\Doctrine\RegistryInterface::flush方法的典型用法代碼示例。如果您正苦於以下問題:PHP RegistryInterface::flush方法的具體用法?PHP RegistryInterface::flush怎麽用?PHP RegistryInterface::flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Bridge\Doctrine\RegistryInterface
的用法示例。
在下文中一共展示了RegistryInterface::flush方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onSuccess
/**
* "Success" form handler
*
* @param Cart $entity
*/
protected function onSuccess(Cart $entity)
{
$count = 0;
/** @var CartItem $item */
foreach ($entity->getCartItems() as $item) {
$item->setCart($entity);
++$count;
}
$entity->setItemsCount($count);
if (null === $entity->getOrganization()) {
$entity->setOrganization($this->organization);
}
if ($entity->getShippingAddress() instanceof AbstractAddress && null === $entity->getShippingAddress()->getOrganization()) {
$entity->getShippingAddress()->setOrganization($this->organization);
}
if ($entity->getBillingAddress() instanceof AbstractAddress && null === $entity->getBillingAddress()->getOrganization()) {
$entity->getBillingAddress()->setOrganization($this->organization);
}
$this->manager->persist($entity);
$this->manager->flush();
}
示例2: onSuccess
/**
* "Success" form handler
*
* @param Order $entity
*/
protected function onSuccess(Order $entity)
{
if (null === $entity->getOrganization()) {
$entity->setOrganization($this->organization);
}
/** @var OrderAddress $address */
foreach ($entity->getAddresses() as $address) {
if (null === $address->getOwner()) {
$address->setOwner($entity);
}
if (null === $address->getOrganization()) {
$address->setOrganization($this->organization);
}
}
/** @var OrderItem $item */
foreach ($entity->getItems() as $item) {
if (null === $item->getOrder()) {
$item->setOrder($entity);
}
}
$this->manager->persist($entity);
$this->manager->flush();
}
示例3: onSuccess
/**
* "Success" form handler
*
* @param CartItem $entity
*/
protected function onSuccess(CartItem $entity)
{
$this->manager->persist($entity);
$this->manager->flush();
}