Last active
August 18, 2022 21:37
-
-
Save micha149/9115366 to your computer and use it in GitHub Desktop.
Example command to get all entity association mappings. #symfony2 #doctrine2
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
<?php | |
namespace Esel\ContentBundle\Command; | |
use Doctrine\ORM\Mapping\ClassMetadata; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
class FindEntityRelationsCommand extends ContainerAwareCommand | |
{ | |
protected function configure() | |
{ | |
$this | |
->setName('entity:relations') | |
->setDescription('Lists association data for entities'); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$em = $this->getContainer()->get('doctrine.orm.default_entity_manager'); | |
$metadata = $em->getMetadataFactory()->getAllMetadata(); | |
/** @var ClassMetadata $classMeta*/ | |
foreach($metadata as $classMeta) { | |
ld($classMeta->getAssociationMappings()); | |
} | |
} | |
} |
The ld()
functions calls the ladybug_dump
function.
That came in handy. Thanks 🙂
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
What is this ld() function?