当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeHelper::purgeWorkspace方法代码示例

本文整理汇总了PHP中PHPCR\Util\NodeHelper::purgeWorkspace方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeHelper::purgeWorkspace方法的具体用法?PHP NodeHelper::purgeWorkspace怎么用?PHP NodeHelper::purgeWorkspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPCR\Util\NodeHelper的用法示例。


在下文中一共展示了NodeHelper::purgeWorkspace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $session = $this->getPhpcrSession();
        $force = $input->getOption('force');

        $workspaceName = $session->getWorkspace()->getName();
        if (!$force) {
            /** @var $dialog DialogHelper */
            $dialog = $this->getHelperSet()->get('dialog');
            $force = $dialog->askConfirmation($output, sprintf(
                '<question>Are you sure you want to purge workspace "%s" Y/N ?</question>',
                $workspaceName
            ), false);
        }

        if (!$force) {
            $output->writeln('<error>Aborted</error>');

            return 1;
        }

        $output->writeln(sprintf('<info>Purging workspace:</info> %s', $workspaceName));

        // Using the static NodeHelper is bad for testing as we cannot mock it.
        NodeHelper::purgeWorkspace($session);
        $session->save();

        return 0;
    }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:32,代码来源:WorkspacePurgeCommand.php

示例2: testPurge

 public function testPurge()
 {
     $systemNodeCount = count($this->session->getRootNode()->getNodes());
     $a = $this->session->getRootNode()->addNode('a', 'nt:unstructured');
     $a->addMixin('mix:referenceable');
     $b = $this->session->getRootNode()->addNode('b', 'nt:unstructured');
     $b->addMixin('mix:referenceable');
     $this->session->save();
     $a->setProperty('ref', $b, PropertyType::REFERENCE);
     $b->setProperty('ref', $a, PropertyType::REFERENCE);
     $this->session->save();
     NodeHelper::purgeWorkspace($this->session);
     if ($this->session->getWorkspace()->getName() == 'crx.default') {
         // if we would continue, we would delete all content from the only real workspace
         $this->markTestIncomplete('TODO: how to test this with crx where we have no workspaces?');
     }
     $this->session->save();
     // if there where system nodes, they should still be here
     $this->assertCount($systemNodeCount, $this->session->getRootNode()->getNodes());
 }
开发者ID:laurentiuc,项目名称:phpcr-api-tests,代码行数:20,代码来源:PurgeTest.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var SessionInterface $session */
     $session = $this->getContainer()->get('sulu.phpcr.session')->getSession();
     /** @var WorkspaceInterface $workspace */
     $workspace = $session->getWorkspace();
     // init node namespace and types
     $output->writeln('Register namespace');
     $workspace->getNamespaceRegistry()->registerNamespace('sulu', 'http://sulu.io/phpcr');
     $workspace->getNamespaceRegistry()->registerNamespace($this->getContainer()->getParameter('sulu.content.language.namespace'), 'http://sulu.io/phpcr/locale');
     $output->writeln('Register node types');
     foreach ([new SuluNodeType(), new PathNodeType(), new ContentNodeType(), new SnippetNodeType(), new PageNodeType(), new HomeNodeType()] as $nodeType) {
         $output->writeln('  - ' . $nodeType->getName());
         $workspace->getNodeTypeManager()->registerNodeType($nodeType, true);
     }
     /** @var SessionInterface $session */
     $session = $this->getContainer()->get('sulu.phpcr.session')->getSession();
     if ($input->getOption('clear')) {
         NodeHelper::purgeWorkspace($session);
         $session->save();
         $output->writeln('Clear repository');
     }
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:23,代码来源:PHPCRInitCommand.php

示例4: testDeleteMoreThanOneThousandNodes

 public function testDeleteMoreThanOneThousandNodes()
 {
     $nodes = array();
     $root = $this->session->getNode('/');
     $parent = $root->addNode('test-more-than-one-thousand');
     for ($i = 0; $i <= 1200; $i++) {
         $nodes[] = $parent->addNode('node-' . $i);
     }
     $this->session->save();
     NodeHelper::purgeWorkspace($this->session);
     $this->session->save();
 }
