diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 245aeaee..2f4d44f4 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -29,4 +29,10 @@
+
+
+
+
+
+
diff --git a/src/CRM/CivixBundle/CivixTestListener.php b/src/CRM/CivixBundle/CivixTestListener.php
new file mode 100644
index 00000000..99760062
--- /dev/null
+++ b/src/CRM/CivixBundle/CivixTestListener.php
@@ -0,0 +1,13 @@
+upgrader === NULL) {
- $this->upgrader = new Upgrader(new Path(\CRM\CivixBundle\Application::findExtDir()));
- }
- return $this->upgrader;
- }
-
protected function confirm(InputInterface $input, OutputInterface $output, $message, $default = TRUE) {
$message = '' . $message . ''; /* FIXME Let caller stylize */
if ($input->getOption('yes')) {
diff --git a/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php b/src/CRM/CivixBundle/Command/AddManagedEntityCommand.php
index 07a672f8..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 = $this->getUpgrader();
- $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 d48f8429..9107c8a3 100644
--- a/src/CRM/CivixBundle/Command/AddServiceCommand.php
+++ b/src/CRM/CivixBundle/Command/AddServiceCommand.php
@@ -23,20 +23,20 @@ protected function configure() {
}
protected function execute(InputInterface $input, OutputInterface $output) {
- $up = $this->getUpgrader();
- $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');
- $this->getIO()->note([
+ Civix::io()->note([
'The service name is a short machine name. It may appear in contexts like:',
sprintf('Civi::service("%s")->doSomething()', $defaultName),
sprintf('It is recommended to always have a naming prefix (such as "%s").', $servicePrefix),
]);
- $serviceName = $this->getIO()->ask('Service name', $defaultName, function ($answer) {
+ $serviceName = Civix::io()->ask('Service name', $defaultName, function ($answer) {
if ('' === trim($answer)) {
throw new \Exception('Service name cannot be empty');
}
@@ -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 2de4cab6..6438f022 100644
--- a/src/CRM/CivixBundle/Command/UpgradeCommand.php
+++ b/src/CRM/CivixBundle/Command/UpgradeCommand.php
@@ -3,7 +3,7 @@
use CRM\CivixBundle\Builder\Module;
use Civix;
-use CRM\CivixBundle\Upgrader;
+use CRM\CivixBundle\Generator;
use CRM\CivixBundle\Utils\Files;
use CRM\CivixBundle\Utils\Naming;
use Symfony\Component\Console\Input\InputInterface;
@@ -39,8 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$startVer = $input->getOption('start');
if ($startVer !== 'current') {
$verAliases = ['0' => '13.10.0'];
- $upgrader = new Upgrader(new Path(\CRM\CivixBundle\Application::findExtDir()));
- $upgrader->updateFormatVersion($verAliases[$startVer] ?? $startVer);
+ Civix::generator()->updateFormatVersion($verAliases[$startVer] ?? $startVer);
}
$this->executeIncrementalUpgrades();
@@ -74,10 +73,10 @@ protected function executeIncrementalUpgrades() {
$io->section("Upgrade v{$lastVersion} => v{$upgradeVersion}");
$io->writeln("Executing upgrade script $upgradeFile");
- $upgrader = new Upgrader(new Path(\CRM\CivixBundle\Application::findExtDir()));
+ $gen = Civix::generator();
$func = require $upgradeFile;
- $func($upgrader);
- $upgrader->updateFormatVersion($upgradeVersion);
+ $func($gen);
+ $gen->updateFormatVersion($upgradeVersion);
$lastVersion = $upgradeVersion;
}
}
@@ -86,10 +85,10 @@ protected function executeGenericUpgrade(): void {
$io = \Civix::io();
$io->title('General upgrade');
- $upgrader = new Upgrader(new Path(\CRM\CivixBundle\Application::findExtDir()));
- $upgrader->cleanEmptyHooks();
- $upgrader->cleanEmptyLines();
- $upgrader->reconcileMixins();
+ $gen = Civix::generator();
+ $gen->cleanEmptyHooks();
+ $gen->cleanEmptyLines();
+ $gen->reconcileMixins();
/**
* @var \CRM\CivixBundle\Builder\Info $info
diff --git a/src/CRM/CivixBundle/Upgrader.php b/src/CRM/CivixBundle/Generator.php
similarity index 99%
rename from src/CRM/CivixBundle/Upgrader.php
rename to src/CRM/CivixBundle/Generator.php
index 32b9cbda..9e220360 100644
--- a/src/CRM/CivixBundle/Upgrader.php
+++ b/src/CRM/CivixBundle/Generator.php
@@ -12,9 +12,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;
/**
- * The "Upgrader" class is a utility provided to various upgrade-scripts.
+ * The "Generator" class is a utility provided to various upgrade-scripts.
*/
-class Upgrader {
+class Generator {
/**
* @var \Symfony\Component\Console\Input\InputInterface
diff --git a/src/Civix.php b/src/Civix.php
index b190cdbc..98b44792 100644
--- a/src/Civix.php
+++ b/src/Civix.php
@@ -194,6 +194,24 @@ public static function mixinBackports(): array {
return self::$cache[__FUNCTION__];
}
+ /**
+ * Get the generator-object for manipulating the extension.
+ *
+ * @param string|Path|null $extDir
+ * Base path of the extension that we wish to manipulate.
+ * If null, use the default (per CWD).
+ *
+ * @return \CRM\CivixBundle\Generator
+ */
+ public static function generator($extDir = NULL): \CRM\CivixBundle\Generator {
+ $extDir = ($extDir === NULL) ? Civix::extdir() : Path::for($extDir);
+ $cacheKey = (string) $extDir;
+ if (!isset(self::$cache[__FUNCTION__][$cacheKey])) {
+ self::$cache[__FUNCTION__][$cacheKey] = new \CRM\CivixBundle\Generator($extDir);
+ }
+ return self::$cache[__FUNCTION__][$cacheKey];
+ }
+
/**
* @return \CRM\CivixBundle\UpgradeList
*/
@@ -204,4 +222,12 @@ public static function upgradeList(): \CRM\CivixBundle\UpgradeList {
return self::$cache[__FUNCTION__];
}
+ public static function reset(): void {
+ $new = [];
+ if (isset(static::$cache['boot'])) {
+ $new['boot'] = static::$cache['boot'];
+ }
+ static::$cache = $new;
+ }
+
}
diff --git a/tests/e2e/CRMNamingTest.php b/tests/e2e/CRMNamingTest.php
index e35fcea2..86df7d00 100644
--- a/tests/e2e/CRMNamingTest.php
+++ b/tests/e2e/CRMNamingTest.php
@@ -3,8 +3,6 @@
namespace E2E;
use CRM\CivixBundle\Builder\Info;
-use CRM\CivixBundle\Upgrader;
-use CRM\CivixBundle\Utils\Path;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\NullOutput;
@@ -15,7 +13,7 @@ class CRMNamingTest extends \PHPUnit\Framework\TestCase {
public static $key = 'civix_crmnaming';
/**
- * @var \CRM\CivixBundle\Upgrader
+ * @var \CRM\CivixBundle\Generator
*/
protected $upgrader;
@@ -32,7 +30,7 @@ public function setUp(): void {
]);
\Civix::ioStack()->push(new ArgvInput(), new NullOutput());
- $this->upgrader = new Upgrader(new Path(static::getExtPath()));
+ $this->upgrader = \Civix::generator(static::getExtPath());
$this->upgrader->updateInfo(function(Info $info) {
// FIXME: Allow "_" instead of "/"
$info->get()->civix->namespace = 'CRM/NamingTest';
diff --git a/tests/e2e/CiviNamingTest.php b/tests/e2e/CiviNamingTest.php
index 6d2bfd37..15b3d816 100644
--- a/tests/e2e/CiviNamingTest.php
+++ b/tests/e2e/CiviNamingTest.php
@@ -3,8 +3,6 @@
namespace E2E;
use CRM\CivixBundle\Builder\Info;
-use CRM\CivixBundle\Upgrader;
-use CRM\CivixBundle\Utils\Path;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\NullOutput;
@@ -15,7 +13,7 @@ class CiviNamingTest extends \PHPUnit\Framework\TestCase {
public static $key = 'civix_civinaming';
/**
- * @var \CRM\CivixBundle\Upgrader
+ * @var \CRM\CivixBundle\Generator
*/
protected $upgrader;
@@ -32,7 +30,7 @@ public function setUp(): void {
]);
\Civix::ioStack()->push(new ArgvInput(), new NullOutput());
- $this->upgrader = new Upgrader(new Path(static::getExtPath()));
+ $this->upgrader = \Civix::generator(static::getExtPath());
$this->upgrader->updateInfo(function(Info $info) {
// FIXME: Allow "\" instead of "/"
$info->get()->civix->namespace = 'Civi/NamingTest';
diff --git a/tests/e2e/CivixProjectTestTrait.php b/tests/e2e/CivixProjectTestTrait.php
index 016273c3..8ae42baf 100644
--- a/tests/e2e/CivixProjectTestTrait.php
+++ b/tests/e2e/CivixProjectTestTrait.php
@@ -3,7 +3,7 @@
namespace E2E;
use CRM\CivixBundle\Application;
-use CRM\CivixBundle\Upgrader;
+use CRM\CivixBundle\Generator;
use CRM\CivixBundle\Utils\Files;
use CRM\CivixBundle\Utils\Path;
use ProcessHelper\ProcessHelper as PH;
@@ -195,14 +195,14 @@ public function civixUpgrade(array $options = []): CommandTester {
/**
* Get the upgrade-utility/helper.
*
- * @return \CRM\CivixBundle\Upgrader
+ * @return \CRM\CivixBundle\Generator
*/
- public function civixUpgradeHelper(): Upgrader {
+ public function civixGeneratorHelper(): Generator {
$input = new ArrayInput([]);
$output = new StreamOutput(fopen('php://memory', 'w', FALSE));
\Civix::ioStack()->push($input, $output);
try {
- return new Upgrader(static::getExtPath());
+ return \Civix::generator(static::getExtPath());
}
finally {
\Civix::ioStack()->pop();
diff --git a/upgrades/16.10.0.up.php b/upgrades/16.10.0.up.php
index bba828c5..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\Upgrader $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 1db500ea..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\Upgrader $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 c66e628b..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\Upgrader $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 5669b8fb..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 97e3d6e1..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\Upgrader $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 1909598b..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\Upgrader $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 4788e2a4..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\Upgrader $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 f90c75ed..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 35e97431..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\Upgrader $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 3a7f9fc3..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\Upgrader $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();