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


PHP Util\PathHelper类代码示例

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


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

示例1: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $session = $this->get('phpcr.session');
     $file = $input->getArgument('file');
     $pretty = $input->getOption('pretty');
     $exportDocument = $input->getOption('document');
     $dialog = $this->get('helper.question');
     if (file_exists($file)) {
         $confirmed = true;
         if (false === $input->getOption('no-interaction')) {
             $confirmed = $dialog->ask($input, $output, new ConfirmationQuestion('File already exists, overwrite?'));
         }
         if (false === $confirmed) {
             return;
         }
     }
     $stream = fopen($file, 'w');
     $absPath = $input->getArgument('absPath');
     PathHelper::assertValidAbsolutePath($absPath);
     if (true === $exportDocument) {
         $session->exportDocumentView($absPath, $stream, $input->getOption('skip-binary'), $input->getOption('no-recurse'));
     } else {
         $session->exportSystemView($absPath, $stream, $input->getOption('skip-binary'), $input->getOption('no-recurse'));
     }
     fclose($stream);
     if ($pretty) {
         $xml = new \DOMDocument(1.0);
         $xml->load($file);
         $xml->preserveWhitespace = true;
         $xml->formatOutput = true;
         $xml->save($file);
     }
 }
开发者ID:phpcr,项目名称:phpcr-shell,代码行数:33,代码来源:SessionExportCommand.php

示例2: preFlush

 public function preFlush(ManagerEventArgs $args)
 {
     if (empty($this->stack)) {
         return;
     }
     $metadataFactory = $args->getObjectManager()->getMetadataFactory();
     foreach ($this->stack as $data) {
         $children = $data['children'];
         $ctMetadata = $data['ct_metadata'];
         $childrenField = $data['field'];
         $index = 0;
         foreach ($children as $child) {
             $childMetadata = $metadataFactory->getMetadataFor(ClassUtils::getRealClass(get_class($child)));
             $expectedId = $this->encoder->encode($childrenField, $index++);
             $identifier = $childMetadata->getIdentifierValue($child);
             $idGenerator = $childMetadata->idGenerator;
             if ($idGenerator !== ClassMetadata::GENERATOR_TYPE_ASSIGNED) {
                 throw new \InvalidArgumentException(sprintf('Currently, all documents which belong to a mapped collection must use the ' . 'assigned ID generator strategy, "%s" is using "%s".', $childMetadata->getName(), $idGenerator));
             }
             if (!$identifier || PathHelper::getNodeName($identifier) !== $expectedId) {
                 throw new \InvalidArgumentException(sprintf('Child mapped to content type "%s" on field "%s" has an unexpected ID "%s". ' . 'It is currently necessary to envoke the CollectionIdentifierUpdater on all ' . 'documents (at least those which have collections) before they are persisted.', $ctMetadata->getType(), $childrenField, $identifier));
             }
         }
     }
 }
开发者ID:symfony-cmf,项目名称:content-type,代码行数:25,代码来源:CollectionSubscriber.php

示例3: doSerializeResource

 private function doSerializeResource(Resource $resource, $depth = 0)
 {
     $data = array();
     $repositoryAlias = $this->registry->getRepositoryAlias($resource->getRepository());
     $data['repository_alias'] = $repositoryAlias;
     $data['repository_type'] = $this->registry->getRepositoryType($resource->getRepository());
     $data['payload_alias'] = $this->payloadAliasRegistry->getPayloadAlias($resource);
     $data['payload_type'] = null;
     if ($resource instanceof CmfResource) {
         $data['payload_type'] = $resource->getPayloadType();
     }
     $data['path'] = $resource->getPath();
     $data['label'] = $data['node_name'] = PathHelper::getNodeName($data['path']);
     $data['repository_path'] = $resource->getRepositoryPath();
     $enhancers = $this->enhancerRegistry->getEnhancers($repositoryAlias);
     $children = array();
     foreach ($resource->listChildren() as $name => $childResource) {
         $children[$name] = array();
         if ($depth < 2) {
             $children[$name] = $this->doSerializeResource($childResource, $depth + 1);
         }
     }
     $data['children'] = $children;
     if ($resource instanceof BodyResource) {
         $data['body'] = $resource->getBody();
     }
     foreach ($enhancers as $enhancer) {
         $data = $enhancer->enhance($data, $resource);
     }
     return $data;
 }
开发者ID:frogriotcom,项目名称:ResourceRestBundle,代码行数:31,代码来源:ResourceHandler.php

示例4: 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

示例5: 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

示例6: mapPathToId

 /**
  * {@inheritdoc}
  */
 public function mapPathToId($path, $rootPath = null)
 {
     // The path is being the id
     $id = PathHelper::absolutizePath($path, '/');
     if (is_string($rootPath) && 0 !== strpos($id, $rootPath)) {
         throw new \OutOfBoundsException(sprintf('The path "%s" is out of the root path "%s" were the file system is located.', $path, $rootPath));
     }
     return $id;
 }
开发者ID:vespolina,项目名称:media,代码行数:12,代码来源:MediaManager.php

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: getNodePath

 public function getNodePath($workspace, $path, $withFilename = true)
 {
     $path = PathHelper::normalizePath($path);
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
     }
     if ($path) {
         $path .= '/';
     }
     $nodeRecordPath = Storage::WORKSPACE_PATH . '/' . $workspace . '/' . $path . 'node.yml';
     if ($withFilename === false) {
         $nodeRecordPath = dirname($nodeRecordPath);
     }
     return $nodeRecordPath;
 }
开发者ID:jackalope,项目名称:jackalope-fs,代码行数:15,代码来源:StorageHelper.php

示例12: 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

示例13: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $session = $this->get('phpcr.session');
     $file = $input->getArgument('file');
     $parentAbsPath = $input->getArgument('parentAbsPath');
     $uuidBehavior = $input->getOption('uuid-behavior');
     if (!in_array($uuidBehavior, $this->uuidBehaviors)) {
         throw new \Exception(sprintf("The specified uuid behavior \"%s\" is invalid, you should use one of:\n%s", $uuidBehavior, '    - ' . implode("\n    - ", $this->uuidBehaviors)));
     }
     if (!file_exists($file)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not exist', $file));
     }
     PathHelper::assertValidAbsolutePath($parentAbsPath);
     $uuidBehavior = constant('\\PHPCR\\ImportUUIDBehaviorInterface::IMPORT_UUID_' . strtoupper(str_replace('-', '_', $uuidBehavior)));
     $session->importXml($parentAbsPath, $file, $uuidBehavior);
 }
开发者ID:hason,项目名称:phpcr-shell,代码行数:16,代码来源:SessionImportCommand.php

示例14: 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

示例15: 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


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