|
@@ 141-163 (lines=23) @@
|
| 138 |
|
* @param Request $request |
| 139 |
|
* @return Response |
| 140 |
|
*/ |
| 141 |
|
public function licenseeSuggestAction(Request $request): Response |
| 142 |
|
{ |
| 143 |
|
$filter = $request->query->get('filter'); |
| 144 |
|
|
| 145 |
|
$searchString = $filter['value']; |
| 146 |
|
|
| 147 |
|
$mongo = $this->get('doctrine_mongodb'); |
| 148 |
|
/* @var $repository \Doctrine\ODM\MongoDB\DocumentRepository */ |
| 149 |
|
$repository = $mongo->getRepository('DembeloMain:Licensee'); |
| 150 |
|
|
| 151 |
|
$licensees = $repository->findBy(array('name' => new \MongoRegex('/'.$searchString.'/')), null, 10); |
| 152 |
|
|
| 153 |
|
$output = array(); |
| 154 |
|
/* @var $licensee \DembeloMain\Document\Licensee */ |
| 155 |
|
foreach ($licensees as $licensee) { |
| 156 |
|
$output[] = array( |
| 157 |
|
'id' => $licensee->getId(), |
| 158 |
|
'value' => $licensee->getName(), |
| 159 |
|
); |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
return new Response(\json_encode($output)); |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
/** |
| 166 |
|
* @Route("/topicSuggest", name="admin_topic_suggest") |
|
@@ 171-193 (lines=23) @@
|
| 168 |
|
* @param Request $request |
| 169 |
|
* @return Response |
| 170 |
|
*/ |
| 171 |
|
public function topicSuggestAction(Request $request): Response |
| 172 |
|
{ |
| 173 |
|
$filter = $request->query->get('filter'); |
| 174 |
|
|
| 175 |
|
$searchString = $filter['value']; |
| 176 |
|
|
| 177 |
|
$mongo = $this->get('doctrine_mongodb'); |
| 178 |
|
/* @var $repository \Doctrine\ODM\MongoDB\DocumentRepository */ |
| 179 |
|
$repository = $mongo->getRepository('DembeloMain:Topic'); |
| 180 |
|
|
| 181 |
|
/* @var $topics \DembeloMain\Document\Topic[] */ |
| 182 |
|
$topics = $repository->findBy(array('name' => new \MongoRegex('/'.$searchString.'/')), null, 10); |
| 183 |
|
|
| 184 |
|
$output = []; |
| 185 |
|
foreach ($topics as $topic) { |
| 186 |
|
$output[] = array( |
| 187 |
|
'id' => $topic->getId(), |
| 188 |
|
'value' => $topic->getName(), |
| 189 |
|
); |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
return new Response(\json_encode($output)); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
/** |
| 196 |
|
* @Route("/topics", name="admin_topics") |