Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 13 |
CRAP | |
0.00% |
0 / 1 |
| Entrypoint | |
0.00% |
0 / 33 |
|
0.00% |
0 / 13 |
210 | |
0.00% |
0 / 1 |
| fromSimpleXMLElement | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
6 | |||
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUrl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExtensionId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getReplacedIds | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| hasAccess | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __toPhpCode | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2014 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\tao\model\menu; |
| 24 | |
| 25 | use oat\oatbox\PhpSerializable; |
| 26 | use tao_models_classes_accessControl_AclProxy; |
| 27 | use oat\tao\model\entryPoint\Entrypoint as InterfaceEntrypoint; |
| 28 | |
| 29 | class Entrypoint implements InterfaceEntrypoint, PhpSerializable |
| 30 | { |
| 31 | public const SERIAL_VERSION = 1392821334; |
| 32 | |
| 33 | private $data = []; |
| 34 | |
| 35 | public static function fromSimpleXMLElement(\SimpleXMLElement $node) |
| 36 | { |
| 37 | $replaced = []; |
| 38 | foreach ($node->xpath("replace") as $replacedNode) { |
| 39 | $replaced[] = (string) $replacedNode['id']; |
| 40 | } |
| 41 | |
| 42 | $url = (string) $node['url']; |
| 43 | list($extension, $controller, $action) = explode('/', trim($url, '/')); |
| 44 | |
| 45 | return new static([ |
| 46 | 'id' => (string) $node['id'], |
| 47 | 'title' => (string) $node['title'], |
| 48 | 'label' => (string) $node['label'], |
| 49 | 'desc' => (string) $node->description, |
| 50 | 'url' => $url, |
| 51 | 'extension' => $extension, |
| 52 | 'controller' => $controller, |
| 53 | 'action' => $action, |
| 54 | 'replace' => $replaced |
| 55 | ]); |
| 56 | } |
| 57 | |
| 58 | public function __construct($data, $version = self::SERIAL_VERSION) |
| 59 | { |
| 60 | $this->data = $data; |
| 61 | } |
| 62 | |
| 63 | public function getId() |
| 64 | { |
| 65 | return $this->data['id']; |
| 66 | } |
| 67 | |
| 68 | public function getTitle() |
| 69 | { |
| 70 | return $this->data['title']; |
| 71 | } |
| 72 | |
| 73 | public function getLabel() |
| 74 | { |
| 75 | return $this->data['label']; |
| 76 | } |
| 77 | |
| 78 | public function getDescription() |
| 79 | { |
| 80 | return $this->data['desc']; |
| 81 | } |
| 82 | |
| 83 | public function getUrl() |
| 84 | { |
| 85 | return _url($this->getAction(), $this->getController(), $this->getExtensionId()); |
| 86 | } |
| 87 | |
| 88 | public function getExtensionId() |
| 89 | { |
| 90 | return $this->data['extension']; |
| 91 | } |
| 92 | |
| 93 | public function getController() |
| 94 | { |
| 95 | return $this->data['controller']; |
| 96 | } |
| 97 | |
| 98 | public function getAction() |
| 99 | { |
| 100 | return $this->data['action']; |
| 101 | } |
| 102 | |
| 103 | public function getReplacedIds() |
| 104 | { |
| 105 | return $this->data['replace']; |
| 106 | } |
| 107 | |
| 108 | public function hasAccess() |
| 109 | { |
| 110 | list($ext, $mod, $act) = explode('/', trim($this->data['url'], '/')); |
| 111 | return tao_models_classes_accessControl_AclProxy::hasAccess($act, $mod, $ext); |
| 112 | } |
| 113 | |
| 114 | public function __toPhpCode() |
| 115 | { |
| 116 | return "new " . __CLASS__ . "(" |
| 117 | . \common_Utils::toPHPVariableString($this->data) . ',' |
| 118 | . \common_Utils::toPHPVariableString(self::SERIAL_VERSION) |
| 119 | . ")"; |
| 120 | } |
| 121 | } |