Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,4 @@ parameters:
- '#Method ApiPlatform\\Core\\DataProvider\\CollectionDataProviderInterface::getCollection\(\) invoked with 3 parameters, 1-2 required\.#'
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 3 parameters, 1 required\.#'
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 4 parameters, 1 required\.#'
- '#Class Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener constructor invoked with 5 parameters, 1-3 required\.#'
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@
</thead>

<tbody>
{% for key, value in collector.resourceMetadata.attributes if key != 'filters' %}
<tr>
<th scope="row">{{ key }}</th>
<td>{{- profiler_dump(value, 2) -}}</td>
</tr>
{% for key, value in collector.resourceMetadata.attributes %}
{% if key != 'filters' %}
<tr>
<th scope="row">{{ key }}</th>
<td>{{- profiler_dump(value, 2) -}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
Expand Down
12 changes: 10 additions & 2 deletions src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Core\EventListener;

use ApiPlatform\Core\Util\RequestAttributesExtractor;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\EventListener\ExceptionListener as BaseExceptionListener;

Expand All @@ -23,8 +24,15 @@
* @author Samuel ROZE <samuel.roze@gmail.com>
* @author Kévin Dunglas <dunglas@gmail.com>
*/
final class ExceptionListener extends BaseExceptionListener
final class ExceptionListener
{
private $exceptionListener;

public function __construct($controller, LoggerInterface $logger = null, $debug = false, string $charset = null, $fileLinkFormat = null)
{
$this->exceptionListener = new BaseExceptionListener($controller, $logger, $debug, $charset, $fileLinkFormat);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meyerbaptiste In which case would the constructor have these arguments? I can't find anything in Symfony.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, looks like it was reverted: symfony/symfony#31868

So we don't need to handle that.

}

public function onKernelException(GetResponseForExceptionEvent $event): void
{
$request = $event->getRequest();
Expand All @@ -36,6 +44,6 @@ public function onKernelException(GetResponseForExceptionEvent $event): void
return;
}

parent::onKernelException($event);
$this->exceptionListener->onKernelException($event);
}
}
8 changes: 4 additions & 4 deletions src/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected function denormalizeCollection(string $attribute, PropertyMetadata $pr
);
}

$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $this->createChildContext($context, $attribute));
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $this->createChildContext($context, $attribute, $format));
}

return $values;
Expand Down Expand Up @@ -531,7 +531,7 @@ protected function getAttributeValue($object, $attribute, $format = null, array
$this->resourceClassResolver->isResourceClass($className)
) {
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
$childContext = $this->createChildContext($context, $attribute);
$childContext = $this->createChildContext($context, $attribute, $format);
$childContext['resource_class'] = $resourceClass;

return $this->normalizeCollectionOfRelations($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
Expand All @@ -543,7 +543,7 @@ protected function getAttributeValue($object, $attribute, $format = null, array
$this->resourceClassResolver->isResourceClass($className)
) {
$resourceClass = $this->resourceClassResolver->getResourceClass($attributeValue, $className);
$childContext = $this->createChildContext($context, $attribute);
$childContext = $this->createChildContext($context, $attribute, $format);
$childContext['resource_class'] = $resourceClass;

return $this->normalizeRelation($propertyMetadata, $attributeValue, $resourceClass, $format, $childContext);
Expand Down Expand Up @@ -660,7 +660,7 @@ private function createAttributeValue($attribute, $value, $format = null, array
$this->resourceClassResolver->isResourceClass($className)
) {
$resourceClass = $this->resourceClassResolver->getResourceClass(null, $className);
$childContext = $this->createChildContext($context, $attribute);
$childContext = $this->createChildContext($context, $attribute, $format);
$childContext['resource_class'] = $resourceClass;

return $this->denormalizeRelation($attribute, $propertyMetadata, $resourceClass, $value, $format, $childContext);
Expand Down
7 changes: 5 additions & 2 deletions tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
use Symfony\Component\Security\Core\User\UserInterface;

/**
Expand Down Expand Up @@ -96,10 +97,11 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load

$loader->load(__DIR__."/config/config_{$this->getEnvironment()}.yml");

$alg = class_exists(SodiumPasswordEncoder::class) && SodiumPasswordEncoder::isSupported() ? 'auto' : 'bcrypt';
$securityConfig = [
'encoders' => [
User::class => 'bcrypt',
UserDocument::class => 'bcrypt',
User::class => $alg,
UserDocument::class => $alg,
// Don't use plaintext in production!
UserInterface::class => 'plaintext',
],
Expand Down Expand Up @@ -128,6 +130,7 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
'provider' => 'chain_provider',
'http_basic' => null,
'anonymous' => null,
'logout_on_user_change' => true,
],
],
'access_control' => [
Expand Down