Пример #1
0
 /**
  * @covers ::getLayoutsAction
  */
 public function testGetLayoutsAction_noAuthorizedLayouts()
 {
     // authenticate a user with super admin authority
     $user = $this->createAuthUser('editor_layout', array('ROLE_API_USER'));
     // set up permissions
     $aclManager = $this->getBBApp()->getContainer()->get('security.acl_manager');
     $aclManager->insertOrUpdateObjectAce(new ObjectIdentity($this->site->getObjectIdentifier(), get_class($this->site)), new UserSecurityIdentity($user->getGroups()[0]->getId(), 'BackBee\\Security\\Group'), MaskBuilder::MASK_VIEW);
     $response = $this->getController()->getLayoutsAction($this->site->getUid());
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('application/json', $response->headers->get('Content-Type'));
     $content = json_decode($response->getContent(), true);
     $this->assertInternalType('array', $content);
     $this->assertCount(0, $content);
 }
 /**
  * Removes stored site-content indexes for a content in a site.
  *
  * @param  Site                 $site
  * @param  AbstractClassContent $content
  *
  * @return IndexationRepository
  */
 public function removeIdxSiteContent(Site $site, AbstractClassContent $content)
 {
     $query = 'DELETE FROM idx_site_content WHERE site_uid = :site AND (content_uid IN ' . '(SELECT content_uid FROM content_has_subcontent WHERE parent_uid = :content)' . 'OR content_uid = :content)';
     $params = array('site' => $site->getUid(), 'content' => $content->getUid());
     return $this->_executeQuery($query, $params);
 }
Пример #3
0
 /**
  * @covers ::persist
  * @covers ::loadPersistors
  * @covers ::doPersist
  * @covers ::updateConfigOverridedSectionsForSite
  */
 public function test_persistWithConfigPerSite()
 {
     $this->application->setIs_Started(true);
     $this->application->getConfig()->setSection('config', array('persistor' => 'BackBee\\Config\\Tests\\Persistor\\FakePersistor'));
     $this->application->getConfig()->setSection('parameters', array('hello' => 'foo'));
     $this->application->setContainer(new Container());
     $this->application->getContainer()->set('container.builder', new FakeContainerBuilder());
     $current_config = $this->application->getConfig()->getAllRawSections();
     $this->application->setSite($site = new Site());
     $this->persistor->persist($this->application->getConfig(), true);
     $this->assertTrue($this->application->getConfig()->getSection('override_site') !== null);
     $updated_override_section = array('override_site' => array($site->getUid() => array('parameters' => array('hello' => 'foo'), 'config' => array('persistor' => 'BackBee\\Config\\Tests\\Persistor\\FakePersistor'))));
     $this->assertEquals(array_merge($current_config, $updated_override_section), $this->application->getConfig()->getAllRawSections());
     $this->assertEquals(array_merge($this->configurator->getConfigDefaultSections($this->application->getConfig()), $updated_override_section), $this->application->getContainer()->getParameter('config_to_persist'));
 }
Пример #4
0
 /**
  * @Serializer\VirtualProperty
  * @Serializer\SerializedName("site_uid")
  */
 public function getSiteUid()
 {
     return null !== $this->_site ? $this->_site->getUid() : null;
 }
 /**
  * Retrieves root nodes for $site
  * 
  * @param  Site     $site           The site we are looking for root nodes
  * @param  string   $classname
  * 
  * @return array                    The root nodes found
  */
 private function getPageRoot(Site $site, $classname)
 {
     $query = sprintf('SELECT %s FROM %s WHERE %s = ? AND %s IS NULL', $this->requiredFields['uid'], $this->em->getClassMetadata($classname)->getTableName(), $this->requiredFields['site_uid'], $this->requiredFields['parent_uid']);
     return $this->em->getConnection()->executeQuery($query, array($site->getUid()), array(Type::STRING))->fetchAll(\PDO::FETCH_COLUMN);
 }
Пример #6
0
 /**
  * @Serializer\VirtualProperty
  * @Serializer\SerializedName("site_uid")
  *
  * @return string|null
  */
 public function getSiteUid()
 {
     if (null === $this->_site) {
         return;
     }
     return $this->_site->getUid();
 }
 /**
  * Generates an uid for layout
  * 
  * @param  string   $filename       The filename of the definition
  * @param  array    $data           The parsed data of the definition
  * @param  Site     $site           Optional, the site for which layout will add
  * 
  * @return string                   The generated uid
  */
 public function generateUid($filename, array $data, Site $site = null)
 {
     $baseUid = $site !== null ? $site->getUid() : '';
     return md5($baseUid . basename($filename));
 }