You are here

class WorkflowTransitionViewsData in Workflow 8

Provides the views data for the workflow entity type.

Partly taken from NodeViewsData.php.

Hierarchy

Expanded class hierarchy of WorkflowTransitionViewsData

File

src/WorkflowTransitionViewsData.php, line 12

Namespace

Drupal\workflow
View source
class WorkflowTransitionViewsData extends EntityViewsData {

  /**
   * {@inheritdoc}
   */
  public function getViewsData() {
    $data = parent::getViewsData();

    // Use flexible $base_table, since both WorkflowTransition and
    // WorkflowScheduledTransition use this.
    $base_table = $this->entityType
      ->getBaseTable();
    $base_field = $this->entityType
      ->getKey('id');

    // @todo D8: Add data from D7 function workflow_views_views_data_alter().
    // @see http://cgit.drupalcode.org/workflow/tree/workflow_views/workflow_views.views.inc
    $data[$base_table]['table']['group'] = $this
      ->t('Workflow');
    $data[$base_table]['table']['provider'] = 'workflow';
    $data[$base_table]['table']['join'] = [
      // This is provided for the many_to_one argument.
      $base_table => [
        'field' => $base_field,
        'left_field' => $base_field,
      ],
    ];

    // @todo Reverse this relationship. See also taxonomy/src/NodeTermData.php.
    // $data[$base_table]['nid'] = [
    //  'title' => $this->t('Content with workflow'),
    //  'help' => $this->t('Relate all content with a workflow.'),
    //  'relationship' => [
    //    'id' => 'standard',
    //    'base' => 'node',
    //    'base field' => 'nid',
    //    'label' => $this->t('node'),
    //    'skip base' => 'node',
    //  ],
    // ];
    $data[$base_table]['from_sid']['filter']['id'] = 'workflow_state';
    $data[$base_table]['from_sid']['help'] = $this
      ->t('The name of the previous state of the transition.');
    $data[$base_table]['to_sid']['filter']['id'] = 'workflow_state';
    $data[$base_table]['to_sid']['help'] = $this
      ->t('The name of the new state of the transition. (For the latest transition, this is the current state.)');
    $data[$base_table]['uid']['help'] = $this
      ->t('The user who triggered the transition. If you need more fields than the uid add the content: author relationship');
    $data[$base_table]['uid']['filter']['id'] = 'user_name';
    $data[$base_table]['uid']['relationship']['title'] = $this
      ->t('User');
    $data[$base_table]['uid']['relationship']['help'] = $this
      ->t('The user who triggered the transition.');
    $data[$base_table]['uid']['relationship']['label'] = $this
      ->t('User');

    // @todo Add similar support to any date field.
    // @see https://www.drupal.org/node/2337507
    $data[$base_table]['timestamp_fulldate'] = [
      'title' => $this
        ->t('Created date'),
      'help' => $this
        ->t('Date in the form of CCYYMMDD.'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_fulldate',
      ],
    ];
    $data[$base_table]['timestamp_year_month'] = [
      'title' => $this
        ->t('Created year + month'),
      'help' => $this
        ->t('Date in the form of YYYYMM.'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_year_month',
      ],
    ];
    $data[$base_table]['timestamp_year'] = [
      'title' => $this
        ->t('Created year'),
      'help' => $this
        ->t('Date in the form of YYYY.'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_year',
      ],
    ];
    $data[$base_table]['timestamp_month'] = [
      'title' => $this
        ->t('Created month'),
      'help' => $this
        ->t('Date in the form of MM (01 - 12).'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_month',
      ],
    ];
    $data[$base_table]['timestamp_day'] = [
      'title' => $this
        ->t('Created day'),
      'help' => $this
        ->t('Date in the form of DD (01 - 31).'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_day',
      ],
    ];
    $data[$base_table]['timestamp_week'] = [
      'title' => $this
        ->t('Created week'),
      'help' => $this
        ->t('Date in the form of WW (01 - 53).'),
      'argument' => [
        'field' => 'timestamp',
        'id' => 'date_week',
      ],
    ];
    $data[$base_table]['changed_fulldate'] = [
      'title' => $this
        ->t('Updated date'),
      'help' => $this
        ->t('Date in the form of CCYYMMDD.'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_fulldate',
      ],
    ];
    $data[$base_table]['changed_year_month'] = [
      'title' => $this
        ->t('Updated year + month'),
      'help' => $this
        ->t('Date in the form of YYYYMM.'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_year_month',
      ],
    ];
    $data[$base_table]['changed_year'] = [
      'title' => $this
        ->t('Updated year'),
      'help' => $this
        ->t('Date in the form of YYYY.'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_year',
      ],
    ];
    $data[$base_table]['changed_month'] = [
      'title' => $this
        ->t('Updated month'),
      'help' => $this
        ->t('Date in the form of MM (01 - 12).'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_month',
      ],
    ];
    $data[$base_table]['changed_day'] = [
      'title' => $this
        ->t('Updated day'),
      'help' => $this
        ->t('Date in the form of DD (01 - 31).'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_day',
      ],
    ];
    $data[$base_table]['changed_week'] = [
      'title' => $this
        ->t('Updated week'),
      'help' => $this
        ->t('Date in the form of WW (01 - 53).'),
      'argument' => [
        'field' => 'changed',
        'id' => 'date_week',
      ],
    ];
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
EntityViewsData::$deprecatedProperties protected property
EntityViewsData::$entityFieldManager protected property The entity field manager.
EntityViewsData::$entityType protected property Entity type for this views data handler instance.
EntityViewsData::$entityTypeManager protected property The entity type manager.
EntityViewsData::$fieldStorageDefinitions protected property The field storage definitions for all base fields of the entity type.
EntityViewsData::$moduleHandler protected property The module handler.
EntityViewsData::$storage protected property The storage used for this entity type.
EntityViewsData::$translationManager protected property The translation manager.
EntityViewsData::addEntityLinks protected function Sets the entity links in case corresponding link templates exist.
EntityViewsData::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
EntityViewsData::getFieldStorageDefinitions protected function Gets the field storage definitions.
EntityViewsData::getViewsTableForEntityType public function Gets the table of an entity type to be used as base table in views. Overrides EntityViewsDataInterface::getViewsTableForEntityType
EntityViewsData::mapFieldDefinition protected function Puts the views data for a single field onto the views data.
EntityViewsData::mapSingleFieldViewsData protected function Provides the views data for a given data type and schema field.
EntityViewsData::processViewsDataForEntityReference protected function Processes the views data for an entity reference field.
EntityViewsData::processViewsDataForLanguage protected function Processes the views data for a language field.
EntityViewsData::processViewsDataForTextLong protected function Processes the views data for a text field with formatting.
EntityViewsData::processViewsDataForUuid protected function Processes the views data for a UUID field.
EntityViewsData::__construct public function Constructs an EntityViewsData object.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
WorkflowTransitionViewsData::getViewsData public function Returns views data for the entity type. Overrides EntityViewsData::getViewsData 1