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


PHP Filesystem::isAbsolutePath方法代码示例

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


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

示例1: locate

 /**
  * {@inheritdoc}
  */
 public function locate($name, $currentPath = null, $first = true)
 {
     if (empty($name)) {
         throw new \InvalidArgumentException('An empty file name is not valid to be located.');
     }
     if ($this->filesystem->isAbsolutePath($name)) {
         if (!$this->filesystem->exists($name)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $name));
         }
         return $name;
     }
     $directories = $this->paths;
     if (null !== $currentPath) {
         $directories[] = $currentPath;
         $directories = array_values(array_unique($directories));
     }
     $filepaths = [];
     $finder = new Finder();
     $finder->files()->name($name)->ignoreUnreadableDirs()->in($directories);
     /** @var SplFileInfo $file */
     if ($first && null !== ($file = $finder->getIterator()->current())) {
         return $file->getPathname();
     }
     foreach ($finder as $file) {
         $filepaths[] = $file->getPathname();
     }
     if (!$filepaths) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $directories)));
     }
     return array_values(array_unique($filepaths));
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:34,代码来源:RecursiveFileLocator.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $projectArg = $input->getOption('project');
     $drupalArg = $input->getOption('drupal');
     $project = !empty($projectArg) && $fs->isAbsolutePath($projectArg) ? $projectArg : implode('/', [getcwd(), $projectArg]);
     $drupal = $fs->isAbsolutePath($drupalArg) ? $drupalArg : implode('/', [getcwd(), $drupalArg]);
     $mapper = new Mapper($this->normalizePath($project), $this->normalizePath($drupal), $input->getOption('copy'));
     $mapper->clear();
     $mapper->mirror($mapper->getMap($this->getApplication()->getComposer(true)->getInstallationManager(), $this->getApplication()->getComposer(true)->getRepositoryManager()));
 }
开发者ID:mbolli,项目名称:drupal-tangler,代码行数:11,代码来源:Command.php

示例3: __invoke

 public function __invoke(Project $project)
 {
     $directory = $project->metadata['template.directory'];
     if ($directory === null) {
         $directory = $project->sourceDirectory . '/' . self::DEFAULT_TEMPLATE_DIRECTORY;
     }
     if (!$this->filesystem->isAbsolutePath($directory)) {
         $directory = $project->sourceDirectory . '/' . $directory;
     }
     $this->assertDirectoryExist($directory);
     $project->watchlist->watchDirectory($directory);
     $project->metadata['template.directory'] = $directory;
 }
开发者ID:jkhaled,项目名称:Couscous,代码行数:13,代码来源:ValidateTemplateDirectory.php

示例4: locate

 /**
  * @param string                $workingDir
  * @param PackageInterface|null $package
  *
  * @return string
  */
 public function locate($workingDir, PackageInterface $package = null)
 {
     $defaultPath = $workingDir . DIRECTORY_SEPARATOR . self::APP_CONFIG_FILE;
     $defaultPath = $this->locateConfigFileWithDistSupport($defaultPath);
     if (null !== $package) {
         $defaultPath = $this->useConfigPathFromComposer($package, $defaultPath);
     }
     // Make sure to set the full path when it is declared relative
     // This will fix some issues in windows.
     if (!$this->filesystem->isAbsolutePath($defaultPath)) {
         $defaultPath = $workingDir . DIRECTORY_SEPARATOR . $defaultPath;
     }
     return $defaultPath;
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:20,代码来源:ConfigurationFile.php

示例5: parse

 /**
  * @param string $path
  *
  * @return $this
  */
 public function parse($path)
 {
     if (!$this->fileSystem->isAbsolutePath($path)) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     if (!is_file($path)) {
         $this->finder->files()->in($path)->ignoreDotFiles(true)->ignoreVCS(true)->ignoreUnreadableDirs(true);
         foreach ($this->finder as $file) {
             $this->parseFile($file);
         }
         return $this;
     }
     $this->parseFile($path);
     return $this;
 }
开发者ID:amaxlab,项目名称:speller,代码行数:20,代码来源:ParserManager.php

示例6: execute

 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return int|null|void
  *
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     /**
      * We load the options to work with
      */
     $options = $this->getUsableConfig($input);
     /**
      * Building the real directory or file to work in
      */
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($path)) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     if (!is_file($path) && !is_dir($path)) {
         throw new Exception('Directory or file "' . $path . '" does not exist');
     }
     /**
      * Print dry-run message if needed
      */
     $this->printDryRunMessage($input, $output, $path);
     /**
      * Print all configuration block if verbose level allows it
      */
     $this->printConfigUsed($output, $options);
     $fileFinder = new FileFinder();
     $files = $fileFinder->findPHPFilesByPath($path);
     /**
      * Parse and fix all found files
      */
     $this->parseAndFixFiles($input, $output, $files, $options);
 }
开发者ID:jumbojett,项目名称:php-formatter,代码行数:42,代码来源:UseSortCommand.php

示例7:

 function it_should_locate_config_file_on_empty_composer_configuration(Filesystem $filesystem, PackageInterface $package)
 {
     $package->getExtra()->willReturn(array());
     $filesystem->exists($this->pathArgument('/composer/grumphp.yml'))->willReturn(true);
     $filesystem->isAbsolutePath($this->pathArgument('/composer/grumphp.yml'))->willReturn(true);
     $this->locate('/composer', $package)->shouldMatch($this->pathRegex('/composer/grumphp.yml'));
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:7,代码来源:ConfigurationFileSpec.php

示例8: fixRelativePath

 protected function fixRelativePath()
 {
     $fs = new Filesystem();
     if (!$fs->isAbsolutePath($this->scriptDirectory)) {
         $this->scriptDirectory = $this->workingDirectory . DIRECTORY_SEPARATOR . $this->scriptDirectory;
     }
 }
开发者ID:sickhye,项目名称:php-db-migrate,代码行数:7,代码来源:Config.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $database = $input->getArgument('database');
     $namespace = $input->getArgument('namespace');
     $location = $input->getArgument('location');
     $configfile = $input->getArgument('config-file');
     $tablesAll = $input->getOption('tables-all');
     $tablesRegex = $input->getOption('tables-regex');
     $tablesPrefix = $input->getOption('tables-prefix');
     if (!file_exists($configfile)) {
         $output->writeln(sprintf('<error>Incorrect config file path "%s"</error>', $configfile));
         return false;
     }
     $config = (require_once $configfile);
     $db_type = $config['db.type'];
     switch ($db_type) {
         case 'Mysql':
             $dbAdapter = new MakeMysql($config, $database, $namespace);
             break;
         default:
             break;
     }
     $tables = $dbAdapter->getTablesNamesFromDb();
     if (empty($tables)) {
         $output->writeln(sprintf('<error>Please provide at least one table to parse.</error>'));
         return false;
     }
     // Check if a relative path
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($location)) {
         $location = getcwd() . DIRECTORY_SEPARATOR . $location;
     }
     $location .= DIRECTORY_SEPARATOR;
     $dbAdapter->addTablePrefixes($tablesPrefix);
     $dbAdapter->setLocation($location);
     foreach (array('Table', 'Entity') as $name) {
         $dir = $location . $name;
         if (!is_dir($dir)) {
             if (!@mkdir($dir, 0755, true)) {
                 $output->writeln(sprintf('<error>Could not create directory zf2 "%s"</error>', $dir));
                 return false;
             }
         }
     }
     $dbAdapter->setTableList($tables);
     $dbAdapter->addTablePrefixes($tablesPrefix);
     foreach ($tables as $table) {
         if ($tablesRegex && !preg_match("/{$tablesRegex}/", $table) > 0) {
             continue;
         }
         $dbAdapter->setTableName($table);
         try {
             $dbAdapter->parseTable();
             $dbAdapter->generate();
         } catch (Exception $e) {
             $output->writeln(sprintf('<error>Warning: Failed to process "%s" : %s ... Skipping</error>', $table, $e->getMessage()));
         }
     }
     $output->writeln(sprintf('<info>Done !!</info>'));
 }
开发者ID:sizrar,项目名称:weez-common,代码行数:60,代码来源:GenerateDbModelCommand.php

示例10: copy

 /**
  * Clone a repository (clone is a reserved keyword).
  *
  * @param string $path
  * @param string $remote_url
  * @param null $repo
  * @param \Shell\Output\ProcessOutputInterface $output
  * @param bool $background
  * @return GitRepository|Process
  * @throws GitException
  */
 public static function copy($path, $remote_url, &$repo = null, $output = null, $background = false)
 {
     $fs = new Filesystem();
     if (!$fs->isAbsolutePath($path)) {
         throw new InvalidArgumentException('Path must be absolute.');
     }
     $fs->mkdir($path);
     $git = new Git($path);
     $repo = new GitRepository($git, $output);
     $args = [$remote_url, $path];
     if ($background) {
         $onSuccess = function () use(&$repo) {
             $repo->processGitConfig();
             $repo->setUpstream();
             $repo->initialized = true;
         };
         return $git->execNonBlocking('clone', $args, [], [], $onSuccess);
     } else {
         $git->exec('clone', $args, ['--verbose' => true]);
         $repo->processGitConfig();
         $repo->setUpstream();
         $repo->initialized = true;
         return $repo;
     }
 }
开发者ID:sp4ceb4r,项目名称:php-git,代码行数:36,代码来源:GitRepository.php

示例11: __construct

 /**
  * Set up our actions and filters
  */
 public function __construct()
 {
     // Create a Filesystem object.
     $this->filesystem = new \Symfony\Component\Filesystem\Filesystem();
     // Discover the correct relative path for the mu-plugins directory.
     $this->mu_plugin_dir = $this->filesystem->makePathRelative(WPMU_PLUGIN_DIR, WP_PLUGIN_DIR);
     if (!$this->filesystem->isAbsolutePath($this->mu_plugin_dir)) {
         $this->mu_plugin_dir = '/' . $this->mu_plugin_dir;
     }
     if ('/' === substr($this->mu_plugin_dir, -1)) {
         $this->mu_plugin_dir = rtrim($this->mu_plugin_dir, '/');
     }
     // Load the plugins
     add_action('muplugins_loaded', array($this, 'muplugins_loaded__requirePlugins'));
     // Adjust the MU plugins list table to show which plugins are MU
     add_action('after_plugin_row_muplugins-subdir-loader.php', array($this, 'after_plugin_row__addRows'));
 }
开发者ID:blueblazeassociates,项目名称:muplugins-subdir-loader,代码行数:20,代码来源:muplugins-subdir-loader.php

示例12: __construct

 /**
  * @param string $rootConfig
  * @param bool   $environment
  * @param        $debug
  */
 public function __construct($rootConfig, $environment, $debug)
 {
     $fs = new Filesystem();
     if (!$fs->isAbsolutePath($rootConfig) && !is_file($rootConfig = __DIR__ . '/' . $rootConfig)) {
         throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig));
     }
     $this->rootConfig = $rootConfig;
     parent::__construct($environment, $debug);
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:14,代码来源:AppKernel.php

示例13: processPidDirectoryConfiguration

 /**
  * @param array $config
  *
  * @return array
  */
 protected function processPidDirectoryConfiguration(array $config)
 {
     $pidDirectory = $config[$this->pidDirectorySetting];
     $fs = new Filesystem();
     if (!$fs->exists($pidDirectory)) {
         $fs->mkdir($pidDirectory);
     }
     $config[$this->pidDirectorySetting] = $fs->isAbsolutePath($pidDirectory) ? $pidDirectory : realpath($pidDirectory);
     return $config;
 }
开发者ID:jordigracia,项目名称:command-lock-bundle,代码行数:15,代码来源:CommandLockExtension.php

示例14: handle

 /**
  * Handles the "add-prefix" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int Returns 0 on success and a positive integer on error.
  */
 public function handle(Args $args, IO $io)
 {
     $prefix = rtrim($args->getArgument('prefix'), '\\');
     $paths = $args->getArgument('path');
     foreach ($paths as $path) {
         if (!$this->filesystem->isAbsolutePath($path)) {
             $path = getcwd() . DIRECTORY_SEPARATOR . $path;
         }
         if (is_dir($path)) {
             $this->finder->files()->name('*.php')->in($path);
             foreach ($this->finder as $file) {
                 $this->scopeFile($file->getPathName(), $prefix, $io);
             }
         }
         if (!is_file($path)) {
             continue;
         }
         $this->scopeFile($path, $prefix, $io);
     }
     return 0;
 }
开发者ID:belanur,项目名称:php-scoper,代码行数:29,代码来源:AddPrefixCommandHandler.php

示例15: __construct

 /**
  * Set up the object. Initialize the proper folder for storing the
  * files.
  *
  * @param  string                               $cacheDir
  * @throws \Exception|\InvalidArgumentException
  */
 public function __construct($cacheDir = null)
 {
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($cacheDir)) {
         $cacheDir = realpath(__DIR__ . "/" . $cacheDir);
     }
     try {
         parent::__construct($cacheDir, self::DEFAULT_EXTENSION);
     } catch (\InvalidArgumentException $e) {
         throw $e;
     }
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:19,代码来源:Cache.php


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