0

如何在 Symfony 2.8 中创建 $doctrineExtractor?它在构造函数中需要 ClassMetadataFactory,但我不明白如何创建它?

我想获取有关实体的属性信息。此外,我想了解在何处以及如何使用 SerializerExtractor?

<?php  
// xController; 

use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; 
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

namespace MeetingBundle\Controller;
/**  * @Route("/x") */
class xController extends Controller {

     * @Route("/", name="x_prop")
     * @Method("GET|POST")
     * @Template("MeetingBundle:help:prop.html.twig")
     */
    public function propAction() {

$reflectionExtractor = new ReflectionExtractor();
$phpDocExtractor = new PhpDocExtractor();
$doctrineExtractor = new DoctrineExtractor(); //how to contruct here ??
$propertyInfo = new PropertyInfoExtractor(
    array($reflectionExtractor),
    array($doctrineExtractor, $phpDocExtractor, $reflectionExtractor),
    array($phpDocExtractor),
    array($reflectionExtractor) );
    $propertyInfo->getProperties($entityName);
    print_r($propertyInfo);
..
}}
4

0 回答 0