| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class RegistryImportFeedController extends Controller |
||
| 11 | { |
||
| 12 | private static $allowed_actions = [ |
||
|
|
|||
| 13 | 'latest', |
||
| 14 | ]; |
||
| 15 | |||
| 16 | private static $url_handlers = [ |
||
| 17 | '$Action/$ModelClass' => 'handleAction', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Get an RSS feed of the latest data imports that were made for this registry model. This will only |
||
| 22 | * return a valid result for classes that exist and implement the {@link RegistryDataInterface} interface. |
||
| 23 | * |
||
| 24 | * @param HTTPRequest $request |
||
| 25 | * @return DBHTMLText |
||
| 26 | */ |
||
| 27 | public function latest($request) |
||
| 28 | { |
||
| 29 | $feed = RegistryImportFeed::create(); |
||
| 30 | $modelClass = $this->unsanitiseClassName($request->param('ModelClass')); |
||
| 31 | |||
| 32 | if (!class_exists($modelClass) || !(singleton($modelClass) instanceof RegistryDataInterface)) { |
||
| 33 | return $this->httpError(404); |
||
| 34 | } |
||
| 35 | |||
| 36 | $feed->setModelClass($modelClass); |
||
| 37 | return $feed->getLatest()->outputToBrowser(); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * See {@link \SilverStripe\Admin\ModelAdmin::unsanitiseClassName} |
||
| 42 | */ |
||
| 43 | protected function unsanitiseClassName($class) |
||
| 46 | } |
||
| 47 | } |
||
| 48 |