Revert ModelDescriberAwareInterface

This commit is contained in:
Filip Benčo 2020-02-18 21:08:48 +01:00
parent 90bae6738a
commit bb19ed7568
3 changed files with 15 additions and 12 deletions

View File

@ -100,6 +100,9 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
private function describeProperty(Type $type, Model $model, Schema $property, string $propertyName)
{
foreach ($this->propertyDescribers as $propertyDescriber) {
if ($propertyDescriber instanceof ModelRegistryAwareInterface) {
$propertyDescriber->setModelRegistry($this->modelRegistry);
}
if ($propertyDescriber->supports($type)) {
$propertyDescriber->describe($type, $property, $model->getGroups());

View File

@ -12,10 +12,14 @@
namespace Nelmio\ApiDocBundle\PropertyDescriber;
use EXSyst\Component\Swagger\Schema;
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface;
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait;
use Symfony\Component\PropertyInfo\Type;
class ArrayPropertyDescriber implements PropertyDescriberInterface
class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelRegistryAwareInterface
{
use ModelRegistryAwareTrait;
/** @var PropertyDescriberInterface[] */
private $propertyDescribers;
@ -35,6 +39,9 @@ class ArrayPropertyDescriber implements PropertyDescriberInterface
$property = $property->getItems();
foreach ($this->propertyDescribers as $propertyDescriber) {
if ($propertyDescriber instanceof ModelRegistryAwareInterface) {
$propertyDescriber->setModelRegistry($this->modelRegistry);
}
if ($propertyDescriber->supports($type)) {
$propertyDescriber->describe($type, $property, $groups);

View File

@ -12,21 +12,14 @@
namespace Nelmio\ApiDocBundle\PropertyDescriber;
use EXSyst\Component\Swagger\Schema;
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface;
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait;
use Nelmio\ApiDocBundle\Model\Model;
use Nelmio\ApiDocBundle\Model\ModelRegistry;
use Symfony\Component\PropertyInfo\Type;
class ObjectPropertyDescriber implements PropertyDescriberInterface
class ObjectPropertyDescriber implements PropertyDescriberInterface, ModelRegistryAwareInterface
{
/**
* @var ModelRegistry
*/
private $modelRegistry;
public function __construct(ModelRegistry $modelRegistry)
{
$this->modelRegistry = $modelRegistry;
}
use ModelRegistryAwareTrait;
public function describe(Type $type, Schema $property, array $groups = null)
{