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


PHP PathHelper::getParentPath方法代码示例

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


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

示例1: setDefaults

 /**
  * {@inheritdoc}
  */
 public function setDefaults(MediaInterface $media, $parentPath = null)
 {
     $class = ClassUtils::getClass($media);
     // check and add name if possible
     if (!$media->getName()) {
         if ($media->getId()) {
             $media->setName(PathHelper::getNodeName($media->getId()));
         } else {
             throw new \RuntimeException(sprintf('Unable to set defaults, Media of type "%s" does not have a name or id.', $class));
         }
     }
     $rootPath = is_null($parentPath) ? $this->rootPath : $parentPath;
     $path = ($rootPath === '/' ? $rootPath : $rootPath . '/') . $media->getName();
     /** @var DocumentManager $dm */
     $dm = $this->getObjectManager();
     // TODO use PHPCR autoname once this is done: http://www.doctrine-project.org/jira/browse/PHPCR-103
     if ($dm->find($class, $path)) {
         // path already exists
         $media->setName($media->getName() . '_' . time() . '_' . rand());
     }
     if (!$media->getParent()) {
         $parent = $dm->find(null, PathHelper::getParentPath($path));
         $media->setParent($parent);
     }
 }
开发者ID:vespolina,项目名称:media,代码行数:28,代码来源:MediaManager.php

示例2: handlePersist

 /**
  * @param PersistEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handlePersist(PersistEvent $event)
 {
     $options = $event->getOptions();
     $this->validateOptions($options);
     $document = $event->getDocument();
     $parentPath = null;
     $nodeName = null;
     if ($options['path']) {
         $parentPath = PathHelper::getParentPath($options['path']);
         $nodeName = PathHelper::getNodeName($options['path']);
     }
     if ($options['parent_path']) {
         $parentPath = $options['parent_path'];
     }
     if ($parentPath) {
         $event->setParentNode($this->resolveParent($parentPath, $options));
     }
     if ($options['node_name']) {
         if (!$event->hasParentNode()) {
             throw new DocumentManagerException(sprintf('The "node_name" option can only be used either with the "parent_path" option ' . 'or when a parent node has been established by a previous subscriber. ' . 'When persisting document: %s', DocumentHelper::getDebugTitle($document)));
         }
         $nodeName = $options['node_name'];
     }
     if (!$nodeName) {
         return;
     }
     if ($event->hasNode()) {
         $this->renameNode($event->getNode(), $nodeName);
         return;
     }
     $node = $this->strategy->createNodeForDocument($document, $event->getParentNode(), $nodeName);
     $event->setNode($node);
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:38,代码来源:ExplicitSubscriber.php

示例3: setRouteRoot

 public function setRouteRoot($routeRoot)
 {
     // make limitation on base path work
     parent::setRootPath($routeRoot);
     // TODO: fix widget to show root node when root is selectable
     // https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/issues/148
     $this->routeRoot = PathHelper::getParentPath($routeRoot);
 }
开发者ID:symfony-cmf,项目名称:routing-bundle,代码行数:8,代码来源:RouteAdmin.php

示例4: createRoute

 /**
  * @param string $path
  *
  * @return Route
  */
 protected function createRoute($path)
 {
     $parentPath = PathHelper::getParentPath($path);
     $parent = $this->getDm()->find(null, $parentPath);
     $name = PathHelper::getNodeName($path);
     $route = new Route();
     $route->setPosition($parent, $name);
     $this->getDm()->persist($route);
     $this->getDm()->flush();
     return $route;
 }
开发者ID:killerwolf,项目名称:RoutingBundle,代码行数:16,代码来源:BaseTestCase.php

