Skip to content

Commit 9ee3930

Browse files
committed
Begin manifest resource publish
1 parent 67e6082 commit 9ee3930

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

src/Libraries/Manifests.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public function publish($path): bool
6060
{
6161
return false;
6262
}
63+
64+
// Proceed resource by resource
65+
$result = true;
66+
foreach ($manifest->resources as $resource)
67+
{
68+
$result = $result && $this->publishResource($resource);
69+
}
70+
71+
return $result;
6372
}
6473

6574
// Read in and verify a manifest from a file path
@@ -118,7 +127,7 @@ protected function manifestFromFile($path): ?object
118127
}
119128

120129
// Verify or create a destination folder and all folders up to it
121-
protected function secureDestination($path): ?object
130+
protected function secureDestination($path): bool
122131
{
123132
$directory = rtrim($this->config->fileBase, '/');
124133

@@ -133,15 +142,18 @@ protected function secureDestination($path): ?object
133142
{
134143
$directory .= $segment . '/';
135144

136-
if ($this->ensureDirectory($directory))
145+
if (! $this->ensureDirectory($directory))
137146
{
138-
$this->addIndexToDirectory($directory);
147+
return false;
139148
}
140-
else
149+
150+
if (! $this->addIndexToDirectory($directory))
141151
{
142-
return;
152+
return false;
143153
}
144154
}
155+
156+
return true;
145157
}
146158

147159
// Make sure a directory exists and is writable
@@ -222,4 +234,20 @@ protected function getIndexHtml(): string
222234
</body>
223235
</html>
224236
';
237+
}
238+
239+
// Parse a resource and copy it to the determined destination
240+
protected function publishResource($resource): ?object
241+
{
242+
// Validate the source
243+
if (! isset($resource->source))
244+
{
245+
return false;
246+
}
247+
248+
// Make sure the source exists
249+
$file = new File($resource->source);
250+
//WIP
251+
252+
}
225253
}

tests/_support/Manifests/LawyerPack.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"source": "WidgetModule/dist",
33
"destination": "vendor/widgets",
4-
"paths": [
4+
"resources": [
55
{
66
"source": "/",
77
"filter": [

tests/_support/Manifests/Widgets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"source": "WidgetModule/dist",
33
"destination": "vendor/widgets",
4-
"paths": [
4+
"resources": [
55
{
66
"source": "widget_style.css",
77
"destination": "vendor/widgets/css"

tests/_support/Manifests/frontend.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"source": "FrontendModule",
33
"destination": "vendor/frontend",
4-
"paths": [
4+
"resources": [
55
{
66
"source": "/",
77
"recursive": true,

0 commit comments

Comments
 (0)