| @@ -7,34 +7,34 @@ | ||
| 7 | 7 | |
| 8 | 8 | class RelatedItemAction extends ItemAction | 
| 9 | 9 |  { | 
| 10 | - /** | |
| 11 | - * Field that contains the related resourse key | |
| 12 | - * | |
| 13 | - * @var string | |
| 14 | - */ | |
| 15 | - protected $relatedKey; | |
| 10 | + /** | |
| 11 | + * Field that contains the related resourse key | |
| 12 | + * | |
| 13 | + * @var string | |
| 14 | + */ | |
| 15 | + protected $relatedKey; | |
| 16 | 16 | |
| 17 | - public function __construct(RestRepository $repository, $transformer, $relatedKey) | |
| 18 | -	{ | |
| 19 | - parent::__construct($repository, $transformer); | |
| 20 | - $this->relatedKey = $relatedKey; | |
| 21 | - } | |
| 17 | + public function __construct(RestRepository $repository, $transformer, $relatedKey) | |
| 18 | + { | |
| 19 | + parent::__construct($repository, $transformer); | |
| 20 | + $this->relatedKey = $relatedKey; | |
| 21 | + } | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * @param RestRequestContract $request | |
| 25 | - * | |
| 26 | - * @return RestResponse | |
| 27 | - */ | |
| 28 | - public function handle($request) | |
| 29 | -	{ | |
| 30 | - $entity = $this->repository()->findByIdentifier($request); | |
| 31 | - $method = 'get' . ucfirst($this->relatedKey); | |
| 32 | -		$relatedEntity = $entity->{$method}(); | |
| 23 | + /** | |
| 24 | + * @param RestRequestContract $request | |
| 25 | + * | |
| 26 | + * @return RestResponse | |
| 27 | + */ | |
| 28 | + public function handle($request) | |
| 29 | + { | |
| 30 | + $entity = $this->repository()->findByIdentifier($request); | |
| 31 | + $method = 'get' . ucfirst($this->relatedKey); | |
| 32 | +  $relatedEntity = $entity->{$method}(); | |
| 33 | 33 | |
| 34 | - $this->authorize($request, $relatedEntity); | |
| 34 | + $this->authorize($request, $relatedEntity); | |
| 35 | 35 | |
| 36 | - $resource = new Item($relatedEntity, $this->transformer(), $this->relatedKey); | |
| 36 | + $resource = new Item($relatedEntity, $this->transformer(), $this->relatedKey); | |
| 37 | 37 | |
| 38 | - return $this->response()->resource($request, $resource); | |
| 39 | - } | |
| 38 | + return $this->response()->resource($request, $resource); | |
| 39 | + } | |
| 40 | 40 | } | 
| @@ -28,7 +28,7 @@ | ||
| 28 | 28 | public function handle($request) | 
| 29 | 29 |  	{ | 
| 30 | 30 | $entity = $this->repository()->findByIdentifier($request); | 
| 31 | - $method = 'get' . ucfirst($this->relatedKey); | |
| 31 | + $method = 'get'.ucfirst($this->relatedKey); | |
| 32 | 32 |  		$relatedEntity = $entity->{$method}(); | 
| 33 | 33 | |
| 34 | 34 | $this->authorize($request, $relatedEntity); | 
| @@ -13,63 +13,63 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | class RelatedCollectionAction extends CollectionAction | 
| 15 | 15 |  { | 
| 16 | - /** | |
| 17 | - * Field that contains the related repository | |
| 18 | - * | |
| 19 | - * @var RestRepository | |
| 20 | - */ | |
| 21 | - protected $relatedrepository; | |
| 16 | + /** | |
| 17 | + * Field that contains the related repository | |
| 18 | + * | |
| 19 | + * @var RestRepository | |
| 20 | + */ | |
| 21 | + protected $relatedrepository; | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * Field that contains the related resourse key | |
| 25 | - * | |
| 26 | - * @var string | |
| 27 | - */ | |
| 28 | - protected $relatedKey; | |
| 23 | + /** | |
| 24 | + * Field that contains the related resourse key | |
| 25 | + * | |
| 26 | + * @var string | |
| 27 | + */ | |
| 28 | + protected $relatedKey; | |
| 29 | 29 | |
| 30 | - public function __construct(RestRepository $repository, RestRepository $relatedRepository, $transformer, $relatedKey) | |
| 31 | -	{ | |
| 32 | - parent::__construct($repository, $transformer); | |
| 33 | - $this->relatedRepository = $relatedRepository; | |
| 34 | - $this->relatedKey = $relatedKey; | |
| 35 | - } | |
| 30 | + public function __construct(RestRepository $repository, RestRepository $relatedRepository, $transformer, $relatedKey) | |
| 31 | + { | |
| 32 | + parent::__construct($repository, $transformer); | |
| 33 | + $this->relatedRepository = $relatedRepository; | |
| 34 | + $this->relatedKey = $relatedKey; | |
| 35 | + } | |
| 36 | 36 | |
| 37 | - /** | |
| 38 | - * @param RestRequestContract $request | |
| 39 | - * | |
| 40 | - * @return RestResponse | |
| 41 | - */ | |
| 42 | - protected function handle($request) | |
| 43 | -	{ | |
| 44 | - $resourceKey = $this->relatedRepository()->getResourceKey(); | |
| 45 | - $this->authorize($request, $this->repository()->getClassName()); | |
| 37 | + /** | |
| 38 | + * @param RestRequestContract $request | |
| 39 | + * | |
| 40 | + * @return RestResponse | |
| 41 | + */ | |
| 42 | + protected function handle($request) | |
| 43 | + { | |
| 44 | + $resourceKey = $this->relatedRepository()->getResourceKey(); | |
| 45 | + $this->authorize($request, $this->repository()->getClassName()); | |
| 46 | 46 | |
| 47 | - $entity = $this->repository()->findByIdentifier($request); | |
| 48 | - $qb = $this->relatedRepository()->sourceQueryBuilder(); | |
| 49 | - $qb->andWhere($this->relatedRepository()->alias() . '.' . $this->relatedKey . ' = ' . ((int)$request->getId())); | |
| 50 | - $this->applyPagination($request, $qb); | |
| 51 | - $this->applyFilter($request, $qb); | |
| 47 | + $entity = $this->repository()->findByIdentifier($request); | |
| 48 | + $qb = $this->relatedRepository()->sourceQueryBuilder(); | |
| 49 | + $qb->andWhere($this->relatedRepository()->alias() . '.' . $this->relatedKey . ' = ' . ((int)$request->getId())); | |
| 50 | + $this->applyPagination($request, $qb); | |
| 51 | + $this->applyFilter($request, $qb); | |
| 52 | 52 | |
| 53 | - $paginator = new Paginator($qb, false); | |
| 54 | - $collection = new Collection($paginator, $this->transformer(), $resourceKey); | |
| 53 | + $paginator = new Paginator($qb, false); | |
| 54 | + $collection = new Collection($paginator, $this->transformer(), $resourceKey); | |
| 55 | 55 | |
| 56 | -		if ($qb->getMaxResults()) { | |
| 57 | - $collection->setPaginator( | |
| 58 | - new DoctrinePaginatorAdapter( | |
| 59 | - $paginator, | |
| 60 | - $this->paginatorUrlGenerator($request, $resourceKey) | |
| 61 | - ) | |
| 62 | - ); | |
| 63 | - } | |
| 56 | +  if ($qb->getMaxResults()) { | |
| 57 | + $collection->setPaginator( | |
| 58 | + new DoctrinePaginatorAdapter( | |
| 59 | + $paginator, | |
| 60 | + $this->paginatorUrlGenerator($request, $resourceKey) | |
| 61 | + ) | |
| 62 | + ); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - return $this->response()->resource($request, $collection); | |
| 66 | - } | |
| 65 | + return $this->response()->resource($request, $collection); | |
| 66 | + } | |
| 67 | 67 | |
| 68 | - /** | |
| 69 | - * @return RestRepository | |
| 70 | - */ | |
| 71 | - public function relatedRepository() | |
| 72 | -	{ | |
| 73 | - return $this->relatedRepository; | |
| 74 | - } | |
| 68 | + /** | |
| 69 | + * @return RestRepository | |
| 70 | + */ | |
| 71 | + public function relatedRepository() | |
| 72 | + { | |
| 73 | + return $this->relatedRepository; | |
| 74 | + } | |
| 75 | 75 | } | 
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | |
| 47 | 47 | $entity = $this->repository()->findByIdentifier($request); | 
| 48 | 48 | $qb = $this->relatedRepository()->sourceQueryBuilder(); | 
| 49 | - $qb->andWhere($this->relatedRepository()->alias() . '.' . $this->relatedKey . ' = ' . ((int)$request->getId())); | |
| 49 | + $qb->andWhere($this->relatedRepository()->alias().'.'.$this->relatedKey.' = '.((int) $request->getId())); | |
| 50 | 50 | $this->applyPagination($request, $qb); | 
| 51 | 51 | $this->applyFilter($request, $qb); | 
| 52 | 52 | |