-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Unable to implement SiteAliasManagerAwareInterface #3394
Comments
Hi @himerus! Thanks for the example module and clear bug report. I can confirm the ill behavior. The issue is that the inflectors at drush/src/Runtime/DependencyInjection.php Lines 104 to 108 in afecae9
|
Until we have a dependency injection solution, your code should use |
Thanks @weitzman! Yeah, the docs at http://docs.drush.org/en/master/site-alias-manager/ weren't super helpful, and until I wrap my head around some of the underpinnings, I was spinning my wheels a bit.
|
See #3406 |
Hi there. I'm still seeing this problem with Drush 9.7.1 despite seemingly following all the instructions in the docs and in this thread. I'm implementing the interface and using the trait, but I still end up with |
I am finding Drush::aliasManager() still works in Drupal 9.1 + Drush 10, but is deprecated; but the suggested siteAliasManager() on the same service returns null. I have spent two days attempting to find any working guidance on the correct way to do it. Is this a bug? All I need to do is simply execute a drush command from a module's post-install hook. FWIW, I eliminated the error by instantiating the SiteAliasManager and setting it into the service. $command = \Drupal::service('my_service_implementing_siteawarenterface'); |
I think this has been fixed at some point since I posted my comment. On Drush 10.5, it seems to work if you try accessing Also, I would strongly recommend using proper dependency injection when possible and not the |
Issue Summary
The basics are this: I'm attempting to write a Drush command that uses the site aliases available to an environment in order to handle creating some custom sync/deploy commands between environments. In order to do so I need to implement the
SiteAliasManagerAwareInterface
and have access to the available aliases indrush/sites/mysite.yml
.I've used the
drush @myalias generate
command to build out the sample module and Drush command file. Then I replace the contents (and edit appropriately) from any of the Drush commands I found toimplements SiteAliasManagerAwareInterface
.Replicate issue
I've created a sample module to demonstrate what I'm trying to accomplish, the issue I've noted, and to avoid having to post the contents of everything from the module/command file in this issue directly.
Sample module demonstrating issue:
sam_test
From SamTestCommands.php
Resulting Error:
drush @mysite-alias sam:test
:Conclusion
Either I'm doing something really wrong, and have wasted a day or two for nothing, or there's something wrong with implementing the
SiteAliasManagerAwareInterface
outside of the default Drush commands in Drush 9.The text was updated successfully, but these errors were encountered: