本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::refresh方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::refresh方法的具体用法?PHP ObjectManager::refresh怎么用?PHP ObjectManager::refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertPersistedPropertyValue
public function assertPersistedPropertyValue($entity, $propertyName, $expectedPropertyValue, $forceDirectAccess = true)
{
$this->entityManager->refresh($entity);
$persistedPropertyValue = ObjectAccess::getProperty($entity, $propertyName, $forceDirectAccess);
$this->test->assertSame($expectedPropertyValue, $persistedPropertyValue, 'The property ' . $propertyName . ' did not have the expected persistent value');
return $this;
}
示例2: process
/**
* Process form
*
* @param EmailTemplate $entity
*
* @return bool True on successful processing, false otherwise
*/
public function process(EmailTemplate $entity)
{
// always use default locale during template edit in order to allow update of default locale
$entity->setLocale($this->defaultLocale);
if ($entity->getId()) {
// refresh translations
$this->manager->refresh($entity);
}
$this->form->setData($entity);
if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
// deny to modify system templates
if ($entity->getIsSystem() && !$entity->getIsEditable()) {
$this->form->addError(new FormError($this->translator->trans('oro.email.handler.attempt_save_system_template')));
return false;
}
$this->form->submit($this->request);
if ($this->form->isValid()) {
// mark an email template creating by an user as editable
if (!$entity->getId()) {
$entity->setIsEditable(true);
}
$this->manager->persist($entity);
$this->manager->flush();
return true;
}
}
return false;
}
示例3: saveAddress
/**
* Saves an address making a copy in case it was already persisted. Then
* returns the saved address.
*
* @param AddressInterface $address The address to save
*
* @return AddressInterface saved address.
*/
public function saveAddress(AddressInterface $address)
{
if ($address->getId()) {
$addressToSave = clone $address;
$addressToSave->setId(null);
$this->addressObjectManager->refresh($address);
$this->addressObjectManager->persist($addressToSave);
$this->addressObjectManager->flush($addressToSave);
$this->addressEventDispatcher->dispatchAddressOnCloneEvent($address, $addressToSave);
return $addressToSave;
}
$this->addressObjectManager->flush($address);
return $address;
}
示例4: refreshEntity
public function refreshEntity($entity)
{
if (!in_array($entity, $this->managedEntities)) {
throw new \Exception('The entity to be refreshed is not handled by the entity factory', 1416484011);
}
$this->entityManager->refresh($entity);
}
示例5: load
/**
*
* @access public
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$userAdmin = new User();
$userAdmin->setUsername('admin');
$userAdmin->setUsernameCanonical('admin');
$userAdmin->setPlainPassword('root');
$userAdmin->setEmail('admin@codeconsortium.com');
$userAdmin->setEmailCanonical('admin@codeconsortium.com');
$userAdmin->setEnabled(true);
$userAdmin->setRoles(array('ROLE_USER', 'ROLE_MODERATOR', 'ROLE_ADMIN'));
$userAdmin->setSuperAdmin(true);
$userAdmin->setRegisteredDate(new \DateTime('now'));
$userTest = new User();
$userTest->setUsername('test');
$userTest->setUsernameCanonical('test');
$userTest->setPlainPassword('root');
$userTest->setEmail('test@codeconsortium.com');
$userTest->setEmailCanonical('test@codeconsortium.com');
$userTest->setEnabled(true);
$userTest->setRoles(array('ROLE_USER'));
$userTest->setRegisteredDate(new \DateTime('now'));
$userManager = $this->container->get('fos_user.user_manager');
$userManager->updateUser($userAdmin);
$userManager->updateUser($userTest);
$manager->refresh($userAdmin, $userTest);
$this->addReference('user-admin', $userAdmin);
$this->addReference('user-test', $userTest);
}
示例6: getAction
/**
* Get completeness for a product
*
* @param int|string $id
*
* @return JSONResponse
*/
public function getAction($id)
{
$product = $this->productRepository->getFullProduct($id);
if (null === $product->getFamily()) {
return new JsonResponse();
}
$this->completenessManager->generateMissingForProduct($product);
// Product have to be refreshed to have the completeness values generated by generateMissingForProduct()
// (on ORM, completeness is not calculated the same way and product doesn't need to be refreshed)
if (AkeneoStorageUtilsExtension::DOCTRINE_MONGODB_ODM === $this->storageDriver) {
$this->productManager->refresh($product);
}
$channels = $this->channelRepository->getFullChannels();
$locales = $this->userContext->getUserLocales();
$filteredLocales = $this->collectionFilter->filterCollection($locales, 'pim.internal_api.locale.view');
$completenesses = $this->completenessManager->getProductCompleteness($product, $channels, $filteredLocales);
return new JsonResponse($this->compNormalizer->normalize($completenesses, 'internal_api'));
}
示例7: process
/**
* Process form
*
* @param RequestStatus $entity
*
* @return bool True on successful processing, false otherwise
*/
public function process(RequestStatus $entity)
{
// always use default locale during template edit in order to allow update of default locale
$entity->setLocale($this->defaultLocale);
if ($entity->getId()) {
// refresh translations
$this->manager->refresh($entity);
}
$this->form->setData($entity);
if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
$this->form->submit($this->request);
if ($this->form->isValid()) {
$this->manager->persist($entity);
$this->manager->flush();
return true;
}
}
return false;
}
示例8: refreshUser
/**
* (non-PHPdoc)
*
* @see \Symfony\Component\Security\Core\User\UserProviderInterface::refreshUser()
*/
public function refreshUser(UserInterface $user)
{
$userClass = get_class($user);
if (!$this->supportsClass($userClass)) {
throw new UnsupportedUserException("Unsupported user '" . $userClass . "'");
}
/* @var ADH\UserBundle\Entity\User $user */
if ($this->entityManager->contains($user)) {
$this->entityManager->refresh($user);
} else {
$user = $this->userRepository->findOneById($user->getId());
}
if ($user === null) {
throw new UsernameNotFoundException("User does not exist.");
}
return $user;
}
示例9: createClientAccount
/**
* @param ObjectManager $manager
* @param array $data
* @param User $clientUser
* @return ClientAccount
*/
private function createClientAccount(ObjectManager $manager, array $data, User $clientUser)
{
$securityRepository = $manager->getRepository('WealthbotAdminBundle:Security');
$account = new ClientAccount();
$account->setClient($clientUser);
$account->setGroupType($this->getReference('client-account-group-type-' . $data['group_type_key']));
$account->setFinancialInstitution($data['financial_institution']);
$account->setValue($data['value']);
$account->setMonthlyContributions($data['monthly_contributions']);
$account->setMonthlyDistributions($data['monthly_distributions']);
$account->setSasCash($data['sas_cash']);
$account->setProcessStep($data['process_step']);
$account->setStepAction($data['step_action']);
$account->setIsPreSaved($data['is_pre_saved']);
$account->setUnconsolidated($data['unconsolidated']);
if ($data['consolidator_index']) {
$consolidator = $clientUser->getClientAccounts()->get($data['consolidator_index'] - 1);
$account->setConsolidator($consolidator);
}
foreach ($data['owners'] as $ownerType) {
$accountOwner = new ClientAccountOwner();
if ($ownerType === ClientAccountOwner::OWNER_TYPE_SELF) {
$accountOwner->setClient($clientUser);
} else {
$accountOwner->setContact($clientUser->getAdditionalContacts()->first());
}
$accountOwner->setOwnerType($ownerType);
$accountOwner->setAccount($account);
$account->addAccountOwner($accountOwner);
}
$manager->persist($account);
$manager->flush();
$manager->refresh($account);
if (isset($data['account_contribution'])) {
$accountContribution = new AccountContribution();
$accountContribution->setAccount($account);
$accountContribution->setType($data['account_contribution']['type']);
$accountContribution->setTransactionFrequency($data['account_contribution']['transaction_frequency']);
$account->setAccountContribution($accountContribution);
$manager->persist($accountContribution);
}
if (isset($data['securities'])) {
foreach ($data['securities'] as $securityItem) {
//ToDo: CE-402. Check that code is not needed more.
// $security = $securityRepository->findOneBySymbol($securityItem['symbol']);
// if (!$security) {
// /** @var SecurityType $securityType */
// $securityType = $this->getReference('security-type-' . $securityItem['type']);
//
// $security = new Security();
// $security->setName($securityItem['name']);
// $security->setSymbol($securityItem['symbol']);
// $security->setSecurityType($securityType);
// $security->setExpenseRatio($securityItem['exp_ratio']);
// }
// $securityAssignment = new SecurityAssignment();
// $securityAssignment->setSecurity($security);
// $securityAssignment->setRia($clientUser->getRia()); Deprecated
// $accountOutsideFund = new AccountOutsideFund();
// $accountOutsideFund->setAccount($account);
// $accountOutsideFund->setSecurityAssignment($securityAssignment);
// $accountOutsideFund->setIsPreferred(false);
//
// $manager->persist($accountOutsideFund);
}
}
$manager->persist($account);
$manager->flush();
$this->addReference('client-account-' . $account->getId(), $account);
return $account;
}
示例10: reloadSite
/**
* Reload an site instance.
*
* @param Site $site
*/
public function reloadSite(Site $site)
{
$this->objectManager->refresh($site);
}
示例11: reloadAnnuaire
/**
* Reload an annuaire instance.
*
* @param Annuaire $annuaire
*/
public function reloadAnnuaire(Annuaire $annuaire)
{
$this->objectManager->refresh($annuaire);
}
示例12: reloadUser
/**
* {@inheritdoc}
*/
public function reloadUser(UserInterface $user)
{
$this->objectManager->refresh($user);
}
示例13: load
/**
* Load data fixtures with the passed EntityManager
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$gal = new Folder();
$gal->setRel('media');
$gal->setName('Media');
$gal->setTranslatableLocale('en');
$manager->persist($gal);
$manager->flush();
$this->addReference('media-folder-en', $gal);
$gal->setTranslatableLocale('nl');
$manager->refresh($gal);
$gal->setName('Media');
$manager->persist($gal);
$manager->flush();
$gal->setTranslatableLocale('fr');
$manager->refresh($gal);
$gal->setName('Média');
$manager->persist($gal);
$manager->flush();
$subgal = new Folder();
$subgal->setParent($gal);
$subgal->setRel('image');
$subgal->setName('Images');
$subgal->setTranslatableLocale('en');
$manager->persist($subgal);
$manager->flush();
$this->addReference('images-folder-en', $subgal);
$subgal->setTranslatableLocale('nl');
$manager->refresh($subgal);
$subgal->setName('Afbeeldingen');
$manager->persist($subgal);
$manager->flush();
$subgal->setTranslatableLocale('fr');
$manager->refresh($subgal);
$subgal->setName('Images');
$manager->persist($subgal);
$manager->flush();
$subgal = new Folder();
$subgal->setParent($gal);
$subgal->setRel('files');
$subgal->setName('Files');
$subgal->setTranslatableLocale('en');
$manager->persist($subgal);
$manager->flush();
$this->addReference('files-folder-en', $subgal);
$subgal->setTranslatableLocale('nl');
$manager->refresh($subgal);
$subgal->setName('Bestanden');
$manager->persist($subgal);
$manager->flush();
$subgal->setTranslatableLocale('fr');
$manager->refresh($subgal);
$subgal->setName('Fichiers');
$manager->persist($subgal);
$manager->flush();
$subgal = new Folder();
$subgal->setParent($gal);
$subgal->setRel('slideshow');
$subgal->setName('Slides');
$subgal->setTranslatableLocale('en');
$manager->persist($subgal);
$manager->flush();
$this->addReference('slides-folder-en', $subgal);
$subgal->setTranslatableLocale('nl');
$manager->refresh($subgal);
$subgal->setName('Presentaties');
$manager->persist($subgal);
$manager->flush();
$subgal->setTranslatableLocale('fr');
$manager->refresh($subgal);
$subgal->setName('Presentations');
$manager->persist($subgal);
$manager->flush();
$subgal = new Folder();
$subgal->setParent($gal);
$subgal->setRel('video');
$subgal->setName('Videos');
$subgal->setTranslatableLocale('en');
$manager->persist($subgal);
$manager->flush();
$this->addReference('videos-folder-en', $subgal);
$subgal->setTranslatableLocale('nl');
$manager->refresh($subgal);
$subgal->setName('Video\'s');
$manager->persist($subgal);
$manager->flush();
$subgal->setTranslatableLocale('fr');
$manager->refresh($subgal);
$subgal->setName('Vidéos');
$manager->persist($subgal);
$manager->flush();
}
示例14: refresh
/**
*
* @access public
* @param Object $entity
* @return \CCDNForum\ForumBundle\Model\Component\Gateway\GatewayInterface
*/
public function refresh($entity)
{
$this->em->refresh($entity);
return $this;
}
示例15:
function it_reloads_user(ObjectManager $objectManager, UserInterface $user)
{
$objectManager->refresh($user)->shouldBeCalled();
$this->reloadUser($user);
}