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

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

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

use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
use Drupal\outline\Entity\Entry;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * @DataProducer(
 *   id = "entry_render",
 *   name = @Translation("Render Entry"),
 *   description = @Translation("Renders an entry."),
 *   produces = @ContextDefinition("entity",
 *     label = @Translation("The entity to render.")
 *   ),
 *   consumes = {
 *     "entity" = @ContextDefinition("entity",
 *       label = @Translation("Entity")
 *     )
 *   }
 * )
 */
class Render extends DataProducerPluginBase implements ContainerFactoryPluginInterface {

  /**
   * The current user.
   *
   * @var \Drupal\Core\Session\AccountInterface
   */
  protected $currentUser;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('current_user')
    );
  }

  /**
   * Render entry constructor.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param array $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   */
  public function __construct(array $configuration, string $plugin_id, array $plugin_definition, AccountInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->currentUser = $current_user;
  }

  /**
   * Render entry.
   *
   *
   * @param \Drupal\outline\Entity\Entry $entry
   *
   * @return \Drupal\outline\Entity\Entry
   *   True if entry was deleted.
   */
  public function resolve(Entry $entry) {
    //if ($this->currentUser->hasPermission("change parent entry")) {

    // Update Parent ID
    //$entry->delete();

    // Return parent entry eid.
    return $entry;

    //}
    //return NULL;
  }

}

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

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