ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

string $path
 
int $permissions
 

Detailed Description

Create a directory.

Definition at line 28 of file DirectoryCreatedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 35 of file DirectoryCreatedObjective.php.

38 {
39 if ($path == "") {
40 throw new \InvalidArgumentException(
41 "Path is empty."
42 );
43 }
44 $this->path = $path;
45 $this->permissions = $permissions;
46 }

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

Definition at line 94 of file DirectoryCreatedObjective.php.

95 {
96 @mkdir($this->path, $this->permissions);
97
98 if (!is_dir($this->path)) {
99 throw new Setup\UnachievableException(
100 "Could not create directory '$this->path'"
101 );
102 }
103 return $environment;
104 }
An environment holds resources to be used in the setup process.
Definition: Environment.php:28

◆ getHash()

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

Uses hashed Path.

@inheritdocs

Implements ILIAS\Setup\Objective.

Reimplemented in ilFileSystemComponentDataDirectoryCreatedObjective.

Definition at line 53 of file DirectoryCreatedObjective.php.

53 : string
54 {
55 return hash("sha256", self::class . "::" . $this->path);
56 }

◆ getLabel()

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

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

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 63 of file DirectoryCreatedObjective.php.

63 : string
64 {
65 return "Create directory '$this->path'";
66 }

◆ getPreconditions()

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

@inheritdocs

Definition at line 81 of file DirectoryCreatedObjective.php.

81 : array
82 {
83 if (file_exists($this->path)) {
84 return [];
85 }
86 return [
87 new Setup\Condition\CanCreateDirectoriesInDirectoryCondition(dirname($this->path))
88 ];
89 }

◆ isApplicable()

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

@inheritDoc

Definition at line 109 of file DirectoryCreatedObjective.php.

109 : bool
110 {
111 return !file_exists($this->path);
112 }

◆ isNotable()

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

Defaults to 'true'.

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 73 of file DirectoryCreatedObjective.php.

73 : bool
74 {
75 return true;
76 }

Field Documentation

◆ $path

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

◆ $permissions

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

◆ DEFAULT_DIRECTORY_PERMISSIONS

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

Definition at line 30 of file DirectoryCreatedObjective.php.


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