當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。