-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(REF) Rename various methods/variables to follow "generator" terminology
- Loading branch information
Showing
14 changed files
with
66 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(['[email protected]']); | ||
$gen = \Civix::generator(); | ||
$gen->addMixins(['[email protected]']); | ||
if ($entityName === 'Afform') { | ||
$upgrader->exportAfform($entityId); | ||
$gen->exportAfform($entityId); | ||
} | ||
else { | ||
$upgrader->exportMgd($entityName, $entityId); | ||
$gen->exportMgd($entityName, $entityId); | ||
} | ||
|
||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,11 @@ protected function configure() { | |
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$up = \Civix::generator(); | ||
$up->addMixins(['[email protected]']); | ||
$gen = \Civix::generator(); | ||
$gen->addMixins(['[email protected]']); | ||
|
||
$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, | ||
]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?php | ||
|
||
return function (\CRM\CivixBundle\Generator $upgrader) { | ||
return function (\CRM\CivixBundle\Generator $gen) { | ||
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */ | ||
$io = \Civix::io(); | ||
$prefix = $upgrader->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' => '[email protected]', | ||
]; | ||
$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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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('[email protected]'); | ||
}); | ||
} | ||
elseif ($action === 'b' && $hasSettingMixin) { | ||
$upgrader->updateMixins(function (Mixins $mixins) { | ||
$gen->updateMixins(function (Mixins $mixins) { | ||
$mixins->removeMixin('setting-php'); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
use CRM\CivixBundle\Utils\Formatting; | ||
|
||
return function (\CRM\CivixBundle\Generator $upgrader) { | ||
return function (\CRM\CivixBundle\Generator $gen) { | ||
/* @var \Symfony\Component\Console\Style\SymfonyStyle $io */ | ||
$io = \Civix::io(); | ||
|
||
|
@@ -13,8 +13,8 @@ | |
'find:*.tpl' => '[email protected]', | ||
]; | ||
$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); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 `[email protected]`.', | ||
'This reduces code-duplication and will enable easier updates in the future.', | ||
|
@@ -17,10 +17,10 @@ | |
throw new \RuntimeException('User stopped upgrade'); | ||
} | ||
|
||
$upgrader->addMixins(['[email protected]']); | ||
$gen->addMixins(['[email protected]']); | ||
} | ||
|
||
$upgrader->removeHookDelegation([ | ||
$gen->removeHookDelegation([ | ||
"_{$prefix}_civix_civicrm_entityTypes", | ||
]); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters