@param object $anEventSourcedAggregateRoot

@return Message[]
439989
public function extractPendingStreamEvents($anEventSourcedAggregateRoot): array
    {
        if (null === $this->pendingEventsExtractor) {
            $callInterceptor = $this->flavour;

            $this->pendingEventsExtractor = function () use ($callInterceptor): array {
                return \array_map(function (Message $event) use ($callInterceptor) {
                    return $callInterceptor->prepareNetworkTransmission($event);
                }, $this->popRecordedEvents());
            };
        }

        return $this->pendingEventsExtractor->call($anEventSourcedAggregateRoot);
    }
792270
public function getFieldTypeCallbacks()
    {
        $types = array();

        $numFields = $this->numFields();
        for( $i = 0; $i < $numFields; $i++ ) {
            $types[pg_field_name( $this->resource, $i )] = TypeConversionFactory::get(
                pg_field_type( $this->resource, $i ),
                $this
            );
        }

        return $types;
    }
1261418
public function getAggregationCounts() {
        $counts = [];

        if (!isset($this->rawResponse['aggregations'])) {
            return $counts;
        }

        foreach ($this->rawResponse['aggregations'] as $name => $aggregation) {

            if (empty($aggregation['buckets'])) {
                continue; // Not all aggregations will count something...
            }

            foreach ($aggregation['buckets'] as $bucket) {
                $counts[$name][$bucket['key']] = $bucket['doc_count'];
            }
        }

        return $counts;
    }
1007459
public function getImportErrorMessages(
        ProcessingErrorAggregatorInterface $errorAggregator
    ) {
        $resultText = '';
        if ($errorAggregator->getErrorsCount()) {
            $message = '';
            $counter = 0;
            foreach ($this->getErrorMessages($errorAggregator) as $error) {
                $message .= ++$counter . '. ' . $error . '<br>';
                if ($counter >= self::LIMIT_ERRORS_MESSAGE) {
                    break;
                }
            }
            if ($errorAggregator->hasFatalExceptions()) {
                foreach ($this->getSystemExceptions($errorAggregator) as $error) {
                    $message .= $error->getErrorMessage()
                        . __('Additional data') . ': '
                        . $error->getErrorDescription() . '</div>';
                }
            }
            try {
                $resultText.=
                    '<strong>' . __('Following Error(s) has been occurred during importing process:') . '</strong><br>'
                    . '<div class="import-error-wrapper">' . __('Only first 100 errors are displayed here. ')
                    . '<a href="'
                    //. $this->createDownloadUrlImportHistoryFile($this->createErrorReport($errorAggregator))
                    . '">' . __('Download full report') . '</a><br>'
                    . '<div class="import-error-list">' . $message . '</div></div>'
                ;
            } catch (\Exception $e) {
                foreach ($this->getErrorMessages($errorAggregator) as $errorMessage) {
                    $resultText.= $errorMessage;
                }
            }
        }

        return $resultText;
    }
631825
public function findEventsByRootAssociations($eventsFilter = null)
    {
        $arrayWithEvents = $this->associationsApiService->getEventsFromRootAssociations($eventsFilter);

        $events = new Events();

        foreach ($arrayWithEvents as $xmlQuery) {
            $mapper = new \RGU\Dvoconnector\Mapper\Events($xmlQuery);
            $mapper->mapToAbstractEntity($events);
        }

        return $this->completeEntity($events);
    }
