Skip to content

Commit

Permalink
Merge pull request #28 from GnaritasInc/pathfix
Browse files Browse the repository at this point in the history
Insure "path" is an array.
  • Loading branch information
OriHoch authored Aug 30, 2017
2 parents 017fa91 + 62ce08f commit c045648
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/Validators/DatapackageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ protected function getDescriptorForValidation()
foreach ($descriptor->resources as &$resource) {
if (is_object($resource)) {
$resource = clone $resource;
if (isset($resource->path) && is_array($resource->path)) {
foreach ($resource->path as &$url) {
if (is_string($url)) {
$url = 'file://'.$url;
if (isset($resource->path)) {
if (is_array($resource->path)) {
foreach ($resource->path as &$url) {
if (is_string($url)) {
$url = 'file://'.$url;
}
}
} elseif (is_string($resource->path)) {
$resource->path .= 'file://'.$resource->path;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Validators/ResourceValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ protected function getResourceClass()
protected function validateKeys()
{
$resourceClass = $this->getResourceClass();
foreach ($this->descriptor->path as $dataSource) {
// DS: path can be a string or an array
$sources = is_array($this->descriptor->path) ? $this->descriptor->path : array($this->descriptor->path);
foreach ($sources as $dataSource) {
foreach ($resourceClass::validateDataSource($dataSource, $this->basePath) as $error) {
$this->errors[] = $error;
}
Expand Down

0 comments on commit c045648

Please sign in to comment.