outline-8.x-1.x-dev/modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/ReferencedEntityId.php
modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/ReferencedEntityId.php
<?php
namespace Drupal\outline_graphql\Plugin\GraphQL\DataProducer\Entry;
use Drupal\Core\Entity\EntityInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
/**
* @DataProducer(
* id = "referenced_entity_id",
* name = @Translation("Referenced Entity ID"),
* description = @Translation("Returns the referenced entity's ID of an entry."),
* produces = @ContextDefinition("string",
* label = @Translation("Referenced Entity ID")
* ),
* consumes = {
* "entity" = @ContextDefinition("entity",
* label = @Translation("Entity")
* )
* }
* )
*/
class ReferencedEntityId extends DataProducerPluginBase {
/**
* @param \Drupal\Core\Entity\EntityInterface $entity
*
* @return string
*/
public function resolve(EntityInterface $entity) {
return $entity->getReferencedEntityId();
}
}