示例5: removeProperty

 public function removeProperty($workspace, $path)
 {
     $propertyName = PathHelper::getNodeName($path);
     $nodePath = PathHelper::getParentPath($path);
     $node = $this->nodeReader->readNode($workspace, $nodePath);
     $property = $node->getProperty($propertyName);
     if (in_array($property['type'], array('Reference', 'WeakReference'))) {
         $this->index->deindexReferrer($node->getPropertyValue(Storage::INTERNAL_UUID), $propertyName, $property['type'] === 'Reference' ? false : true);
     }
     $node->removeProperty($propertyName);
     $this->nodeWriter->writeNode($workspace, $nodePath, $node);
 }
开发者ID:jackalope,项目名称:jackalope-fs,代码行数:12,代码来源:Storage.php

示例6: findParentRoute

 /**
  * Finds the parent route document by concatenating the basepaths with the
  * requested path.
  *
  * @return null|object
  */
 protected function findParentRoute($requestedPath)
 {
     $manager = $this->getManagerForClass('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Phpcr\\Route');
     $parentPaths = array();
     foreach ($this->routeBasePaths as $basepath) {
         $parentPaths[] = PathHelper::getParentPath($basepath . $requestedPath);
     }
     $parentRoutes = $manager->findMany(null, $parentPaths);
     if (0 === count($parentRoutes)) {
         return;
     }
     return $parentRoutes->first();
 }
开发者ID:symfony-cmf,项目名称:seo-bundle,代码行数:19,代码来源:BaseSuggestionProvider.php

示例7: create

 /**
  * {@inheritdoc}
  */
 public function create(Request $request)
 {
     $routes = array();
     $manager = $this->getManagerForClass('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Phpcr\\Route');
     $parentPath = PathHelper::getParentPath($this->routeBasePath . $request->getPathInfo());
     $parentRoute = $manager->find(null, $parentPath);
     if (!$parentRoute) {
         return $routes;
     }
     if ($parentRoute instanceof Route) {
         $routes[$parentRoute->getName()] = $parentRoute;
     }
     return $routes;
 }
开发者ID:damonsson,项目名称:SeoBundle,代码行数:17,代码来源:ParentSuggestionProvider.php

示例8: loadPhpcr

 protected function loadPhpcr($config, XmlFileLoader $loader, ContainerBuilder $container)
 {
     $loader->load('services-phpcr.xml');
     $loader->load('migrator-phpcr.xml');
     $prefix = $this->getAlias() . '.persistence.phpcr';
     $container->setParameter($prefix . '.basepath', $config['basepath']);
     $container->setParameter($prefix . '.menu_basepath', PathHelper::getParentPath($config['basepath']));
     if ($config['use_sonata_admin']) {
         $this->loadSonataAdmin($config, $loader, $container);
     } elseif (isset($config['sonata_admin'])) {
         throw new InvalidConfigurationException('Do not define sonata_admin options when use_sonata_admin is set to false');
     }
     $container->setParameter($prefix . '.manager_name', $config['manager_name']);
     $container->setParameter($prefix . '.document.class', $config['document_class']);
 }
开发者ID:creatiombe,项目名称:SimpleCmsBundle,代码行数:15,代码来源:CmfSimpleCmsExtension.php

示例9: resolveSiblingName

 private function resolveSiblingName($siblingId, NodeInterface $parentNode, NodeInterface $node)
 {
     if (null === $siblingId) {
         return;
     }
     $siblingPath = $siblingId;
     if (UUIDHelper::isUUID($siblingId)) {
         $siblingPath = $this->nodeManager->find($siblingId)->getPath();
     }
     if ($siblingPath !== null && PathHelper::getParentPath($siblingPath) !== $parentNode->getPath()) {
         throw new DocumentManagerException(sprintf('Cannot reorder documents which are not siblings. Trying to reorder "%s" to "%s"', $node->getPath(), $siblingPath));
     }
     if (null !== $siblingPath) {
         return PathHelper::getNodeName($siblingPath);
     }
     return $node->getName();
 }
开发者ID:hason,项目名称:sulu-document-manager,代码行数:17,代码来源:ReorderSubscriber.php

