outline-8.x-1.x-dev/modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/Expanded.php

modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/Expanded.php
<?php

namespace Drupal\outline_graphql\Plugin\GraphQL\DataProducer\Entry;

use Drupal\Core\Entity\EntityInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;

/**
 * @DataProducer(
 *   id = "entry_expanded",
 *   name = @Translation("Entry expanded"),
 *   description = @Translation("Returns the expanded setting of an outline entry."),
 *   produces = @ContextDefinition("boolean",
 *     label = @Translation("Expanded")
 *   ),
 *   consumes = {
 *     "entity" = @ContextDefinition("entity",
 *       label = @Translation("Entity")
 *     )
 *   }
 * )
 */
class Expanded extends DataProducerPluginBase {

  /**
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *
   * @return bool
   */
  public function resolve(EntityInterface $entity) {
      $expanded = $entity->getExpanded();
      if(is_null($expanded)){
        $expanded = FALSE;
      }
      return $expanded;
  }

}

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

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