public function search()
{
$q = $this->request->mixed('q', '');
$offset = $this->request->mixed('offset', 0);
$count = $this->request->mixed('count', 10);
$category_id = (int)$this->request->mixed('category_id', 0);
$sort = $this->request->mixed('sort', "ASC");
$rep = new RepositoryDigest($this->em);
$items = $rep->search($q, $category_id, $offset, $count, $sort);
$data = new ResponseSchema();
$data->setCount(0);
$data->setItems($items);
$json = $this->serializer->serialize($data, 'json', ['attributes' => [
'count',
'items' => [
'name',
'image',
'postCode',
'phone',
'latitude',
'longitude',
'home',
'site',
'schedule',
]
]]);
$this->response->jsonSend($json);
}
/**
* Class Digest
* @package Api\Repository
*/
class RepositoryDigest extends EntityRepository
{
/**
* RepositoryDigest constructor.
* @param EntityManagerInterface $em
*/
public function __construct(EntityManagerInterface $em)
{
parent::__construct($em, $em->getMetadataFactory()->getMetadataFor(Digest::class));
}
...
"files": [
"engine/defines.php",
"engine/function.php",
"engine/env.php",
"vendor/gedmo/doctrine-extensions/src/Mapping/Annotation/All.php"
]
/**
* Contains all annotations for extensions
* NOTE: should be included with require_once
*
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
foreach (glob(__DIR__ . "/*.php") as $filename) {
if (basename($filename, '.php') === 'All') {
continue;
}
include_once $filename;
}
Вот, что получается...
ManyToMany
В "category": [] я хочу увидеть массив с категориями.
reviews отрабатывает (OneToMany)