2019-12-13 22:45:32 +01:00
< ? php
/*
* This file is part of the NelmioApiDocBundle package .
*
* ( c ) Nelmio
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
namespace Nelmio\ApiDocBundle\PropertyDescriber ;
use EXSyst\Component\Swagger\Schema ;
2020-02-18 21:08:48 +01:00
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface ;
use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait ;
2019-12-13 22:45:32 +01:00
use Nelmio\ApiDocBundle\Model\Model ;
use Symfony\Component\PropertyInfo\Type ;
2020-02-18 21:08:48 +01:00
class ObjectPropertyDescriber implements PropertyDescriberInterface , ModelRegistryAwareInterface
2019-12-13 22:45:32 +01:00
{
2020-02-18 21:08:48 +01:00
use ModelRegistryAwareTrait ;
2019-12-13 22:45:32 +01:00
2019-12-13 23:29:52 +01:00
public function describe ( Type $type , Schema $property , array $groups = null )
2019-12-13 22:45:32 +01:00
{
$type = new Type ( $type -> getBuiltinType (), false , $type -> getClassName (), $type -> isCollection (), $type -> getCollectionKeyType (), $type -> getCollectionValueType ()); // ignore nullable field
$property -> setRef (
$this -> modelRegistry -> register ( new Model ( $type , $groups ))
);
}
public function supports ( Type $type ) : bool
{
return Type :: BUILTIN_TYPE_OBJECT === $type -> getBuiltinType ();
}
2019-12-13 22:48:28 +01:00
}