protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        if (!$this->metadata) {
            try {
                $this->metadata = $this->retrieveMetadatas($input->getArgument('name'));
            } catch (\Exception $e) {
                $io->error($e->getMessage());
                return;
            }
        }
        $metadatas = $this->metadata->getMetadata();

        $namespace = str_replace('\\Entity', '', $this->metadata->getNamespace());
        $path = $this->metadata->getPath();

        $basePath = sprintf(
            '%s/%s',
            $path,
            str_replace('\\', '/', $namespace)
        );

        $appDir = $this->getContainer()->getParameter('kernel.root_dir');

        $adminGenerator = new AdminGenerator($appDir);
        $managerGenerator = new ManagerGenerator($appDir);
        $adminCtlGenerator = new AdminControllerGenerator($appDir);
        $servicesGenerator = new ServicesGenerator($appDir);
        $transGenerator = new TranslationsGenerator($appDir);
        foreach ($metadatas as $metadata) {
            $entityName = $this->getEntityNameFromMetadata($metadata);
            $output->writeln('');
            $output->writeln(sprintf('Generate files for entity %s', $entityName));
            // generate Admin class
            $output->writeln($adminGenerator->generate($namespace, $basePath, $metadata));
            // generate Manager class
            $output->writeln($managerGenerator->generate($namespace, $basePath, $metadata));
            // generate AdminController class
            $output->writeln($adminCtlGenerator->generate($namespace, $basePath, $metadata));
            // update translations
            $transGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
            $output->writeln($transGenerator->generate($namespace, $basePath, $metadata));
            // update services.yml
            $servicesGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
            $output->writeln($servicesGenerator->generate($namespace, $basePath, $metadata));
        }
    }