diff --git a/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php b/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php
index f848d3e7..ba470258 100644
--- a/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php
+++ b/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php
@@ -42,13 +42,13 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// Boot CiviCRM to use api4
Civix::boot(['output' => $output]);
- $upgrader = \Civix::generator();
- $upgrader->addMixins(['mgd-php@1.0']);
+ $gen = \Civix::generator();
+ $gen->addMixins(['mgd-php@1.0']);
if ($entityName === 'Afform') {
- $upgrader->exportAfform($entityId);
+ $gen->exportAfform($entityId);
}
else {
- $upgrader->exportMgd($entityName, $entityId);
+ $gen->exportMgd($entityName, $entityId);
}
return 0;
diff --git a/src/CRM/CivixBundle/Command/AddServiceCommand.php b/src/CRM/CivixBundle/Command/AddServiceCommand.php
index 6f2d10b4..9107c8a3 100644
--- a/src/CRM/CivixBundle/Command/AddServiceCommand.php
+++ b/src/CRM/CivixBundle/Command/AddServiceCommand.php
@@ -23,11 +23,11 @@ protected function configure() {
}
protected function execute(InputInterface $input, OutputInterface $output) {
- $up = \Civix::generator();
- $up->addMixins(['scan-classes@1.0']);
+ $gen = \Civix::generator();
+ $gen->addMixins(['scan-classes@1.0']);
- $servicePrefix = $up->infoXml->getFile();
- $namespace = Naming::coerceNamespace($up->infoXml->getNamespace(), $input->getOption('naming'));
+ $servicePrefix = $gen->infoXml->getFile();
+ $namespace = Naming::coerceNamespace($gen->infoXml->getNamespace(), $input->getOption('naming'));
if ($input->isInteractive()) {
$defaultName = $input->getArgument('name') ?? Naming::createServiceName($servicePrefix, 'myService');
@@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$baseNameParts = array_map('ucfirst', explode('.', $baseName));
$className = Naming::createClassName($namespace, ...$baseNameParts);
- $up->addClass($className, 'service.php.php', [
+ $gen->addClass($className, 'service.php.php', [
'service' => $serviceName,
]);
}
diff --git a/src/CRM/CivixBundle/Command/UpgradeCommand.php b/src/CRM/CivixBundle/Command/UpgradeCommand.php
index a9e84203..6438f022 100644
--- a/src/CRM/CivixBundle/Command/UpgradeCommand.php
+++ b/src/CRM/CivixBundle/Command/UpgradeCommand.php
@@ -73,10 +73,10 @@ protected function executeIncrementalUpgrades() {
$io->section("Upgrade v{$lastVersion} => v{$upgradeVersion}");
$io->writeln("Executing upgrade script $upgradeFile");
- $upgrader = Civix::generator();
+ $gen = Civix::generator();
$func = require $upgradeFile;
- $func($upgrader);
- $upgrader->updateFormatVersion($upgradeVersion);
+ $func($gen);
+ $gen->updateFormatVersion($upgradeVersion);
$lastVersion = $upgradeVersion;
}
}
@@ -85,10 +85,10 @@ protected function executeGenericUpgrade(): void {
$io = \Civix::io();
$io->title('General upgrade');
- $upgrader = Civix::generator();
- $upgrader->cleanEmptyHooks();
- $upgrader->cleanEmptyLines();
- $upgrader->reconcileMixins();
+ $gen = Civix::generator();
+ $gen->cleanEmptyHooks();
+ $gen->cleanEmptyLines();
+ $gen->reconcileMixins();
/**
* @var \CRM\CivixBundle\Builder\Info $info
diff --git a/tests/e2e/CivixProjectTestTrait.php b/tests/e2e/CivixProjectTestTrait.php
index 4fc4b98a..8ae42baf 100644
--- a/tests/e2e/CivixProjectTestTrait.php
+++ b/tests/e2e/CivixProjectTestTrait.php
@@ -197,7 +197,7 @@ public function civixUpgrade(array $options = []): CommandTester {
*
* @return \CRM\CivixBundle\Generator
*/
- public function civixUpgradeHelper(): Generator {
+ public function civixGeneratorHelper(): Generator {
$input = new ArrayInput([]);
$output = new StreamOutput(fopen('php://memory', 'w', FALSE));
\Civix::ioStack()->push($input, $output);
diff --git a/upgrades/16.10.0.up.php b/upgrades/16.10.0.up.php
index 5a8756d6..56f84cd5 100644
--- a/upgrades/16.10.0.up.php
+++ b/upgrades/16.10.0.up.php
@@ -5,18 +5,18 @@
*
* At some point in the future, this step could be removed if we configure `info.xml`'s `` option.
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
$io = \Civix::io();
- if (!empty($upgrader->infoXml->get()->upgrader)) {
+ if (!empty($gen->infoXml->get()->upgrader)) {
$io->note("Found tag. Skip hook_postInstall.");
return;
}
// Give a notice if the new `CRM/*/Upgrader/Base` has a substantive change.
// Note: The change is actually done in the generic regen. This is just a notice.
- $phpBaseClass = \CRM\CivixBundle\Utils\Naming::createClassName($upgrader->infoXml->getNamespace(), 'Upgrader', 'Base');
- $phpBaseFile = \CRM\CivixBundle\Utils\Naming::createClassFile($upgrader->infoXml->getNamespace(), 'Upgrader', 'Base');
+ $phpBaseClass = \CRM\CivixBundle\Utils\Naming::createClassName($gen->infoXml->getNamespace(), 'Upgrader', 'Base');
+ $phpBaseFile = \CRM\CivixBundle\Utils\Naming::createClassFile($gen->infoXml->getNamespace(), 'Upgrader', 'Base');
if (file_exists($phpBaseFile)) {
$content = file_get_contents($phpBaseFile);
if (preg_match('|CRM_Core_BAO_Setting::setItem\(.revision, *.Extension.|', $content)) {
@@ -31,11 +31,11 @@
}
}
- $upgrader->addHookDelegation('civicrm_postInstall', '',
+ $gen->addHookDelegation('civicrm_postInstall', '',
"This hook is important for supporting the new version of $phpBaseClass.");
}
else {
- $upgrader->addHookDelegation('civicrm_postInstall', '',
+ $gen->addHookDelegation('civicrm_postInstall', '',
'If you use civix to facilitate database upgrades ("civix generate:upgrader"), then you should enable this stub. Otherwise, it is not needed.');
}
diff --git a/upgrades/19.06.2.up.php b/upgrades/19.06.2.up.php
index 09c1ae97..8539bbdb 100644
--- a/upgrades/19.06.2.up.php
+++ b/upgrades/19.06.2.up.php
@@ -16,15 +16,15 @@
* To be consistent and forward-compatible, you should consider updating your
* existing unit-tests to use the name base-classes.
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */
$io = \Civix::io();
- $testFiles = \CRM\CivixBundle\Utils\Files::findFiles($upgrader->baseDir->string('tests'), '*.php');
- $upgrader->updateTextFiles($testFiles, function(string $file, string $content) use ($io, $upgrader) {
+ $testFiles = \CRM\CivixBundle\Utils\Files::findFiles($gen->baseDir->string('tests'), '*.php');
+ $gen->updateTextFiles($testFiles, function(string $file, string $content) use ($io, $gen) {
$old = 'PHPUnit_Framework_TestCase';
$new = 'PHPUnit\Framework\TestCase';
- $relFile = \CRM\CivixBundle\Utils\Files::relativize($file, $upgrader->baseDir->string() . '/');
+ $relFile = \CRM\CivixBundle\Utils\Files::relativize($file, $gen->baseDir->string() . '/');
if (strpos($content, $old) === FALSE) {
return $content;
diff --git a/upgrades/20.06.0.up.php b/upgrades/20.06.0.up.php
index 07246b4e..09e47ce9 100644
--- a/upgrades/20.06.0.up.php
+++ b/upgrades/20.06.0.up.php
@@ -4,16 +4,16 @@
* If you have a generated `phpunit.xml` or `phpunit.xml.dist` file, it may include the old option `syntaxCheck="false"`.
* You can remove this. The option has been inert and will raise errors in newer versions of PHPUnit.
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */
$io = \Civix::io();
$files = array_filter([
- $upgrader->baseDir->string('phpunit.xml'),
- $upgrader->baseDir->string('phpunit.xml.dist'),
+ $gen->baseDir->string('phpunit.xml'),
+ $gen->baseDir->string('phpunit.xml.dist'),
], 'file_exists');
- $upgrader->updateTextFiles($files, function(string $file, string $oldContent) use ($io, $upgrader) {
- $relFile = \CRM\CivixBundle\Utils\Files::relativize($file, $upgrader->baseDir->string() . '/');
+ $gen->updateTextFiles($files, function(string $file, string $oldContent) use ($io, $gen) {
+ $relFile = \CRM\CivixBundle\Utils\Files::relativize($file, $gen->baseDir->string() . '/');
$content = $oldContent;
$content = preg_replace(';(\s+)syntaxCheck="[^\"]+">;', '>', $content);
diff --git a/upgrades/22.05.0.up.php b/upgrades/22.05.0.up.php
index bb64bb68..85f00ce6 100644
--- a/upgrades/22.05.0.up.php
+++ b/upgrades/22.05.0.up.php
@@ -1,9 +1,9 @@
infoXml->getFile();
+ $prefix = $gen->infoXml->getFile();
$io->note([
"Civix v22.05 converts several functions to mixins. This reduces code-duplication and will enable easier updates in the future.",
@@ -32,8 +32,8 @@
'glob:*.theme.php' => 'theme-php@1.0.0',
];
$mixins = array_filter($filePatterns,
- function (string $mixin, string $pattern) use ($upgrader, $io) {
- $flagFiles = $upgrader->baseDir->search($pattern);
+ function (string $mixin, string $pattern) use ($gen, $io) {
+ $flagFiles = $gen->baseDir->search($pattern);
$io->note($flagFiles
? "Enable \"$mixin\". There are files matching pattern \"$pattern\"."
: "Skip \"$mixin\". There are no files matching pattern \"$pattern\"."
@@ -42,9 +42,9 @@ function (string $mixin, string $pattern) use ($upgrader, $io) {
},
ARRAY_FILTER_USE_BOTH
);
- $upgrader->addMixins($mixins);
+ $gen->addMixins($mixins);
- $upgrader->removeHookDelegation([
+ $gen->removeHookDelegation([
"_{$prefix}_civix_civicrm_angularModules",
"_{$prefix}_civix_civicrm_managed",
"_{$prefix}_civix_civicrm_alterSettingsFolders",
diff --git a/upgrades/22.05.2.up.php b/upgrades/22.05.2.up.php
index 42be4be0..bc2b9430 100644
--- a/upgrades/22.05.2.up.php
+++ b/upgrades/22.05.2.up.php
@@ -3,14 +3,14 @@
use CRM\CivixBundle\Builder\Mixins;
use CRM\CivixBundle\Utils\EvilEx;
-return function (\CRM\CivixBundle\Generator $upgrader) {
- $mixins = new Mixins($upgrader->infoXml, $upgrader->baseDir->string('mixin'));
+return function (\CRM\CivixBundle\Generator $gen) {
+ $mixins = new Mixins($gen->infoXml, $gen->baseDir->string('mixin'));
$declared = $mixins->getDeclaredMixinConstraints();
$hasSettingMixin = (bool) preg_grep('/^setting-php@/', $declared);
$action = NULL;
- $upgrader->updateModulePhp(function (\CRM\CivixBundle\Builder\Info $info, string $content) use ($upgrader, $hasSettingMixin, &$action) {
- $prefix = $upgrader->infoXml->getFile();
+ $gen->updateModulePhp(function (\CRM\CivixBundle\Builder\Info $info, string $content) use ($gen, $hasSettingMixin, &$action) {
+ $prefix = $gen->infoXml->getFile();
$hookFunc = "{$prefix}_civicrm_alterSettingsFolders";
$hookBody = [
'static $configured = FALSE;',
@@ -23,7 +23,7 @@
'}',
];
- $newContent = EvilEx::rewriteMultilineChunk($content, $hookBody, function(array $matchLines) use ($hookFunc, $content, $upgrader, $hasSettingMixin, &$action) {
+ $newContent = EvilEx::rewriteMultilineChunk($content, $hookBody, function(array $matchLines) use ($hookFunc, $content, $gen, $hasSettingMixin, &$action) {
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */
$io = \Civix::io();
$matchLineKeys = array_keys($matchLines);
@@ -32,7 +32,7 @@
$focusEnd = max($matchLineKeys);
$io->note("The following chunk resembles an older template for \"{$hookFunc}()\".");
- $upgrader->showCode($allLines, $focusStart - 4, $focusEnd + 4, $focusStart, $focusEnd);
+ $gen->showCode($allLines, $focusStart - 4, $focusEnd + 4, $focusStart, $focusEnd);
if ($hasSettingMixin) {
$io->note([
@@ -55,12 +55,12 @@
});
if ($action === 'm' && !$hasSettingMixin) {
- $upgrader->updateMixins(function (Mixins $mixins) {
+ $gen->updateMixins(function (Mixins $mixins) {
$mixins->addMixin('setting-php@1.0.0');
});
}
elseif ($action === 'b' && $hasSettingMixin) {
- $upgrader->updateMixins(function (Mixins $mixins) {
+ $gen->updateMixins(function (Mixins $mixins) {
$mixins->removeMixin('setting-php');
});
}
diff --git a/upgrades/22.10.0.up.php b/upgrades/22.10.0.up.php
index 169b6270..6b9fdd9d 100644
--- a/upgrades/22.10.0.up.php
+++ b/upgrades/22.10.0.up.php
@@ -7,15 +7,15 @@
*
* Just add the '` bit to everything.
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
- $upgrader->updateInfo(function (\CRM\CivixBundle\Builder\Info $info) use ($upgrader) {
+ $gen->updateInfo(function (\CRM\CivixBundle\Builder\Info $info) use ($gen) {
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */
$io = \Civix::io();
$loaders = $info->getClassloaders();
$prefixes = array_column($loaders, 'prefix');
- if (file_exists($upgrader->baseDir->string('CRM')) && !in_array('CRM_', $prefixes)) {
+ if (file_exists($gen->baseDir->string('CRM')) && !in_array('CRM_', $prefixes)) {
$io->section('"CRM" Class-loader');
$io->note([
'Older templates enabled class-loading via "hook_config" and "include_path".',
diff --git a/upgrades/22.12.1.up.php b/upgrades/22.12.1.up.php
index 5784f979..2bde5cb6 100644
--- a/upgrades/22.12.1.up.php
+++ b/upgrades/22.12.1.up.php
@@ -11,15 +11,15 @@
* - Use core's base class
* - Remove old base class
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
$io = \Civix::io();
$io->section('Lifecycle Hooks: Install, Upgrade, etc');
- $info = $upgrader->infoXml;
+ $info = $gen->infoXml;
$MIN_COMPAT = '5.38';
$oldCompat = $info->getCompatibilityVer();
$nameSpace = $info->getNamespace();
- $mainFile = $upgrader->baseDir->string($info->getFile() . '.php');
+ $mainFile = $gen->baseDir->string($info->getFile() . '.php');
$upgraderClass = Naming::createClassName($nameSpace, 'Upgrader');
$upgraderFile = Naming::createClassFile($nameSpace, 'Upgrader');
$upgraderBaseClass = Naming::createClassName($nameSpace, 'Upgrader', 'Base');
@@ -70,7 +70,7 @@
}
$prefix = $info->getFile();
- $upgrader->removeHookDelegation([
+ $gen->removeHookDelegation([
"_{$prefix}_civix_civicrm_postInstall",
"_{$prefix}_civix_civicrm_uninstall",
"_{$prefix}_civix_civicrm_disable",
@@ -78,7 +78,7 @@
]);
if ($hasUpgrader) {
- $upgrader->updateInfo(function(\CRM\CivixBundle\Builder\Info $info) use ($MIN_COMPAT, $upgraderClass) {
+ $gen->updateInfo(function(\CRM\CivixBundle\Builder\Info $info) use ($MIN_COMPAT, $upgraderClass) {
$info->raiseCompatibilityMinimum($MIN_COMPAT);
// Add tag
if (!$info->get()->xpath('upgrader')) {
@@ -86,7 +86,7 @@
}
});
// Switch base class
- $upgrader->updateTextFiles([$upgraderFile], function(string $file, string $content) use ($upgraderBaseClass) {
+ $gen->updateTextFiles([$upgraderFile], function(string $file, string $content) use ($upgraderBaseClass) {
return str_replace($upgraderBaseClass, 'CRM_Extension_Upgrader_Base', $content);
});
}
diff --git a/upgrades/23.01.0.up.php b/upgrades/23.01.0.up.php
index 87dcaa5e..d73c2558 100644
--- a/upgrades/23.01.0.up.php
+++ b/upgrades/23.01.0.up.php
@@ -1,7 +1,7 @@
'smarty-v2@1.0.0',
];
$mixins = array_filter($filePatterns,
- function (string $mixin, string $pattern) use ($upgrader, $io, &$previewChanges) {
- $flagFiles = $upgrader->baseDir->search($pattern);
+ function (string $mixin, string $pattern) use ($gen, $io, &$previewChanges) {
+ $flagFiles = $gen->baseDir->search($pattern);
$previewChanges[] = [
'info.xml',
$flagFiles ? "Enable $mixin" : "Skip $mixin. (No files match \"$pattern\")",
@@ -40,6 +40,6 @@ function (string $mixin, string $pattern) use ($upgrader, $io, &$previewChanges)
throw new \RuntimeException('User stopped upgrade');
}
- $upgrader->addMixins($mixins);
+ $gen->addMixins($mixins);
};
diff --git a/upgrades/23.02.0.up.php b/upgrades/23.02.0.up.php
index cc931b51..4e380595 100644
--- a/upgrades/23.02.0.up.php
+++ b/upgrades/23.02.0.up.php
@@ -3,11 +3,11 @@
/**
* Upgrade hook_civicrm_entityTypes to use mixin
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
- $prefix = $upgrader->infoXml->getFile();
+ $prefix = $gen->infoXml->getFile();
- if (is_dir($upgrader->baseDir->string('xml/schema/CRM'))) {
+ if (is_dir($gen->baseDir->string('xml/schema/CRM'))) {
\Civix::io()->note([
'Civix 23.02 removes `*_civix_civicrm_entityTypes` in favor of a mixin `entity-types-php@1.0`.',
'This reduces code-duplication and will enable easier updates in the future.',
@@ -17,10 +17,10 @@
throw new \RuntimeException('User stopped upgrade');
}
- $upgrader->addMixins(['entity-types-php@1.0']);
+ $gen->addMixins(['entity-types-php@1.0']);
}
- $upgrader->removeHookDelegation([
+ $gen->removeHookDelegation([
"_{$prefix}_civix_civicrm_entityTypes",
]);
diff --git a/upgrades/23.02.1.up.php b/upgrades/23.02.1.up.php
index 6ea9fed8..30fa1a8f 100644
--- a/upgrades/23.02.1.up.php
+++ b/upgrades/23.02.1.up.php
@@ -5,9 +5,9 @@
* However, as older extensions adopt newer technologies (like `Civi\Api4`), it helps
* to add a similar to them.
*/
-return function (\CRM\CivixBundle\Generator $upgrader) {
+return function (\CRM\CivixBundle\Generator $gen) {
- $upgrader->updateInfo(function (\CRM\CivixBundle\Builder\Info $info) use ($upgrader) {
+ $gen->updateInfo(function (\CRM\CivixBundle\Builder\Info $info) use ($gen) {
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */
$io = \Civix::io();