cms_content_sync-3.0.x-dev/modules/cms_content_sync_views/src/Plugin/views/field/FlowLabel.php

modules/cms_content_sync_views/src/Plugin/views/field/FlowLabel.php
<?php

namespace Drupal\cms_content_sync_views\Plugin\views\field;

use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * Views Field handler for the flow label.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("cms_content_sync_flow_label")
 */
class FlowLabel extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    // Leave empty to avoid a query on this field.
  }

  /**
   * Renders the flow label.
   */
  public function render(ResultRow $values) {
    /**
     * @var \Drupal\cms_content_sync\Entity\Pool $entity
     */
    $entity = $values->_entity;
    $flow = \Drupal::entityTypeManager()
      ->getStorage('cms_content_sync_flow')
      ->load($entity->get('flow')->value);

    if (isset($flow)) {
      return $flow->label();
    }

    return '';
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc