Load the aggregate identified by $aggregateId from the persistent storage.

@param AggregateId $aggregateId
@return AggregateRoot
@throws InvalidArgumentException If the $aggregateId is invalid
3833
public function load(AggregateId $aggregateId)
    {
        $result = $this->getEntityManager()->find($aggregateId->aggregateClass(), $aggregateId->value());
        Preconditions::checkArgument($result !== null, 'Aggregate with ID [%s] does not exist', $aggregateId);
        return $result;
    }
697364
public function checkout($aggregate_root_id)
    {
        $aggregate_root = $this->create();
        $event_stream = $this->event_reader->read($aggregate_root_id);

        if ($event_stream) {
            $aggregate_root->reconstituteFrom($event_stream->getEvents());
        } else {
            $this->logger->debug(__METHOD__ . ' - ' . get_class($this->event_reader));
            throw new RuntimeError(
                sprintf('Unable to load event stream for given AR identifier: %s', $aggregate_root_id)
            );
        }
        return $aggregate_root;
    }
857467
protected function loadNode(ObjectId $oid) {
    // check if we already loaded the node
    if ($this->isRegistered($oid)) {
      return;
    }
    $persistenceFacade = $this->getPersistenceFacade();

    // restore the request values from session
    $language = $this->getRequestValue('language');
    $translateValues = StringUtil::getBoolean($this->getRequestValue('translateValues'));

    // load the node
    $node = $persistenceFacade->load($oid);
    if ($node == null) {
      throw new PersistenceException("Can't load node '".$oid."'");
    }

    // translate all nodes to the requested language if requested
    if ($this->isLocalizedRequest()) {
      $localization = $this->getLocalization();
      $node = $localization->loadTranslation($node, $language, true, true);
    }

    // translate values if requested
    if ($translateValues) {
      $nodes = [$node];
      if ($this->isLocalizedRequest()) {
        NodeUtil::translateValues($nodes, $language);
      }
      else {
        NodeUtil::translateValues($nodes);
      }
    }

    // assign it to the response
    $this->addNodeToResponse($node);

    $this->register($oid);

    $logger = $this->getLogger();
    if ($logger->isInfoEnabled()) {
      $logger->info("Loaded: ".$node->getOID());
    }
    if ($logger->isDebugEnabled()) {
      $logger->debug($node->toString());
    }
  }
546003
public function build(string $uuid, string $aggregateClass, int $max_version = null, int $user = null): AggregateInterface
    {
        try {
            /**
             * @var AggregateInterface $aggregate
             */
            $aggregate = new $aggregateClass($uuid);

            if ($aggregate instanceof AggregateInterface) {
                /**
                 * Get latest matching Snapshot.
                 *
                 * @var Snapshot $snapshot
                 */
                $snapshot = $this->snapshotStore->find($uuid, $max_version);
                $min_version = $snapshot ? ($snapshot->getVersion() + 1) : null;
                if ($snapshot) {
                    $aggregate = $this->loadFromSnapshot($aggregate, $snapshot);
                }

                /**
                 * Get Event Stream Objects.
                 *
                 * @var EventStreamObject[] $eventStreamObjects
                 */
                $eventStreamObjects = $this->eventStore->find($uuid, $max_version, $min_version);
                if ($eventStreamObjects) {
                    $aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
                }

                // Set the current version that is recorded in the event stream.
                $aggregate->setStreamVersion($aggregate->getVersion());

                if (null !== $user) {
                    /**
                     * Get qeued Event Stream Objects.
                     *
                     * @var EventStreamObject[] $eventStreamObjects
                     */
                    $eventStreamObjects = $this->eventStore->findQeued($uuid, $max_version, $aggregate->getVersion() + 1, $user);
                    if ($eventStreamObjects) {
                        $aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
                    }
                }
            } else {
                // Instantiate generic Aggregate to prevent Handler from failing.
                $aggregate = new Aggregate($uuid);
                throw new AggregateException($aggregateClass.' must implement '.AggregateInterface::class);
            }
        } catch (AggregateException $e) {
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                $uuid,
                $e
            ));
        }

        return $aggregate;
    }
1048727
public function loadLanguageById($languageId)
    {
        $language = $this->languageHandler->load($languageId);

        return $this->buildDomainObject($language);
    }
