Skip to content

Instantly share code, notes, and snippets.

@wdebusschere
Last active November 19, 2018 16:32
Show Gist options
  • Save wdebusschere/0a170adf8e8078bb65a46f2f3c0f6969 to your computer and use it in GitHub Desktop.
Save wdebusschere/0a170adf8e8078bb65a46f2f3c0f6969 to your computer and use it in GitHub Desktop.
Custom datasource Member roles
<?php
class datasourcedsRoles extends SectionDatasource
{
public $dsParamROOTELEMENT = 'dsRoles';
public $dsParamCACHE = -1;
public $dsParamFILTERS = array(
);
public $dsParamINCLUDEDELEMENTS = array(
);
public function __construct($env = null, $process_params = true)
{
parent::__construct($env, $process_params);
$this->_dependencies = array();
}
public function about()
{
return array(
'name' => 'dsroles',
'author' => array(
'name' => 'Wannes Debusschere',
'website' => 'http://localhost/application',
'email' => 'info@e-xperience.be'),
'version' => 'Symphony 2.7.6',
'release-date' => '2018-05-10T11:35:12+00:00'
);
}
public function getSource()
{
}
public function allowEditorToParse()
{
return false;
}
public function execute(array &$param_pool = null)
{
$result = new XMLElement($this->dsParamROOTELEMENT);
$roles = Symphony::Database()->fetch(sprintf("
SELECT *
FROM sym_members_roles
ORDER BY name ASC
"));
$pagination = new XMLElement('pagination', '', array(
'total-entries' => count($roles) ));
$result->appendChild($pagination);
foreach($roles as $role){
$item = new XMLElement('entry', General::sanitize($role['name']), array(
'id' => $role['id'],
'handle' => $role['handle']
));
$result->appendChild($item);
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment