forked from sonata-project/SonataAdminBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateClassCacheCommand.php
63 lines (53 loc) · 1.6 KB
/
CreateClassCacheCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\AdminBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class CreateClassCacheCommand.
*
* @author Thomas Rabaix <[email protected]>
*/
class CreateClassCacheCommand extends ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
public function configure()
{
$this->setName('cache:create-cache-class');
$this->setDescription('Generate the classes.php files');
}
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$kernel = $this->getContainer()->get('kernel');
$classmap = $kernel->getCacheDir().'/classes.map';
if (!is_file($classmap)) {
throw new \RuntimeException(sprintf('The file %s does not exist', $classmap));
}
$name = 'classes';
$extension = '.php';
$output->write('<info>Writing cache file ...</info>');
ClassCollectionLoader::load(
include($classmap),
$kernel->getCacheDir(),
$name,
$kernel->isDebug(),
false,
$extension
);
$output->writeln(' done!');
}
}