Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions Blueprints/src/BlueprintForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function load($extends = null)
}

// Import blueprints.
$this->deepImport($this->items);
$this->deepInit($this->items);
} catch (Exception $e) {
$filename = $this->filename;
Expand Down Expand Up @@ -387,6 +388,37 @@ protected function deepMerge(array $a, array $b)
return $a;
}


/**
* @param array $items
* @param array $path
* @return string
*/
protected function deepImport(array &$items, $path = [])
{
do {
$run_again = false;
$field = end($path) === 'fields';
foreach ($items as $key => &$item) {
if ($field && isset($item['type'])) {
$item['name'] = $key;
}
// Handle import@
if (strpos($key, '@') !== false && preg_match('/^(@*)?import(@\d*)?$/', $key)) {
unset($items[$key]);
$this->doImport($item, $path);
$run_again = true;
break;
} elseif (\is_array($item)) {
// Recursively initialize form.
$newPath = array_merge($path, [$key]);
$this->deepImport($item, $newPath);
}
}
unset($item);
} while ($run_again);
}

/**
* @param array $items
* @param array $path
Expand Down Expand Up @@ -418,10 +450,6 @@ protected function deepInit(array &$items, $path = [])
return null;
}
break;
case 'import':
unset($items[$key]);
$this->doImport($item, $path);
break;
case 'ordering':
$ordering = $item;
unset($items[$key]);
Expand All @@ -435,7 +463,7 @@ protected function deepInit(array &$items, $path = [])
$newPath = array_merge($path, [$key]);

$location = $this->deepInit($item, $newPath);
if ($location) {
if (null !== $location) {
$order[$key] = $location;
} elseif ($location === null) {
unset($items[$key]);
Expand Down
2 changes: 0 additions & 2 deletions StreamWrapper/src/ReadOnlyStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class ReadOnlyStream extends Stream
/** @var ResourceLocatorInterface */
protected static $locator;

public $context;

/**
* @param string $uri
* @param string $mode
Expand Down