ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 achieve (Setup\Environment $environment)
 
 isApplicable (Setup\Environment $environment)
 
- Public Member Functions inherited from ILIAS\Setup\Objective
 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.

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

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

Member Function Documentation

◆ achieve()

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

Definition at line 94 of file DirectoryCreatedObjective.php.

94  : Setup\Environment
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  }

◆ getHash()

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

Uses hashed Path.

Implements ILIAS\Setup\Objective.

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()".

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)

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)

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'.

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: