Skip to content

Commit

Permalink
Merge pull request #632 from dunglas/quality_again
Browse files Browse the repository at this point in the history
More quality fixes
  • Loading branch information
dunglas authored Jul 16, 2016
2 parents 399ef55 + 4fe00f5 commit 44f4f37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Action/ExceptionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function __construct(SerializerInterface $serializer, array $errorFormats
/**
* Converts a an exception to a JSON response.
*
* @param \Exception|FlattenException $exception
* @param Request $request
* @param FlattenException $exception
* @param Request $request
*
* @return Response
*/
public function __invoke($exception, Request $request) : Response
public function __invoke(FlattenException $exception, Request $request) : Response
{
$exceptionClass = $exception->getClass();
foreach ($this->exceptionToStatus as $class => $status) {
Expand Down
11 changes: 4 additions & 7 deletions src/Bridge/Doctrine/Orm/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ protected function extractProperties(Request $request) : array
protected function addJoinsForNestedProperty(string $property, string $rootAlias, QueryBuilder $queryBuilder) : array
{
$propertyParts = $this->splitPropertyParts($property);

if (0 === count($propertyParts['associations'])) {
throw new InvalidArgumentException(sprintf('Cannot add joins for property "%s" - property is not nested.', $property));
}

$parentAlias = $rootAlias;

foreach ($propertyParts['associations'] as $association) {
Expand All @@ -205,8 +200,10 @@ protected function addJoinsForNestedProperty(string $property, string $rootAlias
$parentAlias = $alias;
}

$field = $propertyParts['field'];
if (!isset($alias)) {
throw new InvalidArgumentException(sprintf('Cannot add joins for property "%s" - property is not nested.', $property));
}

return [$alias, $field];
return [$alias, $propertyParts['field']];
}
}
4 changes: 2 additions & 2 deletions src/Hal/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function supportsNormalization($data, $format = null)
*/
public function normalize($object, $format = null, array $context = [])
{
$context['cache_key'] = $this->getCacheKey($format, $context);
$context['cache_key'] = $this->getHalCacheKey($format, $context);

$rawData = parent::normalize($object, $format, $context);
if (!is_array($rawData)) {
Expand Down Expand Up @@ -217,7 +217,7 @@ private function getRelationIri($rel) : string
*
* @return bool|string
*/
private function getCacheKey(string $format = null, array $context)
private function getHalCacheKey(string $format = null, array $context)
{
try {
return md5($format.serialize($context));
Expand Down

0 comments on commit 44f4f37

Please sign in to comment.