outline-8.x-1.x-dev/modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/ChildCount.php
modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/ChildCount.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_child_count",
* name = @Translation("Entry child count"),
* description = @Translation("Counts the children of an outline entry."),
* produces = @ContextDefinition("any",
* label = @Translation("Child Count")
* ),
* consumes = {
* "entity" = @ContextDefinition("entity",
* label = @Translation("Entity")
* )
* }
* )
*/
class ChildCount extends DataProducerPluginBase {
/**
* @param \Drupal\Core\Entity\EntityInterface $entity
*
* @return mixed
*/
public function resolve(EntityInterface $entity) {
return $entity->getChildCount();
}
}