1051014
public function deserialize(array $data, AnnouncementAggregate $aggregate = null, array $options = [])
    {
        $aggregate = $aggregate ?: new AnnouncementAggregate();

        if (!in_array(Options::REFRESH_UUID, $options)) {
            $this->sipe('id', 'setUuid', $data, $aggregate);
        } else {
            $aggregate->refreshUuid();
        }

        $existingAnnounces = [];
        foreach ($aggregate->getAnnouncements() as $announce) {
            $existingAnnounces[$announce->getUuid()] = $announce;
        }

        $announceIds = []; // will be used to remove announces which no longer exist
        if (isset($data['posts'])) {
            foreach ($data['posts'] as $post) {
                $announce = $this->announcementSerializer->deserialize($post, $existingAnnounces[$post['id']] ?? null, $options);

                $announce->setAggregate($aggregate);
                $announceIds[] = $announce->getUuid();
            }
        }

        // remove announces which no longer exist
        foreach ($aggregate->getAnnouncements() as $announce) {
            if (!in_array($announce->getUuid(), $announceIds)) {
                // no longer exists
                $announce->setAggregate(null);
            }
        }

        return $aggregate;
    }
1305198
public function getTemplateRootPaths()
    {
        if ($this->templateRootPaths !== []) {
            return $this->templateRootPaths;
        }

        if ($this->templateRootPathPattern === null) {
            return [];
        }

        $templateRootPath = $this->templateRootPathPattern;
        if (isset($this->patternReplacementVariables['packageKey'])) {
            $templateRootPath = str_replace('@packageResourcesPath', 'resource://' . $this->patternReplacementVariables['packageKey'], $templateRootPath);
        }

        return [$templateRootPath];
    }
192476
private function getBuckets($rawAggregations)
    {
        $buckets = [];

        foreach ($rawAggregations as $bucketName => $rawBucket) {
            while (isset($rawBucket[$bucketName])) {
                $rawBucket = $rawBucket[$bucketName];
            }

            $bucketParams = ['name' => $bucketName, 'values' => $this->getBucketValues($rawBucket)];
            $buckets[$bucketName] = $this->bucketFactory->create($bucketParams);
        }

        return $buckets;
    }
510787
private function buildAggregateAsObject($document)
    {
        $returnObject = [];

        foreach ($document as $event) {
            $returnObject[] = new Event(
                new AggregateUuid($event->uuid),
                $event->type,
                unserialize($event->body),
                $event->version,
                $event->occurred_on
            );
        }

        return $returnObject;
    }
677457
private function buildAggregateAsArray($document)
    {
        $returnArray = [];

        foreach ($document as $event) {
            $returnArray[] = [
                'uuid' => (string) $event->uuid,
                'version' => $event->version,
                'payload' => $event->payload,
                'type' => $event->type,
                'body' => unserialize($event->body),
                'occurred_on' => $event->occurred_on
            ];
        }

        return $returnArray;
    }
371169
public function load(Message $message) : ?Message
    {
        $aggregateIdentifiers = [];
        $expectedVersion = null;

        foreach ($this->aggregateIdentifierMapping as $aggregateIdentifierName => $aggregateIdentifierMappingName) {
            $aggregateIdentifiers[$aggregateIdentifierName] = $this->isFactoryMethod ? null : $this->propertyReaderAccessor->getPropertyValue(PropertyPath::createWith($aggregateIdentifierMappingName), $message->getPayload());
        }

        $aggregate = null;
        if (!$this->isFactoryMethod) {

            foreach ($aggregateIdentifiers as $identifierName => $aggregateIdentifier) {
                if (is_null($aggregateIdentifier)) {
                    throw AggregateNotFoundException::create("Aggregate identifier {$identifierName} definition found, but is null. Can't load aggregate {$this->aggregateClassName} to call {$this->aggregateMethod}.");
                }
            }

            $expectedVersion = $this->expectedVersionName ? $this->propertyReaderAccessor->getPropertyValue(PropertyPath::createWith($this->expectedVersionName), $message->getPayload()) : null;
            if ($this->expectedVersionName && !$expectedVersion) {
                throw InvalidArgumentException::create("Aggregate {$this->aggregateClassName}:{$this->aggregateMethod} has defined version locking, but no version during command handling was provided");
            }

            $aggregate = is_null($this->expectedVersionName)
                ? $this->aggregateRepository->findBy($aggregateIdentifiers)
                : $this->aggregateRepository->findWithLockingBy($aggregateIdentifiers, $expectedVersion);

            if (!$aggregate && $this->filterOutOnNotFound) {
                return null;
            }
        }

        $messageBuilder = MessageBuilder::fromMessage($message);
        if ($aggregate) {
            $messageBuilder = $messageBuilder->setHeader(AggregateMessage::AGGREGATE_OBJECT, $aggregate);
        }
        if ($expectedVersion) {
            $messageBuilder = $messageBuilder->setHeader(AggregateMessage::EXPECTED_VERSION, $expectedVersion);
        }

        if (!$message->getHeaders()->containsKey(MessageHeaders::REPLY_CHANNEL)) {
            $messageBuilder = $messageBuilder
                                ->setReplyChannel(NullableMessageChannel::create());
        }

        return $messageBuilder
            ->setHeader(AggregateMessage::CLASS_NAME, $this->aggregateClassName)
            ->setHeader(AggregateMessage::METHOD_NAME, $this->aggregateMethod)
            ->setHeader(AggregateMessage::AGGREGATE_ID, $aggregateIdentifiers)
            ->setHeader(AggregateMessage::IS_FACTORY_METHOD, $this->isFactoryMethod)
            ->setHeader(AggregateMessage::CALLING_MESSAGE, $message)
            ->build();
    }
