public function generateLayout($filename, Site $site = null, $extention = self::EXTENSION)
 {
     try {
         $data = Yaml::parse($filename);
         $uid = $this->getUidGenerator()->generateUid($filename, $data, $site);
         $layout = new Layout($uid);
         $layout->setPicPath($layout->getUid() . '.png');
         if ($site !== null) {
             $layout->setSite($site);
         }
         if (array_key_exists('label', $data) && $data['label'] !== null) {
             $layout->setLabel($data['label']);
         } else {
             $layout->setLabel(basename($filename, '.' . self::EXTENSION));
         }
         if (array_key_exists('template', $data)) {
             $this->computeTemplate($layout, $data['template']);
         }
         if (array_key_exists('columns', $data)) {
             $layout->setData($this->computeColumns($data['columns']));
         } else {
             throw new LayoutYamlException('Layout ' . $layout->getLabel() . ' definition need columns', LayoutYamlException::NO_COLUMN_ERROR);
         }
     } catch (ParseException $e) {
         throw new LayoutYamlException($e->getMessage(), LayoutYamlException::LAYOUT_BUILD_ERROR, $e, $e->getParsedFile(), $e->getParsedLine());
     }
     return $layout;
 }
예제 #2
0
 protected function setUp()
 {
     $this->initAutoload();
     $this->bbapp = $this->getBBApp();
     $this->initDb($this->bbapp);
     $this->initAcl();
     $this->bbapp->start();
     // craete site
     $this->site = new Site();
     $this->site->setLabel('sitelabel');
     $this->site->setServerName('www.example.org');
     // craete layout
     $this->layout = new Layout();
     $this->layout->setSite($this->site);
     $this->layout->setLabel('defaultLayoutLabel');
     $this->layout->setPath($this->bbapp->getBBDir() . '/Rest/Tests/Fixtures/Controller/defaultLayout.html.twig');
     $this->layout->setData(json_encode(array('templateLayouts' => array('title' => 'zone_1234567'))));
     $this->site->addLayout($this->layout);
     $this->getEntityManager()->persist($this->layout);
     $this->getEntityManager()->persist($this->site);
     $this->getEntityManager()->flush();
 }
예제 #3
0
 /**
  * @covers ::putAction
  */
 public function testPutAction()
 {
     $em = $this->getEntityManager();
     $layout = new Layout();
     $layout->setLabel('Default')->setSite($this->site)->setDataObject(new \stdClass())->setPath($this->getBBApp()->getBaseRepository() . '/Layouts/default.twig');
     $em->persist($layout);
     // create pages
     $homePage = new Page();
     $homePage->setTitle('Page')->setSite($this->site);
     $em->persist($homePage);
     $em->flush();
     $this->getAclManager()->insertOrUpdateObjectAce($homePage, new UserSecurityIdentity($this->group_id, 'BackBee\\Security\\Group'), ['PUBLISH', 'EDIT'])->insertOrUpdateObjectAce($layout, new UserSecurityIdentity($this->group_id, 'BackBee\\Security\\Group'), ['VIEW']);
     $response = $this->sendRequest(self::requestPut('/rest/1/page/' . $homePage->getUid(), ['title' => 'New Page', 'url' => 'url', 'target' => Page::DEFAULT_TARGET, 'state' => Page::STATE_ONLINE, 'layout_uid' => $layout->getUid()]));
     $this->assertEquals(204, $response->getStatusCode());
 }
예제 #4
0
 public function createLayout($label, $uid = null)
 {
     $layout = new Layout($uid);
     $layout->setLabel($label);
     $layout->setPath('/' . $label);
     $layout->setDataObject($this->getDefaultLayoutZones());
     return $layout;
 }