src/Controller/Framework/LsAssociationController.php
/**
     * Creates a new LsAssociation entity -- tree-view version, called via ajax.
     *
     * @Route("/treenew/{lsDoc}", methods={"POST"}, name="lsassociation_tree_new")
     * @Security("is_granted('add-association-to', lsDoc)")
     */
Creates a new LsAssociation entity -- tree-view version, called via ajax.
Creates a new LsAssociation entity -- tree - view version called via ajax .
public function treeNewAction(Request $request, LsDoc $lsDoc): Response
    {
        foreach (['type', 'origin', 'dest'] as $value) {
            if (!$request->request->has($value)) {
                return new JsonResponse(['error' => ['message' => "Missing value: {$value}"]], Response::HTTP_BAD_REQUEST);
            }
        }
        try {
            $command = new AddTreeAssociationCommand(
                $lsDoc,
                $request->request->get('origin'),
                $request->request->get('type'),
                $request->request->get('dest'),
                $request->request->get('assocGroup'),
                $request->request->get('annotation')
            );
            $this->sendCommand($command);
            $lsAssociation = $command->getAssociation();
            $rv = [
                'id' => isset($lsAssociation) ? $lsAssociation->getId() : null,
                'identifier' => isset($lsAssociation) ? $lsAssociation->getIdentifier() : null,
            ];
            $response = new JsonResponse($rv);
            $response->headers->set('Cache-Control', 'no-cache');
            return $response;
        } catch (\Exception $e) {
            return new JsonResponse(['error' => ['message' => $e->getMessage()]], Response::HTTP_BAD_REQUEST);
        }
    }
public function treeNewAction ( Request $ request , LsDoc $ lsDoc ) : Response { foreach ( [ 'type' , 'origin' , 'dest' ] as $ value ) { if ( ! $ request -> request -> has ( $ value ) ) { return new JsonResponse ( [ 'error' => [ 'message' => " Missing value:  { $ value } " ] ] , Response :: HTTP_BAD_REQUEST ) ; } } try { $ command = new AddTreeAssociationCommand ( $ lsDoc , $ request -> request -> get ( 'origin' ) , $ request -> request -> get ( 'type' ) , $ request -> request -> get ( 'dest' ) , $ request -> request -> get ( 'assocGroup' ) , $ request -> request -> get ( 'annotation' ) ) ; $ this -> sendCommand ( $ command ) ; $ lsAssociation = $ command -> getAssociation ( ) ; $ rv = [ 'id' => isset ( $ lsAssociation ) ? $ lsAssociation -> getId ( ) : null , 'identifier' => isset ( $ lsAssociation ) ? $ lsAssociation -> getIdentifier ( ) : null , ] ; $ response = new JsonResponse ( $ rv ) ; $ response -> headers -> set ( 'Cache-Control' , 'no-cache' ) ; return $ response ; } catch ( \ Exception $ e ) { return new JsonResponse ( [ 'error' => [ 'message' => $ e -> getMessage ( ) ] ] , Response :: HTTP_BAD_REQUEST ) ; } }
Creates a new LsAssociation entity -- tree-view version, called via ajax.
Creates a new LsAssociation entity -- tree - view version called via ajax .
// type, origin['externalDoc', 'id', 'identifier'], dest['externalDoc', 'id', 'identifier'], assocGroup // return id of created association