-
Notifications
You must be signed in to change notification settings - Fork 46
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
Class naming convention #124
Comments
DCG itself does not force |
OK, I'll post a link to this issue in the Drush Slack channel to see if one of the experts over there can help. Thanks @Chi-teck |
Sounds like has been introduced by drush due to discoverability. However, if we could use PHP to inspect for attributes on classes that have not been loaded, if they are autoloadable, then that could be removed. Do you know if that's possible somehow? |
Yo'll have to implement own command discovery mechanism. That could be done through /**
* {@selfdoc}
*/
final class GeneratorInfoSubscriber implements EventSubscriberInterface {
/**
* {@selfdoc}
*/
public function onGeneratorDiscovery(GeneratorInfo $event): void {
// @todo Implement generator auto-discovery here.
$event->addGenerators(
// Here we are registering just one command with known class name.
// Use Drupal class loader service for dependency injection.
new Example(),
);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
return [GeneratorInfo::class => 'onGeneratorDiscovery'];
}
} For auto discovery you may use reflection like Drush 12 does or tagged services like Drush 11 did. |
Yeah, it sounds like the drush maintainers don't seem to be keen to go for that, see the thread in slack where you also commented. |
Closing as there is nothing to do here. |
We're building code generators for some of our Drupal modules (e.g. ECA, DRD and others) and we just found out, that the class name needs to follow the *Generator name pattern.
Is that really necessary, or could that requirement be removed?
I mean, the classes are properly namespaced and come with all the PHP attributes to declare and make them discoverable. Enforcing the generator being part of the class name feels redundant, doesn't it?
The text was updated successfully, but these errors were encountered: