public function publishSharedAction(Request $request)
    {
        $this->getDoctrine()->getManager()->getFilters()->disable('draft');

        /** @var BlockManager $manager */
        $manager  = $this->get('opifer.content.block_manager');
        $response = new JsonResponse;
        $id       = (int) $request->request->get('id');

        try {
            $block = $manager->find($id, true);
            $block->setUpdatedAt(new \DateTime());
            $manager->publish($block);

            if ($block instanceof CompositeBlock) {
                $manager->publish($manager->findDescendants($block));
            }

            $response->setStatusCode(200);
            $response->setData(['state' => 'published']);
        } catch (\Exception $e) {
            $response->setStatusCode(500);
            $response->setData(['error' => $e->getMessage() . $e->getTraceAsString()]);
        }

        return $response;
    }
public function publishSharedAction(Request $request)
    {
        $this->getDoctrine()->getManager()->getFilters()->disable('draft');

        /** @var BlockManager $manager */
        $manager  = $this->get('opifer.content.block_manager');
        $response = new JsonResponse;
        $id       = (int) $request->request->get('id');

        try {
            $block = $manager->find($id, true);
            $block->setUpdatedAt(new \DateTime());
            $manager->publish($block);

            if ($block instanceof CompositeBlock) {
                $manager->publish($manager->findDescendants($block));
            }

            $response->setStatusCode(200);
            $response->setData(['state' => 'published']);
        } catch (\Exception $e) {
            $response->setStatusCode(500);
            $response->setData(['error' => $e->getMessage() . $e->getTraceAsString()]);
        }

        return $response;
    }
public function publishSharedAction ( Request $ request ) { $ this -> getDoctrine ( ) -> getManager ( ) -> getFilters ( ) -> disable ( 'draft' ) ; /** @var BlockManager $manager */ $ manager = $ this -> get ( 'opifer.content.block_manager' ) ; $ response = new JsonResponse ; $ id = ( int ) $ request -> request -> get ( 'id' ) ; try { $ block = $ manager -> find ( $ id , true ) ; $ block -> setUpdatedAt ( new \ DateTime ( ) ) ; $ manager -> publish ( $ block ) ; if ( $ block instanceof CompositeBlock ) { $ manager -> publish ( $ manager -> findDescendants ( $ block ) ) ; } $ response -> setStatusCode ( 200 ) ; $ response -> setData ( [ 'state' => 'published' ] ) ; } catch ( \ Exception $ e ) { $ response -> setStatusCode ( 500 ) ; $ response -> setData ( [ 'error' => $ e -> getMessage ( ) . $ e -> getTraceAsString ( ) ] ) ; } return $ response ; }
Publishes a shared block and it's members

@param Request $request

@return JsonResponse
Publishes a shared block and it s members