vendor/sonata-project/admin-bundle/src/Command/CreateClassCacheCommand.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sonata Project package.
  4.  *
  5.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Sonata\AdminBundle\Command;
  11. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  12. use Symfony\Component\ClassLoader\ClassCollectionLoader;
  13. use Symfony\Component\Console\Input\InputInterface;
  14. use Symfony\Component\Console\Output\OutputInterface;
  15. @trigger_error(
  16.     'The '.__NAMESPACE__.'\CreateClassCacheCommand class is deprecated since version 3.39.0 and will be removed in 4.0.',
  17.     E_USER_DEPRECATED
  18. );
  19. /**
  20.  * NEXT_MAJOR: Remove this class.
  21.  *
  22.  * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  23.  */
  24. class CreateClassCacheCommand extends ContainerAwareCommand
  25. {
  26.     public function configure()
  27.     {
  28.         $this->setName('cache:create-cache-class');
  29.         $this->setDescription('Generate the classes.php files');
  30.     }
  31.     public function execute(InputInterface $inputOutputInterface $output)
  32.     {
  33.         $kernel $this->getContainer()->get('kernel');
  34.         $classmap $kernel->getCacheDir().'/classes.map';
  35.         if (!is_file($classmap)) {
  36.             throw new \RuntimeException(sprintf('The file %s does not exist'$classmap));
  37.         }
  38.         $name 'classes';
  39.         $extension '.php';
  40.         $output->write('<info>Writing cache file ...</info>');
  41.         ClassCollectionLoader::load(
  42.             include($classmap),
  43.             $kernel->getCacheDir(),
  44.             $name,
  45.             $kernel->isDebug(),
  46.             false,
  47.             $extension
  48.         );
  49.         $output->writeln(' done!');
  50.     }
  51. }