Skip to content

Instantly share code, notes, and snippets.

@webnitros
Created February 12, 2019 04:09
Show Gist options
  • Save webnitros/bc2cf0417df58a945202a55683519d1e to your computer and use it in GitHub Desktop.
Save webnitros/bc2cf0417df58a945202a55683519d1e to your computer and use it in GitHub Desktop.
<?php
class MyControllerPayment extends modRestController {
public $classKey = 'msPayment';
public $defaultSortField = 'rank';
public $defaultLimit = 20;
public $headers = array(
'Access-Control-Allow-Methods' => 'GET',
);
public $fields = 'id,name,description,price,logo,active';
/* @inheritdoc */
public function initialize()
{
$miniShop2 = $this->modx->getService('miniShop2');
$miniShop2->initialize('web');
}
/* @inheritdoc */
protected function prepareListObject(xPDOObject $object)
{
$data = $object->toArray();
$data['value'] = $data['id'];
$data['text'] = $data['name'];
return $data;
}
/* @inheritdoc */
public function prepareListQueryAfterCount(xPDOQuery $c)
{
$c->where(array(
'active' => true
));
return $c;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment