| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class ElementalAreaController extends LeftAndMain |
||
| 15 | { |
||
| 16 | private static $url_segment = 'element-area'; |
||
|
|
|||
| 17 | |||
| 18 | private static $ignore_menuitem = true; |
||
| 19 | |||
| 20 | private static $allowed_actions = array( |
||
| 21 | 'elementForm', |
||
| 22 | 'schema', |
||
| 23 | ); |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param HTTPRequest|null $request |
||
| 27 | * @return Form |
||
| 28 | * @throws \SilverStripe\Control\HTTPResponse_Exception |
||
| 29 | */ |
||
| 30 | public function elementForm(HTTPRequest $request = null) |
||
| 31 | { |
||
| 32 | // Get ID either from posted back value, or url parameter |
||
| 33 | if (!$request) { |
||
| 34 | $this->jsonError(400); |
||
| 35 | return null; |
||
| 36 | } |
||
| 37 | $id = $request->param('ID'); |
||
| 38 | if (!$id) { |
||
| 39 | $this->jsonError(400); |
||
| 40 | return null; |
||
| 41 | } |
||
| 42 | return $this->getElementForm($id) ?: $this->jsonError(404); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param int $elementID |
||
| 47 | * @return Form|null Returns null if no element exists for the given ID |
||
| 48 | */ |
||
| 49 | public function getElementForm($elementID) |
||
| 62 | ); |
||
| 63 | } |
||
| 65 |