1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rey\BitrixMigrations\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
7
|
|
|
use Doctrine\DBAL\Migrations\Configuration\Configuration; |
8
|
|
|
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand; |
9
|
|
|
|
10
|
|
|
class MigrationsGenerateDoctrineCommand extends GenerateCommand |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* {@inheritdoc} |
14
|
|
|
*/ |
15
|
|
|
protected function configure() |
16
|
|
|
{ |
17
|
|
|
parent::configure(); |
18
|
|
|
$this->setName('bitrix:' . $this->getName()); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param Doctrine\DBAL\Migrations\Configuration\Configuration $configuration |
23
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
24
|
|
|
* @param string $version |
25
|
|
|
* @param string|null $up |
26
|
|
|
* @param string|null $down |
27
|
|
|
* |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
|
|
protected function generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null) |
31
|
|
|
{ |
32
|
|
|
$abstractMigrationClass = $configuration->getMigrationsAbstractClass(); |
|
|
|
|
33
|
|
|
$example = "// \$this->enableBitrixAPI(); //include and configuration Bitrix API\n"; |
34
|
|
|
|
35
|
|
|
$up = $example . $up; |
36
|
|
|
$down = $example . $down; |
37
|
|
|
$path = parent::generateMigration($configuration, $input, $version, $up, $down); |
38
|
|
|
|
39
|
|
|
$migrationContent = file_get_contents($path); |
40
|
|
|
|
41
|
|
|
$migrationContent = str_replace( |
42
|
|
|
'Doctrine\DBAL\Migrations\AbstractMigration', |
43
|
|
|
$abstractMigrationClass.' as AbstractMigration', |
44
|
|
|
$migrationContent |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
$migrationContent = str_replace( |
48
|
|
|
'use '.$abstractMigrationClass, |
49
|
|
|
'use CModule, CMain, CIBlock, CForm;// etc. Bitrix api classes' . "\n" |
50
|
|
|
. 'use '.$abstractMigrationClass, |
51
|
|
|
$migrationContent |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
file_put_contents($path, $migrationContent); |
55
|
|
|
|
56
|
|
|
return $path; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.