Can anyone please let me know how to extend existing drush command class.
I am writing a custom module which provides custom content entity and created a devel generate plugin similar to ContentDevelGenerate.
It is working as expected to generate dummy content from UI . I would like to create a drush command as well for the devel generator plugin. Similar to DevelGenerateCommands content method I would like to add additional method to generate my custom content entity.
My drush command class as follows :
<?php namespace Drupalomdb_apiCommands; use Drupaldevel_generateCommandsDevelGenerateCommands; /** * Class to create omdb api entity drush commands. */ class OmdbApiEntityDevelGenerateCommands extends DevelGenerateCommands { /** * Create omdb api entity items by drush command. * * @command devel-generate:omdb-api * @aliases dgen:omdb-api, devel-generate-omdb-api * @pluginId omdb_api_entity_devel_generate * @validate-module-enabled omdb_api * * @param int $num * Number of omdb api entity items to generate. * @param array $options * Array of options as described below. * * @option kill Delete all omdb api entity items before generating new omdb api entity. * @option feedback An integer representing interval for insertion rate logging. * @option skip-fields A comma delimited list of fields to omit when generating random values. * @option languages A comma-separated list of language codes */ public function omdbApiEntities($num = 50, array $options = ['kill' => FALSE, 'feedback' => 1000]) { $this->generate(); } /** * Wrapper for calling the plugin instance generate function. */ public function generate() { $instance = $this->getPluginInstance(); $instance->generate($this->getParameters()); } }
OmdbApiEntityDevelGenerateCommands If i paste this method directly in DevelGenerateCommands class, command is working as expected. So it seems I am missing something to extend the DevelGenerateCommands class.
# drush.services.yml services: omdb_api.devel_generate_commands: class: Drupalomdb_apiCommandsOmdbApiEntityDevelGenerateCommands tags: - { name: develgenerate.command }