public function getLayoutsAction($uid)
    {
        if (!$this->isGranted("ROLE_API_USER")) {
            throw new AccessDeniedHttpException("Your account's api access is disabled");
        }

        $site = $this->getEntityManager()->getRepository('BackBee\Site\Site')->find($uid);

        if (!$site) {
            return $this->create404Response(sprintf('Site not found: %s', $uid));
        }

        if (!$this->isGranted('VIEW', $site)) {
            throw new AccessDeniedHttpException(sprintf('You are not authorized to view site %s', $site->getLabel()));
        }

        $layouts = array();

        foreach ($site->getLayouts() as $layout) {
            if ($this->isGranted('VIEW', $layout)) {
                $layouts[] = [
                    'uid' => $layout->getUid(),
                    'site' => [
                        'uid' => $layout->getSite()->getUid(),
                    ],
                    'label' => $layout->getLabel(),
                    'path' => $layout->getPath(),
                    'data' => json_decode($layout->getData(), true),
                    'picpath' => $layout->getPicpath(),
                ];
            }
        }

        return new Response($this->formatCollection($layouts), 200, ['Content-Type' => 'application/json']);
    }
public function getLayoutsAction($uid)
    {
        if (!$this->isGranted("ROLE_API_USER")) {
            throw new AccessDeniedHttpException("Your account's api access is disabled");
        }

        $site = $this->getEntityManager()->getRepository('BackBee\Site\Site')->find($uid);

        if (!$site) {
            return $this->create404Response(sprintf('Site not found: %s', $uid));
        }

        if (!$this->isGranted('VIEW', $site)) {
            throw new AccessDeniedHttpException(sprintf('You are not authorized to view site %s', $site->getLabel()));
        }

        $layouts = array();

        foreach ($site->getLayouts() as $layout) {
            if ($this->isGranted('VIEW', $layout)) {
                $layouts[] = [
                    'uid' => $layout->getUid(),
                    'site' => [
                        'uid' => $layout->getSite()->getUid(),
                    ],
                    'label' => $layout->getLabel(),
                    'path' => $layout->getPath(),
                    'data' => json_decode($layout->getData(), true),
                    'picpath' => $layout->getPicpath(),
                ];
            }
        }

        return new Response($this->formatCollection($layouts), 200, ['Content-Type' => 'application/json']);
    }
public function getLayoutsAction ( $ uid ) { if ( ! $ this -> isGranted ( "ROLE_API_USER" ) ) { throw new AccessDeniedHttpException ( "Your account's api access is disabled" ) ; } $ site = $ this -> getEntityManager ( ) -> getRepository ( 'BackBee\Site\Site' ) -> find ( $ uid ) ; if ( ! $ site ) { return $ this -> create404Response ( sprintf ( 'Site not found: %s' , $ uid ) ) ; } if ( ! $ this -> isGranted ( 'VIEW' , $ site ) ) { throw new AccessDeniedHttpException ( sprintf ( 'You are not authorized to view site %s' , $ site -> getLabel ( ) ) ) ; } $ layouts = array ( ) ; foreach ( $ site -> getLayouts ( ) as $ layout ) { if ( $ this -> isGranted ( 'VIEW' , $ layout ) ) { $ layouts [ ] = [ 'uid' => $ layout -> getUid ( ) , 'site' => [ 'uid' => $ layout -> getSite ( ) -> getUid ( ) , ] , 'label' => $ layout -> getLabel ( ) , 'path' => $ layout -> getPath ( ) , 'data' => json_decode ( $ layout -> getData ( ) , true ) , 'picpath' => $ layout -> getPicpath ( ) , ] ; } } return new Response ( $ this -> formatCollection ( $ layouts ) , 200 , [ 'Content-Type' => 'application/json' ] ) ; }
Get site layouts.
Get site layouts .