ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Setup\Objective\DirectoryCreatedObjective Class Reference

Create a directory. More...

+ Inheritance diagram for ILIAS\Setup\Objective\DirectoryCreatedObjective:
+ Collaboration diagram for ILIAS\Setup\Objective\DirectoryCreatedObjective:

Public Member Functions

 __construct (string $path, int $permissions=self::DEFAULT_DIRECTORY_PERMISSIONS)
 
 getHash ()
 Uses hashed Path. More...
 
 getLabel ()
 Defaults to "Build $this->getArtifactPath()". More...
 
 isNotable ()
 Defaults to 'true'. More...
 
 getPreconditions (Setup\Environment $environment)
 @inheritdocs More...
 
 achieve (Setup\Environment $environment)
 @inheritdocs More...
 
 isApplicable (Setup\Environment $environment)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\Setup\Objective
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 Get to know whether the objective is applicable. More...
 

Data Fields

const DEFAULT_DIRECTORY_PERMISSIONS = 0755
 

Protected Attributes

 $path
 
 $permissions
 

Detailed Description

Create a directory.

Definition at line 13 of file DirectoryCreatedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\Objective\DirectoryCreatedObjective::__construct ( string  $path,
int  $permissions = self::DEFAULT_DIRECTORY_PERMISSIONS 
)

Definition at line 27 of file DirectoryCreatedObjective.php.

30 {
31 if ($path == "") {
32 throw new \InvalidArgumentException(
33 "Path is empty."
34 );
35 }
36 $this->path = $path;
37 $this->permissions = $permissions;
38 }

References ILIAS\Setup\Objective\DirectoryCreatedObjective\$path, and ILIAS\Setup\Objective\DirectoryCreatedObjective\$permissions.

Member Function Documentation

◆ achieve()

ILIAS\Setup\Objective\DirectoryCreatedObjective::achieve ( Setup\Environment  $environment)

@inheritdocs

Reimplemented in ilStorageContainersExistingObjective.

Definition at line 86 of file DirectoryCreatedObjective.php.

86 : Setup\Environment
87 {
88 mkdir($this->path, $this->permissions);
89
90 if (!is_dir($this->path)) {
91 throw new Setup\UnachievableException(
92 "Could not create directory '{$this->path}'"
93 );
94 }
95 return $environment;
96 }

◆ getHash()

ILIAS\Setup\Objective\DirectoryCreatedObjective::getHash ( )

Uses hashed Path.

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 45 of file DirectoryCreatedObjective.php.

45 : string
46 {
47 return hash("sha256", self::class . "::" . $this->path);
48 }

◆ getLabel()

ILIAS\Setup\Objective\DirectoryCreatedObjective::getLabel ( )

Defaults to "Build $this->getArtifactPath()".

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 55 of file DirectoryCreatedObjective.php.

55 : string
56 {
57 return "Create directory '{$this->path}'";
58 }

◆ getPreconditions()

ILIAS\Setup\Objective\DirectoryCreatedObjective::getPreconditions ( Setup\Environment  $environment)

@inheritdocs

Reimplemented in ilStorageContainersExistingObjective.

Definition at line 73 of file DirectoryCreatedObjective.php.

73 : array
74 {
75 if (file_exists($this->path)) {
76 return [];
77 }
78 return [
79 new Setup\Condition\CanCreateDirectoriesInDirectoryCondition(dirname($this->path))
80 ];
81 }

◆ isApplicable()

ILIAS\Setup\Objective\DirectoryCreatedObjective::isApplicable ( Setup\Environment  $environment)

@inheritDoc

Reimplemented in ilStorageContainersExistingObjective.

Definition at line 101 of file DirectoryCreatedObjective.php.

101 : bool
102 {
103 return !file_exists($this->path);
104 }

◆ isNotable()

ILIAS\Setup\Objective\DirectoryCreatedObjective::isNotable ( )

Defaults to 'true'.

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 65 of file DirectoryCreatedObjective.php.

65 : bool
66 {
67 return true;
68 }

Field Documentation

◆ $path

ILIAS\Setup\Objective\DirectoryCreatedObjective::$path
protected

◆ $permissions

ILIAS\Setup\Objective\DirectoryCreatedObjective::$permissions
protected

◆ DEFAULT_DIRECTORY_PERMISSIONS

const ILIAS\Setup\Objective\DirectoryCreatedObjective::DEFAULT_DIRECTORY_PERMISSIONS = 0755

Definition at line 15 of file DirectoryCreatedObjective.php.


The documentation for this class was generated from the following file: