Skip to content

Commit

Permalink
Add a method to load a location at a specific version
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Nov 1, 2017
1 parent a7b6188 commit f883688
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions WrapperBundle/Core/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ public function loadEntityFromLocation(Location $location)
return $this->enrichEntityAtLoad($entity);
}

/**
* This method is useful f.e. when you want to create an Entity that matches a given version and specific location.
* This happens notably when doing content previews, where eZ will inject into your controllers both of them.
*
* @param Content $content
* @param Location $location
* @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface
*/
public function loadEntityFromContentAndLocation(Content $content, Location $location)
{
$class = $this->entityClass;
$entity = new $class($this->repository, $content, $location);
return $this->enrichEntityAtLoad($entity);
}

/**
* @param ContentInfo $contentInfo
* @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface
Expand Down
10 changes: 10 additions & 0 deletions WrapperBundle/Core/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public function loadEntityFromContentRemoteId($remoteId);
*/
public function loadEntityFromLocationRemoteId($remoteId);

/**
* This method is useful f.e. when you want to create an Entity that matches a given version and specific location.
* This happens notably when doing content previews, where eZ will inject into your controllers both of them.
*
* @param Content $content
* @param Location $location
* @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface
*/
public function loadEntityFromContentAndLocation(Content $content, Location $location);

/**
* Called by the Entity Manager when retrieving the repo service / creating the repo instance
* @param string $contentTypeIdentifier
Expand Down
9 changes: 9 additions & 0 deletions news.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Ver 4.0

* added a new method to the base Repository Class and Interface: `loadEntityFromContentAndLocation`
This method is useful f.e. when you want to create an Entity that matches a given version and specific location;
that happens notably when doing content previews, where eZ will inject into your controllers both of them.

Since we changed an Interface, we consider this to be an API breackage, and had to increase the major version nr.


Ver 3.1

* added a new Trait to allow to easily get related Entities of an existing entity
Expand Down

0 comments on commit f883688

Please sign in to comment.