class vfsStreamDirectory in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamDirectory.php \org\bovigo\vfs\vfsStreamDirectory
Directory container.
@api
Hierarchy
- class \org\bovigo\vfs\vfsStreamAbstractContent implements vfsStreamContent
- class \org\bovigo\vfs\vfsStreamDirectory implements vfsStreamContainer
Expanded class hierarchy of vfsStreamDirectory
7 files declare their use of vfsStreamDirectory
- PermissionHandlerTest.php in core/
modules/ user/ tests/ src/ Unit/ PermissionHandlerTest.php - Contains \Drupal\Tests\user\Unit\PermissionHandlerTest.
- vfsStreamAbstractVisitorTestCase.php in vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ visitor/ vfsStreamAbstractVisitorTestCase.php - vfsStreamPrintVisitor.php in vendor/
mikey179/ vfsStream/ src/ main/ php/ org/ bovigo/ vfs/ visitor/ vfsStreamPrintVisitor.php - vfsStreamPrintVisitorTestCase.php in vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ visitor/ vfsStreamPrintVisitorTestCase.php - vfsStreamStructureVisitor.php in vendor/
mikey179/ vfsStream/ src/ main/ php/ org/ bovigo/ vfs/ visitor/ vfsStreamStructureVisitor.php
File
- vendor/
mikey179/ vfsStream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStreamDirectory.php, line 16
Namespace
org\bovigo\vfsView source
class vfsStreamDirectory extends vfsStreamAbstractContent implements vfsStreamContainer {
/**
* list of directory children
*
* @type vfsStreamContent[]
*/
protected $children = array();
/**
* constructor
*
* @param string $name
* @param int $permissions optional
* @throws vfsStreamException
*/
public function __construct($name, $permissions = null) {
if (strstr($name, '/') !== false) {
throw new vfsStreamException('Directory name can not contain /.');
}
$this->type = vfsStreamContent::TYPE_DIR;
parent::__construct($name, $permissions);
}
/**
* returns default permissions for concrete implementation
*
* @return int
* @since 0.8.0
*/
protected function getDefaultPermissions() {
return 0777;
}
/**
* returns size of directory
*
* The size of a directory is always 0 bytes. To calculate the summarized
* size of all children in the directory use sizeSummarized().
*
* @return int
*/
public function size() {
return 0;
}
/**
* returns summarized size of directory and its children
*
* @return int
*/
public function sizeSummarized() {
$size = 0;
foreach ($this->children as $child) {
if ($child
->getType() === vfsStreamContent::TYPE_DIR) {
$size += $child
->sizeSummarized();
}
else {
$size += $child
->size();
}
}
return $size;
}
/**
* renames the content
*
* @param string $newName
* @throws vfsStreamException
*/
public function rename($newName) {
if (strstr($newName, '/') !== false) {
throw new vfsStreamException('Directory name can not contain /.');
}
parent::rename($newName);
}
/**
* sets parent path
*
* @param string $parentPath
* @internal only to be set by parent
* @since 1.2.0
*/
public function setParentPath($parentPath) {
parent::setParentPath($parentPath);
foreach ($this->children as $child) {
$child
->setParentPath($this
->path());
}
}
/**
* adds child to the directory
*
* @param vfsStreamContent $child
*/
public function addChild(vfsStreamContent $child) {
$child
->setParentPath($this
->path());
$this->children[$child
->getName()] = $child;
$this
->updateModifications();
}
/**
* removes child from the directory
*
* @param string $name
* @return bool
*/
public function removeChild($name) {
foreach ($this->children as $key => $child) {
if ($child
->appliesTo($name)) {
$child
->setParentPath(null);
unset($this->children[$key]);
$this
->updateModifications();
return true;
}
}
return false;
}
/**
* updates internal timestamps
*/
protected function updateModifications() {
$time = time();
$this->lastAttributeModified = $time;
$this->lastModified = $time;
}
/**
* checks whether the container contains a child with the given name
*
* @param string $name
* @return bool
*/
public function hasChild($name) {
return $this
->getChild($name) !== null;
}
/**
* returns the child with the given name
*
* @param string $name
* @return vfsStreamContent
*/
public function getChild($name) {
$childName = $this
->getRealChildName($name);
foreach ($this->children as $child) {
if ($child
->getName() === $childName) {
return $child;
}
if ($child
->appliesTo($childName) === true && $child
->hasChild($childName) === true) {
return $child
->getChild($childName);
}
}
return null;
}
/**
* helper method to detect the real child name
*
* @param string $name
* @return string
*/
protected function getRealChildName($name) {
if ($this
->appliesTo($name) === true) {
return self::getChildName($name, $this->name);
}
return $name;
}
/**
* helper method to calculate the child name
*
* @param string $name
* @param string $ownName
* @return string
*/
protected static function getChildName($name, $ownName) {
if ($name === $ownName) {
return $name;
}
return substr($name, strlen($ownName) + 1);
}
/**
* checks whether directory contains any children
*
* @return bool
* @since 0.10.0
*/
public function hasChildren() {
return count($this->children) > 0;
}
/**
* returns a list of children for this directory
*
* @return vfsStreamContent[]
*/
public function getChildren() {
return array_values($this->children);
}
/**
* returns iterator for the children
*
* @return vfsStreamContainerIterator
*/
public function getIterator() {
return new vfsStreamContainerIterator($this->children);
}
/**
* checks whether dir is a dot dir
*
* @return bool
*/
public function isDot() {
if ('.' === $this->name || '..' === $this->name) {
return true;
}
return false;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
vfsStreamAbstractContent:: |
protected | property | owner group of the file | |
vfsStreamAbstractContent:: |
protected | property | timestamp of last access | |
vfsStreamAbstractContent:: |
protected | property | timestamp of last attribute modification | |
vfsStreamAbstractContent:: |
protected | property | timestamp of last modification | |
vfsStreamAbstractContent:: |
protected | property | name of the container | |
vfsStreamAbstractContent:: |
private | property | path to to this content | |
vfsStreamAbstractContent:: |
protected | property | permissions for content | |
vfsStreamAbstractContent:: |
protected | property | type of the container | |
vfsStreamAbstractContent:: |
protected | property | owner of the file | |
vfsStreamAbstractContent:: |
public | function |
checks whether the container can be applied to given name Overrides vfsStreamContent:: |
1 |
vfsStreamAbstractContent:: |
public | function |
adds content to given container Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
change owner group of file to given group Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
change file mode to given permissions Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
change owner of file to given user Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function | returns the last access time of the stream content | |
vfsStreamAbstractContent:: |
public | function | returns the last attribute modification time of the stream content | |
vfsStreamAbstractContent:: |
public | function |
returns the last modification time of the stream content Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns owner group of file Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns the file name of the content Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns permissions Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns the type of the container Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns owner of file Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
checks whether content is executable Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
checks whether file is owned by group Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
checks whether file is owned by given user Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
checks whether content is readable Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
checks whether content is writable Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function | sets last access time of the stream content | |
vfsStreamAbstractContent:: |
public | function | sets the last attribute modification time of the stream content | |
vfsStreamAbstractContent:: |
public | function |
sets the last modification time of the stream content Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns path to this content Overrides vfsStreamContent:: |
|
vfsStreamAbstractContent:: |
public | function |
returns complete vfsStream url for this content Overrides vfsStreamContent:: |
|
vfsStreamContent:: |
constant | stream content type: block | ||
vfsStreamContent:: |
constant | stream content type: directory | ||
vfsStreamContent:: |
constant | stream content type: file | ||
vfsStreamDirectory:: |
protected | property | list of directory children | |
vfsStreamDirectory:: |
public | function |
adds child to the directory Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
public | function |
returns the child with the given name Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
protected static | function | helper method to calculate the child name | |
vfsStreamDirectory:: |
public | function |
returns a list of children for this directory Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
protected | function |
returns default permissions for concrete implementation Overrides vfsStreamAbstractContent:: |
|
vfsStreamDirectory:: |
public | function | returns iterator for the children | 1 |
vfsStreamDirectory:: |
protected | function | helper method to detect the real child name | |
vfsStreamDirectory:: |
public | function |
checks whether the container contains a child with the given name Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
public | function |
checks whether directory contains any children Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
public | function | checks whether dir is a dot dir | 1 |
vfsStreamDirectory:: |
public | function |
removes child from the directory Overrides vfsStreamContainer:: |
|
vfsStreamDirectory:: |
public | function |
renames the content Overrides vfsStreamAbstractContent:: |
|
vfsStreamDirectory:: |
public | function |
sets parent path Overrides vfsStreamAbstractContent:: |
|
vfsStreamDirectory:: |
public | function |
returns size of directory Overrides vfsStreamContent:: |
|
vfsStreamDirectory:: |
public | function | returns summarized size of directory and its children | |
vfsStreamDirectory:: |
protected | function | updates internal timestamps | |
vfsStreamDirectory:: |
public | function |
constructor Overrides vfsStreamAbstractContent:: |