TYPO3 CMS  TYPO3_7-6
BackendLayoutCollection.php
Go to the documentation of this file.
1 <?php
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 
21 {
25  protected $identifier;
26 
30  protected $backendLayouts = [];
31 
35  public function __construct($identifier)
36  {
37  $this->setIdentifier($identifier);
38  }
39 
43  public function getIdentifier()
44  {
45  return $this->identifier;
46  }
47 
52  public function setIdentifier($identifier)
53  {
54  if (strpos($identifier, '__') !== false) {
55  throw new \UnexpectedValueException(
56  'Identifier "' . $identifier . '" must not contain "__"',
57  1381597631
58  );
59  }
60 
61  $this->identifier = $identifier;
62  }
63 
70  public function add(BackendLayout $backendLayout)
71  {
72  $identifier = $backendLayout->getIdentifier();
73 
74  if (strpos($identifier, '__') !== false) {
75  throw new \UnexpectedValueException(
76  'BackendLayout Identifier "' . $identifier . '" must not contain "__"',
77  1381597628
78  );
79  }
80 
81  if (isset($this->backendLayouts[$identifier])) {
82  throw new \LogicException(
83  'Backend Layout ' . $identifier . ' is already defined',
84  1381559376
85  );
86  }
87 
88  $this->backendLayouts[$identifier] = $backendLayout;
89  }
90 
97  public function get($identifier)
98  {
99  $backendLayout = null;
100 
101  if (isset($this->backendLayouts[$identifier])) {
102  $backendLayout = $this->backendLayouts[$identifier];
103  }
104 
105  return $backendLayout;
106  }
107 
113  public function getAll()
114  {
115  return $this->backendLayouts;
116  }
117 }