public function EntityChanged::resolve in GraphQL 8.4
Resolver.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
string|null $format:
Return value
string|null
Throws
\Exception
File
- src/
Plugin/ GraphQL/ DataProducer/ Entity/ EntityChanged.php, line 43
Class
- EntityChanged
- Returns the changed time of an entity if it supports it.
Namespace
Drupal\graphql\Plugin\GraphQL\DataProducer\EntityCode
public function resolve(EntityInterface $entity, $format = NULL) {
if ($entity instanceof EntityChangedInterface) {
$datetime = new \DateTime();
$datetime
->setTimestamp($entity
->getChangedTime());
return $datetime
->format($format ?? \DateTime::ISO8601);
}
return NULL;
}