function _drush_plugin_validate

Helper function which returns an array with a plugin instance for a given id and the validated values ready to be used by the generate() function of the plugin.

5 calls to _drush_plugin_validate()
drush_devel_generate_generate_content_validate in devel_generate/drush/devel_generate.drush8.inc
Implements drush_hook_COMMAND_validate().
drush_devel_generate_generate_menus_validate in devel_generate/drush/devel_generate.drush8.inc
Implements drush_hook_COMMAND_validate().
drush_devel_generate_generate_terms_validate in devel_generate/drush/devel_generate.drush8.inc
Implements drush_hook_COMMAND_validate().
drush_devel_generate_generate_users_validate in devel_generate/drush/devel_generate.drush8.inc
Implements drush_hook_COMMAND_validate().
drush_devel_generate_generate_vocabs_validate in devel_generate/drush/devel_generate.drush8.inc
Implements drush_hook_COMMAND_validate().

File

devel_generate/drush/devel_generate.drush8.inc, line 160

Code

function _drush_plugin_validate($params) {
    $instance_and_values =& drupal_static('drush_devel_generate_generate_validate');
    
    //Getting plugin_id and leaving the command line args
    $plugin_id = array_shift($params);
    if (!isset($instance_and_values[$plugin_id])) {
        
        /** @var DevelGeneratePluginManager $manager */
        $manager = \Drupal::service('plugin.manager.develgenerate');
        
        /** @var DevelGenerateBaseInterface $instance */
        $instance = $manager->createInstance($plugin_id, array());
        
        //Plugin instance suit params in order to fit for generateElements
        $values = $instance->validateDrushParams($params);
        $instance_and_values[$plugin_id]['instance'] = $instance;
        $instance_and_values[$plugin_id]['values'] = $values;
    }
    return $instance_and_values[$plugin_id];
}