[TASK] Re-work/simplify copyright header in PHP files - Part 1
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / FolderStructure / RootNode.php
1 <?php
2 namespace TYPO3\CMS\Install\FolderStructure;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Install\Status;
18
19 /**
20 * Root node of structure
21 */
22 class RootNode extends DirectoryNode implements RootNodeInterface {
23
24 /**
25 * Implement constructor
26 *
27 * @param array $structure Given structure
28 * @param NodeInterface $parent Must be NULL for RootNode
29 * @throws Exception\RootNodeException
30 * @throws Exception\InvalidArgumentException
31 */
32 public function __construct(array $structure, NodeInterface $parent = NULL) {
33 if (!is_null($parent)) {
34 throw new \TYPO3\CMS\Install\FolderStructure\Exception\RootNodeException(
35 'Root node must not have parent',
36 1366140117
37 );
38 }
39
40 if (!isset($structure['name'])
41 || ($this->isWindowsOs() && substr($structure['name'], 1, 2) !== ':/')
42 || (!$this->isWindowsOs() && $structure['name'][0] !== '/')
43 ) {
44 throw new \TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException(
45 'Root node expects absolute path as name',
46 1366141329
47 );
48 }
49 $this->name = $structure['name'];
50
51 if (isset($structure['targetPermission'])) {
52 $this->setTargetPermission($structure['targetPermission']);
53 }
54
55 if (array_key_exists('children', $structure)) {
56 $this->createChildren($structure['children']);
57 }
58 }
59
60 /**
61 * Get own status and status of child objects - Root node gives error status if not exists
62 *
63 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
64 */
65 public function getStatus() {
66 $result = array();
67 if (!$this->exists()) {
68 $status = new Status\ErrorStatus();
69 $status->setTitle($this->getAbsolutePath() . ' does not exist');
70 $result[] = $status;
71 } else {
72 $result = $this->getSelfStatus();
73 }
74 $result = array_merge($result, $this->getChildrenStatus());
75 return $result;
76 }
77
78 /**
79 * Root node does not call parent, but returns own name only
80 *
81 * @return string Absolute path
82 */
83 public function getAbsolutePath() {
84 return $this->name;
85 }
86 }