开发者ID:frogriotcom,项目名称:jackalope-doctrine-dbal,代码行数:12,代码来源:ClientTest.php

示例5: addNode

 /**
  * Helper method for importing to add a node with the proper uuid behavior
  *
  * @param \PHPCR\NodeInterface $parentNode   the node to add this node to
  * @param string               $nodename     the node name to use
  * @param string               $type         the primary type name to use
  * @param int                  $uuidBehavior one of the constants of ImportUUIDBehaviorInterface
  *
  * @return NodeInterface the created node
  *
  * @throws \PHPCR\ItemExistsException if IMPORT_UUID_COLLISION_THROW and
  *      duplicate id
  * @throws \PHPCR\NodeType\ConstraintViolationException if behavior is remove or
  *      replace and the node with the uuid is in the parent path.
  */
 private static function addNode(NodeInterface $parentNode, $nodename, $type, $properties, $uuidBehavior)
 {
     $forceReferenceable = false;
     if (isset($properties['jcr:uuid'])) {
         try {
             $existing = $parentNode->getSession()->getNodeByIdentifier($properties['jcr:uuid']['values']);
             switch ($uuidBehavior) {
                 case self::IMPORT_UUID_CREATE_NEW:
                     unset($properties['jcr:uuid']);
                     $forceReferenceable = true;
                     break;
                 case self::IMPORT_UUID_COLLISION_THROW:
                     throw new ItemExistsException('There already is a node with uuid ' . $properties['jcr:uuid']['values'] . ' in this workspace.');
                 case self::IMPORT_UUID_COLLISION_REMOVE_EXISTING:
                 case self::IMPORT_UUID_COLLISION_REPLACE_EXISTING:
                     if (self::IMPORT_UUID_COLLISION_REPLACE_EXISTING == $uuidBehavior && 'jcr:root' == $nodename && $existing->getDepth() == 0) {
                         break;
                     }
                     if (!strncmp($existing->getPath() . '/', $parentNode->getPath() . "/{$nodename}", strlen($existing->getPath() . '/'))) {
                         throw new ConstraintViolationException('Trying to remove/replace parent of the path we are adding to. ' . $existing->getIdentifier() . ' at ' . $existing->getPath());
                     }
                     if (self::IMPORT_UUID_COLLISION_REPLACE_EXISTING == $uuidBehavior) {
                         // replace the found node. spec is not precise: do we keep the name or use the one of existing?
                         $parentNode = $existing->getParent();
                     }
                     $existing->remove();
                     break;
                 default:
                     // @codeCoverageIgnoreStart
                     throw new RepositoryException("Unexpected type {$uuidBehavior}");
                     // @codeCoverageIgnoreEnd
             }
         } catch (\PHPCR\ItemNotFoundException $e) {
             // nothing to do, we can add the node without conflict
         }
     }
     /* we add a jcr:root somewhere in the tree (either create new ids or
      * the root was not referenceable. do not make jackrabbit think it
      * would be the real root node.
      */
     if ('jcr:root' === $nodename && 'rep:root' === $type) {
         $type = 'nt:unstructured';
     }
     if ('jcr:root' == $nodename && isset($existing) && $existing->getDepth() === 0 && self::IMPORT_UUID_COLLISION_REPLACE_EXISTING == $uuidBehavior) {
         // update the root node properties
         // http://www.day.com/specs/jcr/2.0/11_Import.html#11.9%20Importing%20%3CI%3Ejcr:root%3C/I%3E
         NodeHelper::purgeWorkspace($parentNode->getSession());
         $node = $existing;
     } else {
         $node = $parentNode->addNode($nodename, $type);
     }
     foreach ($properties as $name => $info) {
         if ('jcr:primaryType' == $name) {
             // handled in node constructor
         } elseif ('jcr:mixinTypes' == $name) {
             if (is_array($info['values'])) {
                 foreach ($info['values'] as $type) {
                     $node->addMixin($type);
                 }
             } else {
                 $node->addMixin($info['values']);
             }
         } elseif ('jcr:created' == $name || 'jcr:createdBy' == $name) {
             // skip PROTECTED properties. TODO: get the names from node type instead of hardcode
         } elseif ('jcr:uuid' == $name) {
             //avoid to throw an exception when trying to set a UUID when importing from XML
             $node->setProperty($name, $info['values'], $info['type'], false);
         } else {
             $node->setProperty($name, $info['values'], $info['type']);
         }
     }
     if ($forceReferenceable && !$node->isNodeType('mix:referenceable')) {
         $node->addMixin('mix:referenceable');
     }
     return $node;
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:91,代码来源:ImportExport.php

示例6: iPurgeTheCurrentWorkspace

 /**
  * @Given /^I purge the current workspace$/
  */
 public function iPurgeTheCurrentWorkspace()
 {
     $session = $this->getSession();
     NodeHelper::purgeWorkspace($session);
 }
开发者ID:hason,项目名称:phpcr-shell,代码行数:8,代码来源:ContextBase.php

示例7: purge

 /**
  * @inheritDoc
  */
 public function purge()
 {
     $session = $this->dm->getPhpcrSession();
     NodeHelper::purgeWorkspace($session);
     $session->save();
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:9,代码来源:PHPCRPurger.php

示例8: initPhpcr

 /**
  * Initialize / reset the Sulu PHPCR environment.
  *
  * NOTE: We could use the document initializer here rather than manually creating
  *       the webspace nodes, but it currently adds more overhead and offers
  *       no control over *which* webspaces are created, see
  *       https://github.com/sulu-io/sulu/pull/2063 for a solution.
  */
 protected function initPhpcr()
 {
     /** @var SessionInterface $session */
     $session = $this->getContainer()->get('sulu_document_manager.default_session');
     $liveSession = $this->getContainer()->get('sulu_document_manager.live_session');
     if ($session->nodeExists('/cmf')) {
         NodeHelper::purgeWorkspace($session);
         $session->save();
     }
     if ($liveSession->nodeExists('/cmf')) {
         NodeHelper::purgeWorkspace($liveSession);
         $liveSession->save();
     }
     if (!$this->importer) {
         $this->importer = new PHPCRImporter($session, $liveSession);
     }
     // initialize the content repository.  in order to speed things up, for
     // each process, we dump the initial state to an XML file and restore
     // it thereafter.
     $initializerDump = __DIR__ . '/../Resources/app/cache/initial.xml';
     $initializerDumpLive = __DIR__ . '/../Resources/app/cache/initial_live.xml';
     if (true === self::$workspaceInitialized) {
         $session->importXml('/', $initializerDump, ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
         $session->save();
         $liveSession->importXml('/', $initializerDumpLive, ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
         $liveSession->save();
         return;
     }
     $filesystem = new Filesystem();
     if (!$filesystem->exists(dirname($initializerDump))) {
         $filesystem->mkdir(dirname($initializerDump));
     }
     $this->getContainer()->get('sulu_document_manager.initializer')->initialize();
     $handle = fopen($initializerDump, 'w');
     $liveHandle = fopen($initializerDumpLive, 'w');
     $session->exportSystemView('/cmf', $handle, false, false);
     $liveSession->exportSystemView('/cmf', $liveHandle, false, false);
     fclose($handle);
     self::$workspaceInitialized = true;
 }
开发者ID:sulu,项目名称:sulu,代码行数:48,代码来源:SuluTestCase.php

示例9: purgeWorkspace

 /**
  * Purge the workspace.
  */
 public function purgeWorkspace()
 {
     NodeHelper::purgeWorkspace($this->session);
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:7,代码来源:NodeManager.php


注:本文中的PHPCR\Util\NodeHelper::purgeWorkspace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。