コード例 #1
0
ファイル: Workspace.php プロジェクト: frogriotcom/jackalope
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function deleteWorkspace($name)
 {
     if (!$this->session->getTransport() instanceof WorkspaceManagementInterface) {
         throw new UnsupportedRepositoryOperationException('Transport does not support workspace management');
     }
     return $this->session->getTransport()->deleteWorkspace($name);
 }
コード例 #2
0
 public function testCaseInsensativeRename()
 {
     $root = $this->session->getNode('/');
     $topic1 = $root->addNode('topic');
     $this->session->save();
     $this->session->move('/topic', '/Topic');
     $this->session->save();
 }
コード例 #3
0
ファイル: SessionTest.php プロジェクト: frogriotcom/jackalope
 public function testSessionRegistry()
 {
     $factory = new Factory();
     $repository = $this->getRepositoryMock();
     $transport = $this->getTransportStub();
     $transport->expects($this->any())->method('getNamespaces')->will($this->returnValue(array()));
     $s = new Session($factory, $repository, 'workspaceName', new SimpleCredentials('foo', 'bar'), $transport);
     $this->assertSame(Session::getSessionFromRegistry($s->getRegistryKey()), $s);
     $s->logout();
     $this->assertNull(Session::getSessionFromRegistry($s->getRegistryKey()));
 }
コード例 #4
0
ファイル: SessionTest.php プロジェクト: ruflin/jackalope
 public function testSessionRegistry()
 {
     $factory = new Factory();
     $repository = $this->getMock('Jackalope\\Repository', array(), array($factory), '', false);
     $transport = $this->getMockBuilder('Jackalope\\Transport\\TransportInterface')->disableOriginalConstructor()->getMock(array('login', 'logout', 'getRepositoryDescriptors', 'getNamespaces'), array($factory, 'http://example.com'));
     $transport->expects($this->any())->method('getNamespaces')->will($this->returnValue(array()));
     $s = new Session($factory, $repository, 'workspaceName', new SimpleCredentials('foo', 'bar'), $transport);
     $this->assertSame(Session::getSessionFromRegistry($s->getRegistryKey()), $s);
     $s->logout();
     $this->assertNull(Session::getSessionFromRegistry($s->getRegistryKey()));
 }
コード例 #5
0
ファイル: ContentMapperTest.php プロジェクト: Silwereth/sulu
 public function testCopyLanguageTree()
 {
     $data = $this->prepareCopyLanguageTree();
     $this->mapper->copyLanguage($data[0]->getUuid(), 1, 'sulu_io', 'de', 'en');
     $this->mapper->save(['title' => 'test-en', 'url' => '/test-en'], 'overview', 'sulu_io', 'en', 1, true, $data[0]->getUuid(), null, null, false);
     $this->session->refresh(false);
     $this->mapper->copyLanguage($data[1]->getUuid(), 1, 'sulu_io', 'de', 'en');
     $result = $this->mapper->load($data[0]->getUuid(), 'sulu_io', 'en');
     $this->assertEquals('test-en', $result->getPropertyValue('title'));
     $this->assertEquals('/test-en', $result->getPropertyValue('url'));
     $result = $this->mapper->load($data[1]->getUuid(), 'sulu_io', 'en');
     $this->assertEquals('childtest', $result->getPropertyValue('title'));
     $this->assertEquals('/test-en/childtest', $result->getPropertyValue('url'));
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $srcLocale = $input->getArgument('srcLocale');
     $destLocale = $input->getArgument('destLocale');
     $overwrite = $input->getOption('overwrite');
     $dryRun = $input->getOption('dry-run');
     $this->session = $this->getContainer()->get('doctrine_phpcr')->getManager()->getPhpcrSession();
     $this->queryManager = $this->session->getWorkspace()->getQueryManager();
     $this->languageNamespace = $this->getContainer()->getParameter('sulu.content.language.namespace');
     $this->snippetRepository = $this->getContainer()->get('sulu_snippet.repository');
     $this->contentMapper = $this->getContainer()->get('sulu.content.mapper');
     $this->output = $output;
     $this->copyNodes($srcLocale, $destLocale, $overwrite);
     if (false === $dryRun) {
         $this->output->writeln('<info>Saving ...</info>');
         $this->session->save();
         $this->output->writeln('<info>Done</info>');
     } else {
         $this->output->writeln('<info>Dry run complete</info>');
     }
 }
コード例 #7
0
ファイル: Item.php プロジェクト: frogriotcom/jackalope
 /**
  * Initialize basic information common to nodes and properties
  *
  * @param FactoryInterface $factory       the object factory
  * @param string           $path          The normalized and absolute path to this item
  * @param Session          $session
  * @param ObjectManager    $objectManager
  * @param boolean          $new           can be set to true to tell the object that it has
  *      been created locally
  */
 protected function __construct(FactoryInterface $factory, $path, Session $session, ObjectManager $objectManager, $new = false)
 {
     $this->factory = $factory;
     $this->valueConverter = $this->factory->get('PHPCR\\Util\\ValueConverter');
     $this->session = $session;
     $this->objectManager = $objectManager;
     $this->setState($new ? self::STATE_NEW : self::STATE_CLEAN);
     if (!$new && $session->getRepository()->getDescriptor(RepositoryInterface::OPTION_TRANSACTIONS_SUPPORTED)) {
         if ($session->getWorkspace()->getTransactionManager()->inTransaction()) {
             // properly set previous state in case we get into a rollback
             $this->savedState = self::STATE_CLEAN;
         }
     }
     $this->setPath($path);
 }
コード例 #8
0
 /**
  * Check whether stream was already loaded, otherwise fetch from backend
  * and cache it.
  *
  * Multivalued properties have a special handling since the backend returns
  * all streams in a single call.
  *
  * Always checks if the current session is still alive.
  *
  * @throws LogicException when trying to use a stream from a closed session
  *      and on trying to access a nonexisting multivalue id.
  *
  * @return void
  */
 private function init_stream()
 {
     if (null === $this->stream) {
         if ($this->session && !$this->session->isLive()) {
             throw new LogicException("Trying to read a stream from a closed transport.");
         }
         $url = parse_url($this->path);
         $this->session = Session::getSessionFromRegistry($url['host']);
         $property_path = $url['path'];
         $token = isset($url['user']) ? $url['user'] : null;
         if (null === $token) {
             $this->stream = $this->session->getObjectManager()->getBinaryStream($property_path);
         } else {
             // check if streams have been loaded for multivalued properties
             if (!isset(self::$multiValueMap[$token])) {
                 self::$multiValueMap[$token] = $this->session->getObjectManager()->getBinaryStream($property_path);
             }
             $index = isset($url['port']) ? $url['port'] - 1 : 0;
             if (!isset(self::$multiValueMap[$token][$index])) {
                 throw new LogicException("Trying to read a stream from a non existant token '{$token}' or token index '{$index}'.");
             }
             $this->stream = self::$multiValueMap[$token][$index];
         }
     }
 }
コード例 #9
0
ファイル: Session.php プロジェクト: frogriotcom/jackalope
 /**
  * Implementation specific: unregister session in session registry on
  * logout.
  *
  * @param Session $session the session to unregister
  *
  * @private
  */
 protected static function unregisterSession(Session $session)
 {
     $key = $session->getRegistryKey();
     unset(self::$sessionRegistry[$key]);
 }