Skip to content

Commit

Permalink
Insure "path" is an array.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Santucci committed Aug 29, 2017
1 parent 017fa91 commit f6a3dd9
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;
}
}
} else if (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 f6a3dd9

Please sign in to comment.