示例10: init

 /**
  * {@inheritDoc}
  */
 public function init(ManagerRegistry $registry)
 {
     /** @var $dm DocumentManager */
     $dm = $registry->getManagerForClass('Symfony\\Cmf\\Bundle\\SimpleCmsBundle\\Doctrine\\Phpcr\\Page');
     if ($dm->find(null, $this->basePath)) {
         return;
     }
     $session = $dm->getPhpcrSession();
     NodeHelper::createPath($session, PathHelper::getParentPath($this->basePath));
     $page = new $this->documentClass();
     $page->setId($this->basePath);
     $page->setLabel('Home');
     $page->setTitle('Homepage');
     $page->setBody('Autocreated Homepage');
     $dm->persist($page);
     $dm->flush();
 }
开发者ID:2lenet,项目名称:SimpleCmsBundle,代码行数:20,代码来源:HomepageInitializer.php

示例11: init

 /**
  * {@inheritdoc}
  */
 public function init(ManagerRegistry $registry)
 {
     /** @var $dm DocumentManager */
     $dm = $registry->getManagerForClass('AppBundle\\Document\\SeoPage');
     if ($dm->find(null, $this->basePath)) {
         return;
     }
     $session = $dm->getPhpcrSession();
     NodeHelper::createPath($session, PathHelper::getParentPath($this->basePath));
     /** @var \AppBundle\Document\SeoPage $page */
     $page = new $this->documentClass();
     $page->setId($this->basePath);
     $page->setLabel('Home');
     $page->setTitle('Homepage');
     $page->setBody('Autocreated Homepage');
     $page->setIsVisibleForSitemap(true);
     $dm->persist($page);
     $dm->flush();
 }
开发者ID:symfony-cmf,项目名称:symfony-cmf-website,代码行数:22,代码来源:HomePageInitializer.php

示例12: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getPhpcrHelper();
     $session = $this->getPhpcrSession();
     $path = $input->getArgument('path');
     $type = $input->getOption('type');
     $dump = $input->getOption('dump');
     $setProp = $input->getOption('set-prop');
     $removeProp = $input->getOption('remove-prop');
     $addMixins = $input->getOption('add-mixin');
     $removeMixins = $input->getOption('remove-mixin');
     try {
         $node = $session->getNode($path);
     } catch (PathNotFoundException $e) {
         $node = null;
     }
     if ($node) {
         $nodeType = $node->getPrimaryNodeType()->getName();
         $output->writeln(sprintf('<info>Node at path </info>%s <info>already exists and has primary type</info> %s.', $path, $nodeType));
         if ($nodeType != $type) {
             $output->writeln(sprintf('<error>You have specified node type "%s" but the existing node is of type "%s"</error>', $type, $nodeType));
             return 1;
         }
     } else {
         $nodeName = PathHelper::getNodeName($path);
         $parentPath = PathHelper::getParentPath($path);
         try {
             $parentNode = $session->getNode($parentPath);
         } catch (PathNotFoundException $e) {
             $output->writeln(sprintf('<error>Parent path "%s" does not exist</error>', $parentPath));
             return 2;
         }
         $output->writeln(sprintf('<info>Creating node: </info> %s [%s]', $path, $type));
         $node = $parentNode->addNode($nodeName, $type);
     }
     $helper->processNode($output, $node, array('setProp' => $setProp, 'removeProp' => $removeProp, 'addMixins' => $addMixins, 'removeMixins' => $removeMixins, 'dump' => $dump));
     $session->save();
     return 0;
 }
开发者ID:frogriotcom,项目名称:phpcr-utils,代码行数:42,代码来源:NodeTouchCommand.php

