|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverStripe\CKANRegistry\Page; |
|
4
|
|
|
|
|
5
|
|
|
use PageController; |
|
|
|
|
|
|
6
|
|
|
use SilverStripe\CKANRegistry\Model\Resource; |
|
7
|
|
|
use SilverStripe\ORM\DataObject; |
|
8
|
|
|
|
|
9
|
|
|
class CKANRegistryPageController extends PageController |
|
10
|
|
|
{ |
|
11
|
|
|
private static $url_handlers = [ |
|
|
|
|
|
|
12
|
|
|
// Route all requests for this page, including sub-URLs, to the index action. |
|
13
|
|
|
// The frontend components should take care of handling sub-URL routing from here. |
|
14
|
|
|
'view/$Item' => 'index', |
|
15
|
|
|
]; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Loads model data encapsulated as JSON in order to power front end technologies used to render that |
|
19
|
|
|
* data. Includes critical info such as the CKAN site to query (e.g. which domain, datastore, etc.) |
|
20
|
|
|
* but also can be extended to be used for configuring the component used to show this (e.g. React.js |
|
21
|
|
|
* or Vue.js component configuration). |
|
22
|
|
|
* |
|
23
|
|
|
* @param DataObject $holder |
|
24
|
|
|
* @return array |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getCKANClientConfig(DataObject $holder = null) |
|
27
|
|
|
{ |
|
28
|
|
|
if (!$holder) { |
|
29
|
|
|
$holder = $this->data(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** @var Resource $resource */ |
|
33
|
|
|
$resource = $holder->getComponent('DataResource'); |
|
34
|
|
|
|
|
35
|
|
|
$config = [ |
|
36
|
|
|
'spec' => [ |
|
37
|
|
|
'endpoint' => $resource->Endpoint, |
|
38
|
|
|
'dataset' => $resource->DataSet, |
|
39
|
|
|
'identifier' => $resource->Identifier, |
|
40
|
|
|
], |
|
41
|
|
|
'name' => $resource->Name, |
|
42
|
|
|
'resourceName' => $resource->ResourceName, |
|
43
|
|
|
'basePath' => $this->getBasePath($holder), |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
$this->extend('updateCKANClientConfig', $config); |
|
47
|
|
|
|
|
48
|
|
|
return $config; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns the base path for the resource's page with a leading slash |
|
53
|
|
|
* |
|
54
|
|
|
* @param DataObject $holder |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getBasePath(DataObject $holder = null) |
|
58
|
|
|
{ |
|
59
|
|
|
if (!$holder) { |
|
60
|
|
|
return '/'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$link = $holder->RelativeLink(); |
|
64
|
|
|
return '/' . trim($link, '/'); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths