forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compatiblity with Symfony 4.3 (api-platform#2784)
* Compatiblity with Symfony 4.3 * Fix all broken unit tests * Fix some deprecations * Remove @Final from ItemNormalizer * Fix Behat tests * Use composition for the Exception Listener * Fix default firewall logout_on_user_change deprecation * Make sure that sodium is supported * Fix composer and tests * Fix PHPStan config and CS * Remove deprecated option * Fix MongoDB * Fix rebase
- Loading branch information
1 parent
ea11026
commit e06475f
Showing
21 changed files
with
129 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ | |
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\Common\Persistence\Mapping\MappingException; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata; | ||
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType; | ||
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; | ||
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; | ||
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; | ||
use Symfony\Component\PropertyInfo\Type; | ||
|
@@ -29,7 +31,7 @@ | |
* @author Kévin Dunglas <[email protected]> | ||
* @author Alan Poulain <[email protected]> | ||
*/ | ||
final class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface | ||
final class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface | ||
{ | ||
private $objectManager; | ||
|
||
|
@@ -43,9 +45,7 @@ public function __construct(ObjectManager $objectManager) | |
*/ | ||
public function getProperties($class, array $context = []) | ||
{ | ||
try { | ||
$metadata = $this->objectManager->getClassMetadata($class); | ||
} catch (MappingException $exception) { | ||
if (null === $metadata = $this->getMetadata($class)) { | ||
return null; | ||
} | ||
|
||
|
@@ -57,9 +57,7 @@ public function getProperties($class, array $context = []) | |
*/ | ||
public function getTypes($class, $property, array $context = []) | ||
{ | ||
try { | ||
$metadata = $this->objectManager->getClassMetadata($class); | ||
} catch (MappingException $exception) { | ||
if (null === $metadata = $this->getMetadata($class)) { | ||
return null; | ||
} | ||
|
||
|
@@ -111,6 +109,39 @@ public function getTypes($class, $property, array $context = []) | |
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isReadable($class, $property, array $context = []): ?bool | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isWritable($class, $property, array $context = []): ?bool | ||
{ | ||
if ( | ||
null === ($metadata = $this->getMetadata($class)) | ||
|| ClassMetadata::GENERATOR_TYPE_NONE === $metadata->generatorType | ||
|| !\in_array($property, $metadata->getIdentifierFieldNames(), true) | ||
) { | ||
return null; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private function getMetadata(string $class): ?ClassMetadata | ||
{ | ||
try { | ||
return $this->objectManager->getClassMetadata($class); | ||
} catch (MappingException $exception) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the corresponding built-in PHP type. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -23,8 +24,15 @@ | |
* @author Samuel ROZE <[email protected]> | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
final class ExceptionListener extends BaseExceptionListener | ||
final class ExceptionListener | ||
{ | ||
private $exceptionListener; | ||
|
||
public function __construct($controller, LoggerInterface $logger = null) | ||
{ | ||
$this->exceptionListener = new BaseExceptionListener($controller, $logger); | ||
} | ||
|
||
public function onKernelException(GetResponseForExceptionEvent $event): void | ||
{ | ||
$request = $event->getRequest(); | ||
|
@@ -36,6 +44,6 @@ public function onKernelException(GetResponseForExceptionEvent $event): void | |
return; | ||
} | ||
|
||
parent::onKernelException($event); | ||
$this->exceptionListener->onKernelException($event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,6 @@ | |
/** | ||
* Generic item normalizer. | ||
* | ||
* @final | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
class ItemNormalizer extends AbstractItemNormalizer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Bridge/Doctrine/MongoDbOdm/PropertyInfo/Fixtures/DoctrineGeneratedValue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Bridge\Doctrine\MongoDbOdm\PropertyInfo\Fixtures; | ||
|
||
use Doctrine\ODM\MongoDB\Mapping\Annotations\Document; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations\Field; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations\Id; | ||
|
||
/** | ||
* @Document | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
* @author Alan Poulain <[email protected]> | ||
*/ | ||
class DoctrineGeneratedValue | ||
{ | ||
/** | ||
* @Id(strategy="INCREMENT", type="integer") | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @Field | ||
*/ | ||
public $foo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.