Skip to content

Commit

Permalink
Merge pull request #20 from workingconcept/master
Browse files Browse the repository at this point in the history
Add CraftQL support for `text` and `html` fields.
  • Loading branch information
selvinortiz authored Nov 23, 2018
2 parents 671b123 + 09ca35e commit b8ab37a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Doxter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ function(RegisterComponentTypesEvent $event)
}
);

if (class_exists(\markhuot\CraftQL\CraftQL::class))
{
Event::on(
DoxterField::class,
'craftQlGetFieldSchema',
function($event)
{
$event->handled = true;

$outputSchema = $event->schema->createObjectType(ucfirst($event->sender->handle).'DoxterFieldData');

$outputSchema->addStringField('text')
->resolve(function($root) {
return (string)$root->getRaw();
});

$outputSchema->addStringField('html')
->resolve(function($root) {
return (string)$root->getHtml();
});

$event->schema->addField($event->sender)->type($outputSchema);
}
);
}

$this->name = $this->getSettings()->pluginAlias;
$this->hasCpSection = $this->getSettings()->enableCpTab;
$this->hasCpSettings = true;
Expand Down

0 comments on commit b8ab37a

Please # to comment.