Get array/list of entities from Doctrine

前端 未结 4 725

This is probably pretty simple, but I can\'t find a way to do this.

Is there any way to get a list of class names of the entities that Doctrine manages? Something l

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 18:51

    I know this question is old, but in case someone still needs to do it (tested in Doctrine 2.4.0):

    $classes = array();
    $metas = $entityManager->getMetadataFactory()->getAllMetadata();
    foreach ($metas as $meta) {
        $classes[] = $meta->getName();
    }
    var_dump($classes);
    

    Source

提交回复
热议问题