public function postFlush(PostFlushEventArgs $eventArgs) { if ($this->needFlush) { $this->needFlush = false; $eventArgs->getEntityManager()->flush(); } }
/** * Save collected changes * * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { /** @var $entityManager */ $entityManager = $args->getEntityManager(); $this->activityListManager->processDeletedEntities($this->deletedEntities, $entityManager); $this->deletedEntities = []; if ($this->activityListManager->processInsertEntities($this->insertedEntities, $entityManager)) { $this->insertedEntities = []; $entityManager->flush(); } }
/** * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $entityManager = $args->getEntityManager(); foreach ($entityManager->getUnitOfWork()->getIdentityMap() as $key => $entities) { foreach ($entities as $entityId => $entity) { $changeSet = $entityManager->getUnitOfWork()->getEntityChangeSet($entity); $entityClass = $this->contextService->resolveEntityClass(get_class($entity)); $contexts = $this->contextService->getEntityContexts($entityClass); if (count($contexts) && count($changeSet)) { $queued = $this->contextService->getQueued(); if (count($queued)) { if (isset($queued[$entityClass])) { $currentEntity = $queued[$entityClass]; $contextRepo = $args->getEntityManager()->getRepository('BigfootContextBundle:Context'); /** @var ContextRepository $contextRepo */ $context = $contextRepo->findOneByEntityIdEntityClass($entityId, $entityClass); if (!$context) { $context = $this->createContext($entityId, $entityClass, $currentEntity['context_values']); } $entityManager->persist($context); $this->contextService->clearQueue(); $entityManager->flush(); } } } } } }
/** * Send notification to clank that user have new emails * * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $usersWithNewEmails = []; if (!$this->processEmailUsersEntities) { return; } /** @var EmailUser $entity */ foreach ($this->processEmailUsersEntities as $item) { $status = $item['status']; $entity = $item['entity']; $em = $args->getEntityManager(); $ownerIds = $this->determineOwners($entity, $em); foreach ($ownerIds as $ownerId) { if (array_key_exists($ownerId, $usersWithNewEmails) === true) { $new = $usersWithNewEmails[$ownerId]['new']; if ($status === self::ENTITY_STATUS_NEW) { $usersWithNewEmails[$ownerId]['new'] = $new + 1; } } else { $usersWithNewEmails[$ownerId] = ['entity' => $entity, 'new' => $status === self::ENTITY_STATUS_NEW ? 1 : 0]; } } } if ($usersWithNewEmails) { $this->processor->send($usersWithNewEmails); } $this->processEmailUsersEntities = []; }
/** * Post flush * * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $this->manager = $args->getEntityManager(); if (!empty($this->deactivatedLocales)) { $this->onLocalesDeactivated(); } }
public function postFlush(PostFlushEventArgs $event) { $em = $event->getEntityManager(); while ($entity = array_shift($this->proxiesStripped)) { $className = get_class($entity); $this->getTranslationMetadata($className, $em)->injectProxies($entity, $this->defaultLocaleProvider); } }
/** * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { if ($this->scheduledEntities) { while ($processJob = array_shift($this->scheduledEntities)) { $this->serialize($processJob); } $args->getEntityManager()->flush(); } }
public function postFlush(PostFlushEventArgs $event) { foreach ($this->entities as $entity) { foreach ($entity->popEvents() as $event) { $event->setSubject($entity); $this->dispatcher->dispatch($event->getName(), $event); } } }
public function postFlush(PostFlushEventArgs $args) { if (count($this->EntidadesRelacionadas) > 0) { $em = $args->getEntityManager(); foreach ($this->EntidadesRelacionadas as $Entidad) { $em->persist($Entidad); } $this->EntidadesRelacionadas = array(); $em->flush(); } }
public function postFlush(PostFlushEventArgs $event) { if (!empty($this->entities)) { $em = $event->getEntityManager(); foreach ($this->entities as $k => $entity) { $em->persist($entity); unset($this->entities[$k]); } $em->flush(); } }
/** * @param PostFlushEventArgs $args args */ public function postFlush(PostFlushEventArgs $args) { if (count($this->violations) === 0) { return null; } $entityManager = $args->getEntityManager(); foreach ($this->violations as $violation) { $entityManager->persist($violation); } $this->violations = array(); $entityManager->flush(); }
public function postFlush(PostFlushEventArgs $args) { if ($this->_isFlushing || !count($this->_structures)) { return; } $em = $args->getEntityManager(); $uow = $em->getUnitOfWork(); foreach ($this->_structures as $structure) { $nodes = $em->getRepository('Chalk\\Core\\Structure\\Node')->all(['structure' => $structure, 'sort' => 'sort']); $root = null; foreach ($nodes as $node) { $node->children->setInitialized(true); $node->children->clear(); if (!isset($node->parent)) { $root = $node; } } foreach ($nodes as $node) { if (isset($node->parent)) { $node->parent->children->add($node); } } $tree = new \RecursiveIteratorIterator(new \Chalk\Core\Structure\Node\Iterator([$root]), \RecursiveIteratorIterator::SELF_FIRST); $j = 0; $stack = []; foreach ($tree as $i => $node) { $slice = array_splice($stack, $tree->getDepth(), count($stack), [$node]); foreach (array_reverse($slice) as $reverse) { $reverse->right = $j++; } $node->left = $j++; $node->sort = $i; $node->depth = $tree->getDepth(); $nodes = $stack; array_shift($nodes); $parts = array_map(function ($node) { return isset($node->slug) ? $node->slug : $node->content->slug; }, $nodes); if (isset($structure->path)) { array_unshift($parts, $structure->path); } $node->path = implode('/', $parts); } foreach (array_reverse($stack) as $reverse) { $reverse->right = $j++; } } $this->_structures = []; $this->_isFlushing = true; $em->flush(); $this->_isFlushing = false; }
public function postFlush(Event\PostFlushEventArgs $eventArgs) { if ($this->recursionMutex || $this->switchedOff) { return; } foreach ($this->toInvalidate as $territoire) { $this->container->get('repository.cache_info')->invalidate($territoire); } $this->recursionMutex = true; $eventArgs->getEntityManager()->flush(); $this->recursionMutex = false; $this->toInvalidate = array(); }
public function postFlush(PostFlushEventArgs $args) { if (!count($this->_updates)) { return; } $em = $args->getEntityManager(); $indexes = $em->getRepository('Chalk\\Core\\Index')->entities($this->_updates); foreach ($indexes as $index) { $index->reindex(); } $this->_updates = []; $em->flush(); }
public function postFlush(PostFlushEventArgs $args) { $arm = $this->getAutoRouteManager(); $arm->handleDefunctRoutes(); if (!$this->postFlushDone) { $om = $args->getEntityManager(); foreach ($this->insertions as $document) { $this->handleInsertOrUpdate($document, $arm, $om); } $this->postFlushDone = true; $om->flush(); } $this->postFlushDone = false; }
/** * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $emailIds = $this->popEmailIds(); if (!$emailIds) { return; } $jobArgs = array_map(function ($id) { return sprintf('--%s=%s', AutoResponseCommand::OPTION_ID, $id); }, $emailIds); $job = new Job(AutoResponseCommand::NAME, $jobArgs); $em = $args->getEntityManager(); $em->persist($job); $em->flush(); }
/** * Handles postFlush event * * @param PostFlushEventArgs $event */ public function handlePostFlush(PostFlushEventArgs $event) { $entityManager = $event->getEntityManager(); if ($this->getQueueThreadUpdate()) { $this->processThreadCreate($entityManager); $this->resetQueueThreadUpdate(); $entityManager->flush(); } if ($this->getQueueHeadUpdate()) { $this->processEmailsHeadSet($entityManager); $this->resetQueueHeadUpdate(); $entityManager->flush(); } }
/** * @param PostFlushEventArgs $event */ public function postFlush(PostFlushEventArgs $event) { if (!empty($this->insertedCalendars)) { $em = $event->getEntityManager(); foreach ($this->insertedCalendars as $calendar) { // connect the calendar to itself $calendarProperty = new CalendarProperty(); $calendarProperty->setTargetCalendar($calendar)->setCalendarAlias(Calendar::CALENDAR_ALIAS)->setCalendar($calendar->getId()); $em->persist($calendarProperty); } $this->insertedCalendars = []; $em->flush(); } }
/** * Updates all returns which have been scheduled for insertion. * * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $em = $args->getEntityManager(); $changedReturns = $this->updateReturnNumbers($this->returns); /* * Empty returns array to indicate that all returns have been processed and to prevent loop on flushing. */ $this->returns = []; foreach ($changedReturns as $return) { $em->persist($return); } if (!empty($changedReturns)) { $em->flush($changedReturns); } }
/** * Updates all orders which have been scheduled for insertion. * * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { $em = $args->getEntityManager(); $changedOrders = $this->updateOrderNumbers($this->orders); /* * Empty orders array to indicate that all orders have been process and to prevent loop on flushing. */ $this->orders = []; foreach ($changedOrders as $order) { $em->persist($order); } if (!empty($changedOrders)) { $em->flush($changedOrders); } }
/** * @param PostFlushEventArgs $event */ public function postFlush(PostFlushEventArgs $event) { if (count($this->ordersForUpdate) === 0) { return; } $orders = $this->getChangedOrders($event->getEntityManager()->getUnitOfWork()); foreach ($orders as $order) { // if order was scheduled for update if (!empty($this->ordersForUpdate[$order->getId()])) { $this->channelDoctrineListener->initializeFromEventArgs($event); $this->updateCustomerLifetime($event->getEntityManager(), $order); unset($this->ordersForUpdate[$order->getId()]); } } }
public function postFlush(PostFlushEventArgs $args) { if (static::$disableProcessing) { return; } $this->init(); $em = $args->getEntityManager(); if (count($this->toFlush) > 0) { foreach ($this->toFlush as $num => $item) { $em->persist($item); } $em->flush(); $this->toFlush = array(); } }
public function postFlush(PostFlushEventArgs $event) { // exit; // if (array_key_exists('form', $_POST) && isset($_POST['form']["seo_slug"])) { $em = $event->getEntityManager(); $uow = $em->getUnitOfWork(); $languages = $em->getRepository('BigfishLanguageBundle:Language')->findAll(); $resourceTable = $em->getClassMetadata("BigfishResourceBundle:Resource")->getTableName(); $translationTable = $em->getClassMetadata("BigfishResourceBundle:ResourceTranslation")->getTableName(); foreach ($languages as $language) { $sql = "UPDATE " . $translationTable . " AS U\n INNER JOIN (\n SELECT core.resource_id, CONCAT_WS('/', dd.slug, cc.slug, bb.slug, aa.slug, core_aa.slug) AS slug\n FROM " . $resourceTable . " AS core JOIN " . $translationTable . " core_aa ON core.resource_id = core_aa.resource_id AND core_aa.language_id = " . $language->getId() . "\n LEFT OUTER JOIN " . $resourceTable . " a ON core.parent_id = a.resource_id LEFT OUTER JOIN " . $translationTable . " aa ON aa.resource_id = a.resource_id AND aa.language_id = " . $language->getId() . "\n LEFT OUTER JOIN " . $resourceTable . " b ON a.parent_id = b.resource_id LEFT OUTER JOIN " . $translationTable . " bb ON bb.resource_id = b.resource_id AND bb.language_id = " . $language->getId() . "\n LEFT OUTER JOIN " . $resourceTable . " c ON b.parent_id = c.resource_id LEFT OUTER JOIN " . $translationTable . " cc ON cc.resource_id = c.resource_id AND cc.language_id = " . $language->getId() . "\n LEFT OUTER JOIN " . $resourceTable . " d ON c.parent_id = d.resource_id LEFT OUTER JOIN " . $translationTable . " dd ON dd.resource_id = d.resource_id AND dd.language_id = " . $language->getId() . "\n\n ) AS Q ON U.resource_id = Q.resource_id SET U.path = Q.slug WHERE U.language_id = " . $language->getId() . "\n "; $query = $em->getConnection()->exec($sql); } } }
public function postFlush(PostFlushEventArgs $args) { if (!count($this->_updates) && !count($this->_deletions)) { return; } $em = $args->getEntityManager(); while (count($this->_updates)) { $entity = array_shift($this->_updates); $entity->entityId = $entity->entityObject->id; $em->persist($entity); } while (count($this->_deletions)) { $entity = array_shift($this->_deletions); $em->remove($entity); } $em->flush(); }
/** * Handles postFlush event * * @param PostFlushEventArgs $event */ public function handlePostFlush(PostFlushEventArgs $event) { $em = $event->getEntityManager(); if ($this->getQueue()) { foreach ($this->getQueue() as $email) { $this->copyContexts($em, $email); // prepare the list of association targets $targets = []; if (count($this->emailActivityListProvider->getTargetEntities($email)) === 0) { $this->addRecipientOwners($targets, $email); } $this->addSenderOwner($targets, $email); // add associations $this->addContextsToThread($em, $email, $targets); } $this->resetQueue(); $em->flush(); } }
/** * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { if (!$this->isActive() || empty($this->insertEntities)) { return; } foreach ($this->insertEntities as $entity) { $this->getSearchEngine()->save($entity, $this->realtime, true); } $this->insertEntities = array(); $args->getEntityManager()->flush(); }
/** * @param PostFlushEventArgs $args */ public function postFlush(PostFlushEventArgs $args) { if (!$this->enabled || !$this->brokenAudits) { return; } $em = $args->getEntityManager(); foreach ($this->brokenAudits as $audit) { $meta = $em->getClassMetadata($audit->getObjectClass()); $deprecatedData = $audit->getDeprecatedData(); foreach ($deprecatedData as $field => $values) { $oldValue = is_array($values['old']) ? $values['old']['value'] : $values['old']; $newValue = is_array($values['new']) ? $values['new']['value'] : $values['new']; $fieldType = $meta->getTypeOfField($field); $audit->createField($field, $fieldType, $newValue, $oldValue); } $audit->setData(null); } $this->brokenAudits = []; $em->flush(); }
public function postFlush(PostFlushEventArgs $args) { if ($this->changeset) { if ($user = $this->changeset->getUser()) { $em = $args->getEntityManager(); $em->persist($this->changeset); $em->flush(); # надо пописать в поле изменения код с разметкой измененных изображений if ($user instanceof Doctor && count($this->imgFields)) { foreach ($this->imgFields as $field => $label) { $method = 'get' . ucfirst($field); if (method_exists($user, $method)) { $imgPath = $user->{$method}()['path']; $em->createQuery("\r\n\t\t\t\t\t\t\tUPDATE EvrikaMainBundle:ProfileChangeset ps\r\n\t\t\t\t\t\t\tSET ps.new = CONCAT(ps.new, '<br/><b>{$label}:</b> <img src=\"{$imgPath}\" />')\r\n\t\t\t\t\t\t\tWHERE ps.id = {$this->changeset->getId()}\r\n\t\t\t\t\t\t")->execute(); } } } $this->changeset = null; $this->imgFields = array(); } } }
public function postFlush(PostFlushEventArgs $eventArgs) { $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); foreach ($this->extraUpdates as $entity) { $className = get_class($entity); $meta = $em->getClassMetadata($className); $persister = $uow->getEntityPersister($className); $updateData = $this->prepareUpdateData($persister, $entity); if (!isset($updateData[$meta->table['name']]) || !$updateData[$meta->table['name']]) { continue; } foreach ($updateData[$meta->table['name']] as $field => $value) { $sql = 'UPDATE ' . $this->config->getTableName($meta) . ' ' . 'SET ' . $field . ' = ? ' . 'WHERE ' . $this->config->getRevisionFieldName() . ' = ? '; $params = array($value, $this->getRevisionId()); $types = array(); if (in_array($field, $meta->columnNames)) { $types[] = $meta->fieldMappings[$meta->getFieldForColumn($field)]['type']; } else { //try to find column in association mappings $type = null; foreach ($meta->associationMappings as $mapping) { if (isset($mapping['joinColumns'])) { foreach ($mapping['joinColumns'] as $definition) { if ($definition['name'] == $field) { $targetTable = $em->getClassMetadata($mapping['targetEntity']); $type = $targetTable->getTypeOfColumn($definition['referencedColumnName']); } } } } if (is_null($type)) { throw new \Exception(sprintf('Could not resolve database type for column "%s" during extra updates', $field)); } } $types[] = $this->config->getRevisionIdFieldType(); foreach ($meta->identifier as $idField) { if (isset($meta->fieldMappings[$idField])) { $columnName = $meta->fieldMappings[$idField]['columnName']; $types[] = $meta->fieldMappings[$idField]['type']; } elseif (isset($meta->associationMappings[$idField])) { $columnName = $meta->associationMappings[$idField]['joinColumns'][0]; $types[] = $meta->associationMappings[$idField]['type']; } $params[] = $meta->reflFields[$idField]->getValue($entity); $sql .= 'AND ' . $columnName . ' = ?'; } $this->em->getConnection()->executeQuery($sql, $params, $types); } } }
public function postFlush(PostFlushEventArgs $args) { $em = $args->getEntityManager(); $uow = $em->getUnitOfWork(); $manager = new TagManager($this->managerRegistry); $tags = array(); foreach ($uow->getIdentityMap() as $model) { foreach ($model as $entity) { if ($entity instanceof Tag) { $tags[] = $entity; } if ($entity instanceof Taggable) { $this->entity = $entity; } } } if ($this->entity) { if (!empty($tags)) { $this->entity->setTags($tags); $manager->saveRelation($this->entity); } } }