/** * Get the widget that should used for the default value. * * Returns null to use the default for the field. * @todo This is in here specifically to look at a solution for Workbench Moderation. * Should this be function on the runner plugin? * Or an old school alter hook? * @param $definition * * @return WidgetBase|null */ protected function getWidgetOverride(FieldDefinitionInterface $definition) { if ($definition->getType() == 'entity_reference' && $definition->getSetting('target_type') == 'moderation_state') { $definition->setRequired(FALSE); $definition->setDescription(''); return \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $definition)); } return NUll; }