1307695
public function applyChanges(AggregateInterface $aggregate): AggregateInterface
    {
        // Execute the handlers of pending Events.
        /**
         * @var EventInterface $event
         */
        foreach ($aggregate->getPendingEvents() as $event) {
            /**
             * Get Handler for Command.
             *
             * @var HandlerInterface $handler
             */
            $handlerClass = $event->getCommand()->getHandlerClass();
            $handler = new $handlerClass($this->messageBus, $this);
            $aggregate = $handler->executeHandler($event->getCommand(), $aggregate);
        }

        // Clear pending events.
        $aggregate->setPendingEvents([]);

        return $aggregate;
    }
226198
public function loadObjectStateDataForContent($contentId, $stateGroupId)
    {
        try {
            return $this->innerGateway->loadObjectStateDataForContent($contentId, $stateGroupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
465990
public function save(AggregateRoot $aggregateRoot) : void
    {
        $this->aggregates[$this->createKey($aggregateRoot->getId())] = $aggregateRoot;
        self::getLogger()->debug('Aggregate identified by [{}] has been persisted', [$aggregateRoot->getId()]);
    }
1083644
public function select($id = null)
    {
        if (!is_array($id) || !isset($id['service']) || !isset($id['method']) || empty($id['service']) || empty($id['method'])) {
            throw new \InvalidArgumentException('Invalid id argument. Must be array and containing at least service and method property.');
        }

        $serviceName = $id['service'];
        if (!isset($this->services[$serviceName])) {
            throw new \InvalidArgumentException("Service '$serviceName' is not registered in StorageProvider.");
        }

        $method = $id['method'];
        if (!empty($this->services[$serviceName]['methods']) && !in_array($method, $this->services[$serviceName]['methods'])) {
            throw new \InvalidArgumentException("Method '$method' is not registered in StorageProvider for service '$serviceName'.");
        }

        $service = $this->container->get($serviceName);
        $callable_with_arguments = array($service, $method, isset($id['arguments']) ? $id['arguments'] : null);

        return new StorageSelection($callable_with_arguments);
    }
272133
public function loadObjectStateListData($groupId)
    {
        try {
            return $this->innerGateway->loadObjectStateListData($groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1263349
public function doSave(AggregateRoot $aggregateRoot)
    {
        $eventStream = $aggregateRoot->uncommittedChanges();

        if (!$eventStream->isEmpty()) {
            $this->eventStore->append($this->aggregateRootType, $eventStream);
        }
    }
1355562
public function loadRoleDraftByRoleId($roleId)
    {
        try {
            return $this->innerGateway->loadRoleDraftByRoleId($roleId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1254727
function (cmd) {
    var aggregateId = dotty.get(cmd, this.definitions.command.aggregateId);
    var aggregateName = this.aggregate.name;
    var contextName = this.aggregate.context.name;

    var toLoad = [{
      context: contextName,
      aggregate: aggregateName,
      aggregateId: aggregateId
    }];

    if (_.isFunction(this.getStreamsInfo)) {
      toLoad = this.getStreamsInfo(cmd);
      if (!_.isArray(toLoad)) {
        toLoad = [toLoad];
      }
      toLoad.forEach(function (l) {
        l.aggregateId = l.aggregateId || aggregateId;
      });
    }

    if (toLoad[0].context !== contextName || toLoad[0].aggregate !== aggregateName) {
      throw new Error('First stream to load has to be the new one!');
    }

    return toLoad;
  }
1054404
public function registerAggregateRoot(EventSourcedAggregateRoot $aggregateRoot): void
    {
        if ($this->aggregateRoot !== null && $this->aggregateRoot !== $aggregateRoot) {
            throw new DomainException('Aggregate root already registered');
        }

        $this->aggregateRoot = $aggregateRoot;
    }
421634
public function setGroupId( $groupId )
    {
        $this->groupId = (int) $groupId ?: null;

        if ( $this->group && $this->group->id != $this->groupId )
        {
            $this->group = null;
        }

        return $this;
    }
542800
public static function load($id, $subId = null) : CacheEntryInterface
    {
        $storageId = $id;

        if ($subId) {
            $storageId .= '[' . $subId . ']';
        }

        if (!isset(self::$files[$storageId])) {
            $filename = static::CACHE_DIR . ($subId ? $subId . '/' : null) . urlencode($id) . '.' . static::CACHE_EXTENSION;
            self::$files[$storageId] = new File($filename);
        }

        return self::$files[$storageId];
    }
728186
public function load($id)
    {
        /** @var \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface $loader **/
        foreach ($this->procedureLoaders as $loader) {

            try {

                $procedure = $loader->load($id);

                return $procedure;

            } catch (\Exception $e) {}

        }

        throw new \InvalidArgumentException(sprintf('No valid procedure loader could be found to load the \'%s\' procedure.', $id));
    }