ILIAS  release_7 Revision v7.30-3-g800a261c036
DirectoryCreatedObjective.php
Go to the documentation of this file.
1<?php
2
3
4/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de>, Fabian Schmid <fs@studer-raimann.ch> Extended GPL, see docs/LICENSE */
5
7
9
14{
16
20 protected $path;
21
25 protected $permissions;
26
27 public function __construct(
28 string $path,
29 int $permissions = self::DEFAULT_DIRECTORY_PERMISSIONS
30 ) {
31 if ($path == "") {
32 throw new \InvalidArgumentException(
33 "Path is empty."
34 );
35 }
36 $this->path = $path;
37 $this->permissions = $permissions;
38 }
39
45 public function getHash() : string
46 {
47 return hash("sha256", self::class . "::" . $this->path);
48 }
49
55 public function getLabel() : string
56 {
57 return "Create directory '{$this->path}'";
58 }
59
65 public function isNotable() : bool
66 {
67 return true;
68 }
69
73 public function getPreconditions(Setup\Environment $environment) : array
74 {
75 if (file_exists($this->path)) {
76 return [];
77 }
78 return [
80 ];
81 }
82
86 public function achieve(Setup\Environment $environment) : Setup\Environment
87 {
88 mkdir($this->path, $this->permissions);
89
90 if (!is_dir($this->path)) {
92 "Could not create directory '{$this->path}'"
93 );
94 }
95 return $environment;
96 }
97
101 public function isApplicable(Setup\Environment $environment) : bool
102 {
103 return !file_exists($this->path);
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
getPreconditions(Setup\Environment $environment)
@inheritdocs
getLabel()
Defaults to "Build $this->getArtifactPath()".
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
@inheritdocs
__construct(string $path, int $permissions=self::DEFAULT_DIRECTORY_PERMISSIONS)
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...