function FileCopy::getDirectory

Same name in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/migrate/process/FileCopy.php \Drupal\migrate\Plugin\migrate\process\FileCopy::getDirectory()
  2. 10 core/modules/migrate/src/Plugin/migrate/process/FileCopy.php \Drupal\migrate\Plugin\migrate\process\FileCopy::getDirectory()
  3. 11.x core/modules/migrate/src/Plugin/migrate/process/FileCopy.php \Drupal\migrate\Plugin\migrate\process\FileCopy::getDirectory()

Returns the directory component of a URI or path.

For URIs like public://foo.txt, the full physical path of public:// will be returned, since a scheme by itself will trip up certain file API functions (such as \Drupal\Core\File\FileSystemInterface::prepareDirectory()).

Parameters

string $uri: The URI or path.

Return value

string|false The directory component of the path or URI, or FALSE if it could not be determined.

1 call to FileCopy::getDirectory()
FileCopy::transform in core/modules/migrate/src/Plugin/migrate/process/FileCopy.php
Performs the associated process.

File

core/modules/migrate/src/Plugin/migrate/process/FileCopy.php, line 211

Class

FileCopy
Copies or moves a local file from one place into another.

Namespace

Drupal\migrate\Plugin\migrate\process

Code

protected function getDirectory($uri) {
    $dir = $this->fileSystem
        ->dirname($uri);
    if (substr($dir, -3) == '://') {
        return $this->fileSystem
            ->realpath($dir);
    }
    return $dir;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.