158728
public function getCampaignList(ContactSource $contactSource)
    {
        $result           = $campaignIds = [];
        $campaignSettings = json_decode($contactSource->getCampaignSettings(), true);
        if (!empty($campaignSettings)) {
            foreach ($campaignSettings as $campaignSetting) {
                if (!empty($campaignSetting)) {
                    foreach ($campaignSetting as $setting) {
                        if (!empty($setting['campaignId'])) {
                            $campaignIds[] = (int) $setting['campaignId'];
                        }
                    }
                }
            }
        }
        if ($campaignIds) {
            /** @var CampaignRepository $campaignRepo */
            $campaignRepo = $this->em->getRepository('MauticCampaignBundle:Campaign');
            $campaigns    = $campaignRepo->findBy(['id' => $campaignIds], ['name' => 'ASC']);
            if ($campaigns) {
                foreach ($campaigns as $campaign) {
                    $result[$campaign->getId()] = $campaign->getName();
                }
            }
        }

        return $result;
    }
165664
private function getArgumentTokenOfTag(): array
    {
        if ($this->argumentToken === null) {
            $this->argumentToken = $this->loadArgumentTokenOfTag();
        }

        return $this->argumentToken;
    }
549774
public function getArgs($event)
    {
        return [$event->getModel()->getId(), new DcCompat($event->getEnvironment(), $event->getSourceModel())];
    }
1054404
public function registerAggregateRoot(EventSourcedAggregateRoot $aggregateRoot): void
    {
        if ($this->aggregateRoot !== null && $this->aggregateRoot !== $aggregateRoot) {
            throw new DomainException('Aggregate root already registered');
        }

        $this->aggregateRoot = $aggregateRoot;
    }
957238
private function parseAggregationFilters(\DOMXPath $xpath, \DOMNode $rootNode)
    {
        $filters = [];

        foreach ($xpath->query(self::AGGREGATION_FILTERS_PATH, $rootNode) as $filterNode) {
            $filters[$filterNode->getAttribute('name')] = $filterNode->nodeValue;
        }

        return $filters;
    }
51861
protected function parseGateBeforeArguments($arguments, $additional)
    {
        // The way arguments are passed into the gate's before callback has changed in Laravel
        // in the middle of the 5.2 release. Before, arguments were spread out. Now they're
        // all supplied in a single array instead. We will normalize it into two values.
        if (! is_null($additional)) {
            return [$arguments, $additional];
        }

        if (is_array($arguments)) {
            return [
                isset($arguments[0]) ? $arguments[0] : null,
                isset($arguments[1]) ? $arguments[1] : null,
            ];
        }

        return [$arguments, null];
    }