1 | <?php |
||
19 | class PHPCRGenerator implements GeneratorInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $DocumentTemplate; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $DocumentRepositoryTemplate; |
||
30 | |||
31 | public function __construct() |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function generate(OutputInterface $output, BundleMetadata $bundleMetadata): void |
||
48 | |||
49 | public function generateMappingDocumentFiles(OutputInterface $output, BundleMetadata $bundleMetadata): void |
||
84 | |||
85 | public function generateDocumentFiles(OutputInterface $output, BundleMetadata $bundleMetadata): void |
||
86 | { |
||
87 | $output->writeln(' - Generating Document files'); |
||
88 | |||
89 | $names = $bundleMetadata->getPhpcrMetadata()->getDocumentNames(); |
||
90 | |||
91 | foreach ($names as $name) { |
||
92 | $extendedName = $name; |
||
93 | |||
94 | $dest_file = sprintf( |
||
95 | '%s/%s.php', |
||
96 | $bundleMetadata->getPhpcrMetadata()->getExtendedDocumentDirectory(), |
||
97 | $name |
||
98 | ); |
||
99 | $src_file = sprintf( |
||
100 | '%s/%s.php', |
||
101 | $bundleMetadata->getPhpcrMetadata()->getDocumentDirectory(), |
||
102 | $extendedName |
||
103 | ); |
||
104 | |||
105 | if (!is_file($src_file)) { |
||
106 | $extendedName = 'Base'.$name; |
||
107 | $src_file = sprintf( |
||
108 | '%s/%s.php', |
||
109 | $bundleMetadata->getPhpcrMetadata()->getDocumentDirectory(), |
||
110 | $extendedName |
||
111 | ); |
||
112 | |||
113 | if (!is_file($src_file)) { |
||
114 | $output->writeln(sprintf(' ! <info>%s</info>', $extendedName)); |
||
115 | |||
116 | continue; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | if (is_file($dest_file)) { |
||
121 | $output->writeln(sprintf(' ~ <info>%s</info>', $name)); |
||
122 | } else { |
||
123 | $output->writeln(sprintf(' + <info>%s</info>', $name)); |
||
124 | |||
125 | $string = Mustache::replace($this->getDocumentTemplate(), [ |
||
126 | 'extended_namespace' => $bundleMetadata->getExtendedNamespace(), |
||
127 | 'name' => $extendedName, |
||
128 | 'class' => $name, |
||
129 | 'extended_name' => $name === $extendedName ? 'Base'.$name : $extendedName, |
||
130 | 'namespace' => $bundleMetadata->getNamespace(), |
||
131 | ]); |
||
132 | |||
133 | file_put_contents($dest_file, $string); |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | |||
138 | public function generateDocumentRepositoryFiles(OutputInterface $output, BundleMetadata $bundleMetadata): void |
||
177 | |||
178 | public function getDocumentTemplate(): string |
||
182 | |||
183 | public function getDocumentRepositoryTemplate(): string |
||
187 | } |
||
188 |