-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow registering of command info alterer services #3447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
greg-1-anderson
merged 4 commits into
drush-ops:master
from
claudiu-cristea:command-info-alter
Mar 7, 2018
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1fa850f
Allow to register command info alterer services.
claudiu-cristea b0da314
Remove unused statement.
claudiu-cristea 0484eb1
Add debug logging. Document command info alter.
claudiu-cristea 7850f64
Remove LoggerAwareInterface, LoggerAwareTrait.
claudiu-cristea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| namespace Unish; | ||
|
|
||
| use Webmozart\PathUtil\Path; | ||
|
|
||
| /** | ||
| * @group commands | ||
| * | ||
| */ | ||
| class CommandInfoAlterTest extends CommandUnishTestCase | ||
| { | ||
| use TestModuleHelperTrait; | ||
|
|
||
| /** | ||
| * Tests command info alter. | ||
| */ | ||
| public function testCommandInfoAlter() | ||
| { | ||
| $this->setUpDrupal(1, true); | ||
| $this->setupModulesForTests(['woot'], Path::join(__DIR__, 'resources/modules/d8')); | ||
| $this->drush('pm-enable', ['woot']); | ||
| $this->drush('woot:altered', [], ['help' => true]); | ||
| $this->assertNotContains('woot-initial-alias', $this->getOutput()); | ||
| $this->assertContains('woot-new-alias', $this->getOutput()); | ||
|
|
||
| // Try to run the command with the initial alias. | ||
| $this->drush('woot-initial-alias', [], [], null, null, self::EXIT_ERROR); | ||
| // Run the command with the altered alias. | ||
| $this->drush('woot-new-alias'); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
16 changes: 16 additions & 0 deletions
16
tests/resources/modules/d8/woot/src/WootCommandInfoAlterer.php
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| namespace Drupal\woot; | ||
|
|
||
| use Consolidation\AnnotatedCommand\CommandInfoAltererInterface; | ||
| use Consolidation\AnnotatedCommand\Parser\CommandInfo; | ||
|
|
||
| class WootCommandInfoAlterer implements CommandInfoAltererInterface | ||
| { | ||
| public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance) | ||
| { | ||
| if ($commandInfo->getName() === 'woot:altered') { | ||
| $commandInfo->setAliases('woot-new-alias'); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably write a debug log message if a module adds one of these.