/** * Prepare values for suggest field * * @param array $params */ public function suggestAlbum(array $params) { list($entityType, $entityId) = $this->getEntity($params); $userId = trim($params['userId']); if (OW::getRequest()->isAjax()) { // collect default album names $event = new BASE_CLASS_EventCollector(PHOTO_CLASS_EventHandler::EVENT_SUGGEST_DEFAULT_ALBUM, array('userId' => $userId, "entityType" => $entityType, "entityId" => $entityId)); OW::getEventManager()->trigger($event); $data = $event->getData(); foreach ($data as $album) { echo $album . "\t0\n"; } $albums = $this->photoAlbumService->suggestEntityAlbums($entityType, $entityId, $_GET['q']); if ($albums) { foreach ($albums as $album) { if (!empty($data['albums']) && in_array($album->name, $data['albums'])) { continue; } echo "{$album->name}\t{$album->id}\n"; } } exit; } else { throw new Redirect404Exception(); } }