Created
October 31, 2018 14:43
-
-
Save wdebusschere/120cd631c7faff5d32d3bd86eab7be06 to your computer and use it in GitHub Desktop.
Custom datasource with symql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Usecase example: | |
--> | |
public function allowEditorToParse() | |
{ | |
return false; | |
} | |
public function execute(array &$param_pool = null) | |
{ | |
$result = new XMLElement($this->dsParamROOTELEMENT); | |
// fetch categories | |
$query =new SymQLQuery('Categories'); | |
$query | |
->select('system:id,title) | |
->from('categories') | |
->where('active', 'Yes') | |
->orderby('title', 'asc'); | |
$resultsymqlquery = SymQL::run($query,SymQL::RETURN_ARRAY); | |
//var_dump($resultsymqlquery['entries'][0]['entry']);die; | |
foreach ($resultsymqlquery['entries'] as $entry => $value) { | |
$entry = new XMLElement('category'); | |
$entry->setAttribute("id",$value['entry']['_id']); | |
$entry->setAttribute("title",$value['entry']['title']['value']); | |
$result->appendChild($entry); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment