-
Notifications
You must be signed in to change notification settings - Fork 304
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
Add a method Robo::getCommandInstance. #675
Conversation
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.
Looks pretty clean to me
Any chance to get this merged? Still interested in this! |
Did you test it? Does it satisfy your use case? What is your use case? |
I tested this out. My use case is to have a single command that sets up a development environment for a Drupal website. This command is intended to run multiple other Robo commands, to set up config files like In my test I tried to create a command that calls 2 other commands directly: My commands live in a Robo extension and are set up using the instructions at https://robo.li/extending/#register-command-files-via-psr-4-autoloading. I am using Robo 2.2.1, and this PR applies cleanly on it. The commit that tests this PR is code-lab-eu/robo-drupal-setup@1c549ad I am getting an error, it appears that in my setup the command file I am trying to instantiate is not registered in the container.
Also I am getting complaints about a missing |
@pfrenssen: Could you compare with |
I tried with Robo 3 but this gives a similar error:
I'm not clear what you mean by comparing with |
Overview
This pull request:
Summary
Adds static method Robo::getCommandInstance
Description
It is frequently a request by command authors, who, in order to implement some command
my:a
which in turn should execute other commandsmy:b
andmy:c
, the desire of the author is to recover the commandfile instance for the subcommands so that the command's implementation methods may be called directly.In general, this technique has been discouraged, because calling an implementation method directly omits any hook evaluation, so the result might not be the same as running
my:b
andmy:c
e.g. via exec. However, the advantage of having a reference to the command object is that the direct command result is available, whereas using exec or$application->run()
all you would get is stdout.