mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: GraphQL helpers
This commit is contained in:
parent
a167ad4b5d
commit
39f81b5a16
@ -53,3 +53,4 @@ Page:
|
||||
- A2nt\CMSNiceties\Models\TeamMember
|
||||
extensions:
|
||||
- DNADesign\Elemental\Extensions\ElementalPageExtension
|
||||
- ObjectGraphQlEx
|
||||
|
38
src/Extensions/ObjectGraphQlEx.php
Normal file
38
src/Extensions/ObjectGraphQlEx.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace A2nt\CMSNiceties\Extensions;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\GraphQL\Controller as GraphQLController;
|
||||
use App\GraphQL\URLLinkablePlugin;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
/**
|
||||
* Class \A2nt\CMSNiceties\Extensions\SubmittedFormEx
|
||||
* AJAX/GraphQL helpers
|
||||
* @property \A2nt\CMSNiceties\Extensions\SubmittedFormEx $owner
|
||||
*/
|
||||
class ObjectGraphQlEx extends DataExtension
|
||||
{
|
||||
// Get rendered template
|
||||
public function MainContent()
|
||||
{
|
||||
$object = $this;
|
||||
return isset($object->GraphQLContent) ? $object->GraphQLContent : null;
|
||||
}
|
||||
|
||||
public function RequestLink()
|
||||
{
|
||||
$curr = Controller::curr();
|
||||
//$var = URLLinkablePlugin::config()->get('single_field_name');
|
||||
$var = 'url';
|
||||
if ($curr::class === GraphQLController::class) {
|
||||
$vars = json_decode($curr->getRequest()->getBody(), true)['variables'];
|
||||
if (isset($vars[$var])) {
|
||||
return $vars[$var];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user