1 | <?php |
||
50 | class Repository implements RepositoryInterface |
||
51 | { |
||
52 | // Name of the php class used to create entities. Subclasses have to set a value to this, to be able to create entities |
||
53 | protected $entityClass; |
||
54 | |||
55 | protected $repository; |
||
56 | protected $entityManager; |
||
57 | protected $contentTypeIdentifier; |
||
58 | protected $settings; |
||
59 | protected $logger; |
||
60 | |||
61 | 10 | public function __construct(eZRepository $repository, $entityManager, array $settings=array(), $contentTypeIdentifier='') |
|
68 | |||
69 | 10 | public function setContentTypeIdentifier($contentTypeIdentifier) |
|
74 | |||
75 | public function setSettings(array $settings) |
||
80 | |||
81 | 10 | public function setLogger(LoggerInterface $logger=null) |
|
82 | { |
||
83 | 10 | $this->logger = $logger; |
|
84 | 10 | return $this; |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * Called from the constructor, with the settings received from the caller. |
||
89 | * Subclasses can implement checking here, or merge the received settings with other data, using f.e. the Symfony |
||
90 | * OptionsResolver component (see http://symfony.com/doc/current/components/options_resolver.html). |
||
91 | * |
||
92 | * @param array $settings |
||
93 | * @return array |
||
94 | */ |
||
95 | 10 | protected function validateSettings(array $settings) |
|
99 | |||
100 | /** |
||
101 | * Nice syntactic sugar ( manually typehinted :-) ) |
||
102 | * Allow all logger methods and eZ repo methods to be called on this extended repo |
||
103 | * |
||
104 | * @param string $method |
||
105 | * @param array $args |
||
106 | * @return mixed |
||
107 | * |
||
108 | * @todo !important move this method to protected access? |
||
109 | */ |
||
110 | 10 | public function __call($method, $args) |
|
131 | |||
132 | /** |
||
133 | * To be overridden in subclasses, this method allows injecting extra services/settings in the entities created. |
||
134 | * This version 'knows' about EntityManagerAware and Logging entity traits. |
||
135 | * |
||
136 | * @param \Kaliop\eZObjectWrapperBundle\Core\EntityInterface $entity |
||
137 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
138 | */ |
||
139 | 10 | protected function enrichEntityAtLoad($entity) |
|
149 | |||
150 | /** |
||
151 | * @param Content $content |
||
152 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
153 | * |
||
154 | * @todo optionally (?) throw an error if bad content type is detected |
||
155 | */ |
||
156 | 10 | public function loadEntityFromContent(Content $content) |
|
162 | |||
163 | /** |
||
164 | * @param Location $location |
||
165 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
166 | */ |
||
167 | 4 | public function loadEntityFromLocation(Location $location) |
|
173 | |||
174 | /** |
||
175 | * @param ContentInfo $contentInfo |
||
176 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
177 | */ |
||
178 | 2 | public function loadEntityFromContentInfo(ContentInfo $contentInfo) |
|
182 | |||
183 | /** |
||
184 | * @param int $id |
||
185 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
186 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content with the given id does not exist |
||
187 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions |
||
188 | */ |
||
189 | 10 | public function loadEntityFromContentId($id) |
|
193 | |||
194 | /** |
||
195 | * An alias for loadEntityFromContentId, to keep the API close to Doctrine |
||
196 | * @param int $id |
||
197 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
198 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content with the given id does not exist |
||
199 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions |
||
200 | */ |
||
201 | 10 | public function find($id) |
|
205 | |||
206 | /** |
||
207 | * @param int $id |
||
208 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
209 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to read this location |
||
210 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified location is not found |
||
211 | */ |
||
212 | 1 | public function loadEntityFromLocationId($id) |
|
216 | |||
217 | /** |
||
218 | * @param string $remoteId |
||
219 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
220 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content with the given id does not exist |
||
221 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions |
||
222 | */ |
||
223 | 1 | public function loadEntityFromContentRemoteId($remoteId) |
|
227 | |||
228 | /** |
||
229 | * @param string $remoteId |
||
230 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface |
||
231 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to read this location |
||
232 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified location is not found |
||
233 | */ |
||
234 | 1 | public function loadEntityFromLocationRemoteId($remoteId) |
|
238 | |||
239 | /** |
||
240 | * NB: assumes that all search results are homogeneous (same content type) |
||
241 | * @param SearchResult $searchResult |
||
242 | * @return \Kaliop\eZObjectWrapperBundle\Core\EntityInterface[] |
||
243 | */ |
||
244 | protected function loadEntitiesFromSearchResults(SearchResult $searchResult) |
||
257 | } |
||
258 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.