Skip to content

Commit c045648

Browse files
authored
Merge pull request #28 from GnaritasInc/pathfix
Insure "path" is an array.
2 parents 017fa91 + 62ce08f commit c045648

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Validators/DatapackageValidator.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ protected function getDescriptorForValidation()
2929
foreach ($descriptor->resources as &$resource) {
3030
if (is_object($resource)) {
3131
$resource = clone $resource;
32-
if (isset($resource->path) && is_array($resource->path)) {
33-
foreach ($resource->path as &$url) {
34-
if (is_string($url)) {
35-
$url = 'file://'.$url;
32+
if (isset($resource->path)) {
33+
if (is_array($resource->path)) {
34+
foreach ($resource->path as &$url) {
35+
if (is_string($url)) {
36+
$url = 'file://'.$url;
37+
}
3638
}
39+
} elseif (is_string($resource->path)) {
40+
$resource->path .= 'file://'.$resource->path;
3741
}
3842
}
3943
}

src/Validators/ResourceValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ protected function getResourceClass()
4444
protected function validateKeys()
4545
{
4646
$resourceClass = $this->getResourceClass();
47-
foreach ($this->descriptor->path as $dataSource) {
47+
// DS: path can be a string or an array
48+
$sources = is_array($this->descriptor->path) ? $this->descriptor->path : array($this->descriptor->path);
49+
foreach ($sources as $dataSource) {
4850
foreach ($resourceClass::validateDataSource($dataSource, $this->basePath) as $error) {
4951
$this->errors[] = $error;
5052
}

0 commit comments

Comments
 (0)