本文整理汇总了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));
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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'));
}
示例8: fixRelativePath
protected function fixRelativePath()
{
$fs = new Filesystem();
if (!$fs->isAbsolutePath($this->scriptDirectory)) {
$this->scriptDirectory = $this->workingDirectory . DIRECTORY_SEPARATOR . $this->scriptDirectory;
}
}
示例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>'));
}
示例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;
}
}
示例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'));
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}