get('flaglists'), $container->get('current_user') ); } /** * Constructs a new MaterioFlagController object. */ public function __construct(FlagListsService $flag_lists_service, AccountProxyInterface $account) { $this->flaglists = $flag_lists_service; $this->user = $account; } /** * Hello. * * @return string * Return Hello string. */ public function getUsersFlaggingCollections() { $colls = $this->flaglists->getUsersFlaggingCollections(); $data = []; foreach ($colls as $id => $collection) { $data[] = array( "id" => $id, "name" => $collection->getName() ); } return new JsonResponse($data); } public function createUserFlaggingCollection(Request $request) { // dpm($request); $post_data = json_decode( $request->getContent(),TRUE); $name = $post_data['name']; $newFlagColl = FlaggingCollection::Create([ 'type' => 'flagging_collection_type', 'name' => $name, 'user_id' => $this->user->id(), 'templateflag' => 'dossier' ]); $newFlagColl->save(); $data = [ 'status' => $newFlagColl->get('status')->value, 'id' => $newFlagColl->id(), 'name' => $newFlagColl->getName(), 'newflagcoll_toarray' => $newFlagColl->toArray() ]; return new JsonResponse($data); } public function deleteUserFlaggingCollection(Request $request) { // dpm($request); $post_data = json_decode( $request->getContent(),TRUE); $flagid = $post_data['flagid']; $flagcoll = $this->flaglists->getFlaggingCollectionById($flagid); $result = $flagcoll->delete(); $data = [ 'result' => $result, 'id' => $flagid ]; return new JsonResponse($data); } }