graphql_compose-1.0.0-beta20/src/Plugin/GraphQLCompose/FieldType/PublishedAtItem.php

src/Plugin/GraphQLCompose/FieldType/PublishedAtItem.php
<?php

declare(strict_types=1);

namespace Drupal\graphql_compose\Plugin\GraphQLCompose\FieldType;

use Drupal\graphql_compose\Attribute\FieldType;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\graphql\GraphQL\Execution\FieldContext;
use Drupal\graphql_compose\Plugin\GraphQL\DataProducer\FieldProducerItemInterface;
use Drupal\graphql_compose\Plugin\GraphQL\DataProducer\FieldProducerTrait;

/**
 * {@inheritdoc}
 */
#[FieldType(
  id: "published_at",
  type_sdl: "DateTime",
)]
class PublishedAtItem extends DateTimeItem implements FieldProducerItemInterface {

  use FieldProducerTrait;

  /**
   * {@inheritdoc}
   */
  public function resolveFieldItem(FieldItemInterface $item, FieldContext $context) {

    $clone = clone $item;
    $clone->value = $item->published_at_or_now;

    return parent::resolveFieldItem($clone, $context);
  }

}

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

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