ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ILIAS\Setup\DirectoryCreatedObjective Class Reference

Create a directory. More...

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

Public Member Functions

 __construct (string $path, int $permissions=self::DEFAULT_DIRECTORY_PERMISSIONS)
 
 getHash ()
 Uses hashed Path. More...
 
 getLabel ()
 @inheritdocs More...
 
 isNotable ()
 Defaults to 'true'. More...
 
 getPreconditions (Environment $environment)
 @inheritdocs More...
 
 achieve (Environment $environment)
 @inheritdocs More...
 
 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...
 

Data Fields

const DEFAULT_DIRECTORY_PERMISSIONS = 0755
 

Protected Attributes

 $path
 
 $permissions
 

Detailed Description

Create a directory.

Definition at line 11 of file DirectoryCreatedObjective.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 25 of file DirectoryCreatedObjective.php.

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

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

Member Function Documentation

◆ achieve()

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

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 82 of file DirectoryCreatedObjective.php.

82 : Environment
83 {
84 if (!file_exists($this->path)) {
85 mkdir($this->path, $this->permissions);
86 }
87 if (!is_dir($this->path)) {
88 throw new UnachievableException(
89 "Could not create directory '{$this->path}'"
90 );
91 }
92 return $environment;
93 }

◆ getHash()

ILIAS\Setup\DirectoryCreatedObjective::getHash ( )

Uses hashed Path.

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 43 of file DirectoryCreatedObjective.php.

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

◆ getLabel()

ILIAS\Setup\DirectoryCreatedObjective::getLabel ( )

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 51 of file DirectoryCreatedObjective.php.

51 : string
52 {
53 return "Create directory '{$this->path}'";
54 }

◆ getPreconditions()

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

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 69 of file DirectoryCreatedObjective.php.

69 : array
70 {
71 if (file_exists($this->path)) {
72 return [];
73 }
74 return [
75 new CanCreateDirectoriesInDirectoryCondition(dirname($this->path))
76 ];
77 }

◆ isNotable()

ILIAS\Setup\DirectoryCreatedObjective::isNotable ( )

Defaults to 'true'.

@inheritdocs

Implements ILIAS\Setup\Objective.

Definition at line 61 of file DirectoryCreatedObjective.php.

61 : bool
62 {
63 return true;
64 }

Field Documentation

◆ $path

ILIAS\Setup\DirectoryCreatedObjective::$path
protected

◆ $permissions

ILIAS\Setup\DirectoryCreatedObjective::$permissions
protected

◆ DEFAULT_DIRECTORY_PERMISSIONS

const ILIAS\Setup\DirectoryCreatedObjective::DEFAULT_DIRECTORY_PERMISSIONS = 0755

Definition at line 13 of file DirectoryCreatedObjective.php.


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