Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #106 from apility/feature/webpack-assets-base-path
Browse files Browse the repository at this point in the history
Adds basePath from jwt payload to WebpackAssets
  • Loading branch information
thomas-alrek authored Nov 13, 2019
2 parents 2cb7a1e + a034d23 commit 4d5eebf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"ivopetkov/html5-dom-document-php": "^2.0",
"apility/netflex-support": "^1.0",
"psy/psysh": "^0.9.9",
"apility/webpack-assets": "^1.0"
"apility/webpack-assets": "^1.0.2"
},
"require-dev": {
"phpunit/phpunit": "^8.1",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/NF.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ public static function init($site = null, $branch = null, $path = [])
self::$commerce = new Commerce();

self::$search = new ElasticSearch();

self::setWebpackAssets();
}

/** Sets webpackAssets */
public static function setWebpackAssets () {
global $payload;

$basePath = $payload->domain ?? null;

self::$webpackAssets = isset(self::$config['webpackManifest'])
? new WebpackAssets(self::$config['webpackManifest'], [
'defaultEntrypoint' => 'app',
'preload' => true,
'basePath' => $basePath,
])
: null;

Expand Down
4 changes: 4 additions & 0 deletions src/controller_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
$payload = NF::$jwt->decode($token);
$controller = NF::nfPath('pagefinder/' . $payload->scope . '_' . $payload->relation . '.php');

NF::setWebpackAssets();

if (file_exists($controller)) {
require $controller;
die();
Expand All @@ -33,6 +35,8 @@
die('Invalid or expired token');
}

NF::setWebpackAssets();

if ($url == '') {
$url = 'index';
}
Expand Down

0 comments on commit 4d5eebf

Please sign in to comment.