示例13: getBinaryStream

 /**
  * {@inheritDoc}
  * @throws RepositoryException when no binary data found
  */
 public function getBinaryStream($path)
 {
     $this->assertLoggedIn();
     $nodePath = PathHelper::getParentPath($path);
     $nodeId = $this->getSystemIdForNode($nodePath);
     $propertyName = PathHelper::getNodeName($path);
     $data = $this->getConnection()->fetchAll('SELECT data, idx FROM phpcr_binarydata WHERE node_id = ? AND property_name = ? AND workspace_name = ?', array($nodeId, $propertyName, $this->workspaceName));
     if (count($data) === 0) {
         throw new RepositoryException('No binary data found in stream');
     }
     $streams = array();
     foreach ($data as $row) {
         if (is_resource($row['data'])) {
             $stream = $row['data'];
         } else {
             $stream = fopen('php://memory', 'rwb+');
             fwrite($stream, $row['data']);
             rewind($stream);
         }
         $streams[] = $stream;
     }
     if (count($data) === 1) {
         // we don't know if this is a multivalue property or not.
         // TODO we should have something more efficient to know this. a flag in the database?
         // TODO use self::getProperty()->isMultiple() once implemented
         $node = $this->getNode($nodePath);
         if (!is_array($node->{':' . $propertyName})) {
             return reset($streams);
         }
     }
     return $streams;
 }
开发者ID:jackalope,项目名称:jackalope-doctrine-dbal,代码行数:36,代码来源:Client.php

示例14: restore

 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function restore($removeExisting, $version, $absPath = null)
 {
     if ($this->objectManager->hasPendingChanges()) {
         throw new InvalidItemStateException('You may not call restore when there pending unsaved changes');
     }
     if (is_string($version)) {
         if (!is_string($absPath)) {
             throw new InvalidArgumentException('To restore version by version name you need to specify the path to the node you want to restore to this name');
         }
         $vh = $this->getVersionHistory($absPath);
         $version = $vh->getVersion($version);
         $versionPath = $version->getPath();
         $nodePath = $absPath;
     } elseif (is_array($version)) {
         // @codeCoverageIgnoreStart
         throw new NotImplementedException('TODO: implement restoring a list of versions');
         // @codeCoverageIgnoreEnd
     } elseif ($version instanceof VersionInterface && is_string($absPath)) {
         // @codeCoverageIgnoreStart
         throw new NotImplementedException('TODO: implement restoring a version to a specified path');
         // @codeCoverageIgnoreEnd
     } elseif ($version instanceof VersionInterface) {
         $versionPath = $version->getPath();
         $nodePath = $this->objectManager->getNodeByIdentifier($version->getContainingHistory()->getVersionableIdentifier())->getPath();
     } else {
         throw new InvalidArgumentException();
     }
     $this->objectManager->restore($removeExisting, $versionPath, $nodePath);
     $version->setCachedPredecessorsDirty();
     if ($history = $this->objectManager->getCachedNode(PathHelper::getParentPath($version->getPath()), 'Version\\VersionHistory')) {
         $history->notifyHistoryChanged();
     }
 }
开发者ID:viral810,项目名称:ngSimpleCMS,代码行数:38,代码来源:VersionManager.php

示例15: getBinaryStream

    /**
     * {@inheritDoc}
     */
    public function getBinaryStream($path)
    {
        $this->assertLoggedIn();

        $nodePath = PathHelper::getParentPath($path);
        $nodeId = $this->pathExists($nodePath);
        $propertyName = PathHelper::getNodeName($path);

        $data = $this->conn->fetchAll(
            'SELECT data, idx FROM phpcr_binarydata WHERE node_id = ? AND property_name = ? AND workspace_name = ?',
            array($nodeId, $propertyName, $this->workspaceName)
        );

        $streams = array();
        foreach ($data as $row) {
            if (is_resource($row['data'])) {
                $stream = $row['data'];
            } else {
                $stream = fopen('php://memory', 'rwb+');
                fwrite($stream, $row['data']);
                rewind($stream);
            }

            $streams[] = $stream;
        }

        // TODO even a multi value field could have only one value stored
        // we need to also fetch if the property is multi valued instead of this count() check
        if (count($data) > 1) {
            return $streams;
        }

        return reset($streams);
    }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:37,代码来源:Client.php


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