src/Phlexible/Bundle/ElementBundle/Controller/LocksController.php
public function lockAction(Request $request)
    {
        // get request parameters
        $eid = (int) $request->get('eid');
        $language = $request->get('language');

        $elementService = $this->get('phlexible_element.element_service');
        $lockManager = $this->get('phlexible_element.element_lock_manager');

        $element = $elementService->findElement($eid);

        if ($lockManager->isLocked($element)) {
            return new ResultResponse(false, 'Element already locked.');
        } else {
            try {
                // try to lock the element
                $lockManager->lock($element, $this->getUser()->getId());

                return new ResultResponse(true, 'Lock aquired.');
            } catch (\Exception $e) {
                return new ResultResponse(false, $e->getMessage());
            }
        }
    }
public function lockAction(Request $request)
    {
        // get request parameters
        $eid = (int) $request->get('eid');
        $language = $request->get('language');

        $elementService = $this->get('phlexible_element.element_service');
        $lockManager = $this->get('phlexible_element.element_lock_manager');

        $element = $elementService->findElement($eid);

        if ($lockManager->isLocked($element)) {
            return new ResultResponse(false, 'Element already locked.');
        } else {
            try {
                // try to lock the element
                $lockManager->lock($element, $this->getUser()->getId());

                return new ResultResponse(true, 'Lock aquired.');
            } catch (\Exception $e) {
                return new ResultResponse(false, $e->getMessage());
            }
        }
    }
public function lockAction ( Request $ request ) { // get request parameters $ eid = ( int ) $ request -> get ( 'eid' ) ; $ language = $ request -> get ( 'language' ) ; $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ lockManager = $ this -> get ( 'phlexible_element.element_lock_manager' ) ; $ element = $ elementService -> findElement ( $ eid ) ; if ( $ lockManager -> isLocked ( $ element ) ) { return new ResultResponse ( false , 'Element already locked.' ) ; } else { try { // try to lock the element $ lockManager -> lock ( $ element , $ this -> getUser ( ) -> getId ( ) ) ; return new ResultResponse ( true , 'Lock aquired.' ) ; } catch ( \ Exception $ e ) { return new ResultResponse ( false , $ e -> getMessage ( ) ) ; } } }
Lock element.

@param Request $request

@return ResultResponse
@Route("/lock", name="elements_locks_lock")
Lock element .