niobi-8.x-2.0-alpha4/modules/niobi_form/modules/niobi_app/src/Plugin/GroupContentEnabler/GroupNiobiApplicationWorkflowStage.php
modules/niobi_form/modules/niobi_app/src/Plugin/GroupContentEnabler/GroupNiobiApplicationWorkflowStage.php
<?php
namespace Drupal\niobi_app\Plugin\GroupContentEnabler;
use Drupal\group\Plugin\GroupContentEnablerBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a content enabler for forms.
*
* @GroupContentEnabler(
* id = "group_niobi_application_workflow_stage",
* label = @Translation("Group Application Workflow Stages"),
* description = @Translation("Adds application workflow stages to groups both publicly and privately."),
* entity_type_id = "niobi_application_workflow_stage",
* entity_access = TRUE,
* reference_label = @Translation("Title"),
* reference_description = @Translation("The title of the niobi_application_workflow_stage to add to the group"),
* deriver = "Drupal\niobi_app\Plugin\GroupContentEnabler\GroupNiobiApplicationWorkflowStageDeriver"
* )
*/
class GroupNiobiApplicationWorkflowStage extends GroupContentEnablerBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$config = parent::defaultConfiguration();
$config['entity_cardinality'] = 1;
return $config;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
// Disable the entity cardinality field as the functionality of this module
// relies on a cardinality of 1. We don't just hide it, though, to keep a UI
// that's consistent with other content enabler plugins.
$info = $this->t("This field has been disabled by the plugin to guarantee the functionality that's expected of it.");
$form['entity_cardinality']['#disabled'] = TRUE;
$form['entity_cardinality']['#description'] .= '<br /><em>' . $info . '</em>';
return $form;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return ['module' => ['niobi_app']];
}
}
