outline-8.x-1.x-dev/modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/EditFormUrl.php
modules/outline_graphql/src/Plugin/GraphQL/DataProducer/Entry/EditFormUrl.php
<?php
namespace Drupal\outline_graphql\Plugin\GraphQL\DataProducer\Entry;
use Drupal\Core\Entity\EntityInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
use Drupal\Core\Url;
/**
* @DataProducer(
* id = "edit_form_url",
* name = @Translation("Entry Edit Form URL"),
* description = @Translation("Returns the entry's edit form URL."),
* produces = @ContextDefinition("string",
* label = @Translation("Edit Form URL")
* ),
* consumes = {
* "entity" = @ContextDefinition("entity",
* label = @Translation("Entity")
* )
* }
* )
*/
class EditFormUrl extends DataProducerPluginBase {
/**
* @param \Drupal\Core\Entity\EntityInterface $entity
*
* @return string
*/
public function resolve(EntityInterface $entity) {
//return $entity->getEditFormUrl();
return Url::fromRoute('entity.outline_entry.edit_form', ['outline_entry' => $entity->id()])->toString();
}
}
