|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Sonata Project package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Sonata\AdminBundle\Command; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\ClassLoader\ClassCollectionLoader; |
|
17
|
|
|
use Symfony\Component\Console\Command\Command; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
20
|
|
|
|
|
21
|
|
|
@trigger_error(sprintf( |
|
|
|
|
|
|
22
|
|
|
'The %s\CreateClassCacheCommand class is deprecated since version 3.39.0 and will be removed in 4.0.', |
|
23
|
|
|
__NAMESPACE__ |
|
24
|
|
|
), E_USER_DEPRECATED); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* NEXT_MAJOR: Remove this class. |
|
28
|
|
|
* |
|
29
|
|
|
* @deprecated since version sonata-project/admin-bundle 3.39.0 and will be removed in 4.0. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Thomas Rabaix <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class CreateClassCacheCommand extends Command |
|
34
|
|
|
{ |
|
35
|
|
|
protected static $defaultName = 'cache:create-cache-class'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $cacheDir; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
private $debug; |
|
46
|
|
|
|
|
47
|
|
|
public function __construct(string $cacheDir, bool $debug) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->cacheDir = $cacheDir; |
|
50
|
|
|
$this->debug = $debug; |
|
51
|
|
|
|
|
52
|
|
|
parent::__construct(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function configure() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->setDescription('Generate the classes.php files'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
|
61
|
|
|
{ |
|
62
|
|
|
$classmap = $this->cacheDir.'/classes.map'; |
|
63
|
|
|
|
|
64
|
|
|
if (!is_file($classmap)) { |
|
65
|
|
|
throw new \RuntimeException(sprintf('The file %s does not exist', $classmap)); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$name = 'classes'; |
|
69
|
|
|
$extension = '.php'; |
|
70
|
|
|
|
|
71
|
|
|
$output->write('<info>Writing cache file ...</info>'); |
|
72
|
|
|
ClassCollectionLoader::load( |
|
73
|
|
|
include($classmap), |
|
74
|
|
|
$this->cacheDir, |
|
75
|
|
|
$name, |
|
76
|
|
|
$this->debug, |
|
77
|
|
|
false, |
|
78
|
|
|
$extension |
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
$output->writeln(' done!'); |
|
82
|
|
|
|
|
83
|
|
|
return 0; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: