Skip to content

Commit 8131da7

Browse files
committed
Custom assets path.
Added the ability to specify a custom assets path to the instantiated FrontEnd object.
1 parent 630ac82 commit 8131da7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
1717
### v3.1.0
1818

1919
[2020.10.30; Maikuolan]: Redesigned the login pips and refactored some CSS.
20+
21+
[2020.10.30; New Feature; Maikuolan]: Added the ability to specify a custom assets path to the instantiated FrontEnd object.

src/FrontEnd.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2020.10.26).
11+
* This file: Front-end handler (last modified: 2020.10.30).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -36,6 +36,11 @@ class FrontEnd
3636
*/
3737
private $AssetsPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
3838

39+
/**
40+
* @var string A path for any custom front-end asset files.
41+
*/
42+
public $CustomAssetsPath = '';
43+
3944
/**
4045
* @var string The path to the front-end L10N files.
4146
*/
@@ -131,6 +136,7 @@ class FrontEnd
131136
* Construct the loader.
132137
*
133138
* @param \phpMussel\Core\Loader $Loader The instantiated loader object, passed by reference.
139+
* @param \phpMussel\Core\Scanner $Scanner The instantiated scanner object, passed by reference.
134140
*/
135141
public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Scanner &$Scanner)
136142
{
@@ -1680,7 +1686,7 @@ public function view(string $Page = '')
16801686
);
16811687

16821688
/** Initialise array for fetching logs data. */
1683-
$FE['LogFiles'] = ['Files' => $this->logsRecursiveList($this->AssetsPath), 'Out' => ''];
1689+
$FE['LogFiles'] = ['Files' => $this->logsRecursiveList(), 'Out' => ''];
16841690

16851691
/** Text mode switch link base. */
16861692
$FE['TextModeSwitchLink'] = '';
@@ -1848,6 +1854,14 @@ private function getAssetPath(string $Asset, bool $CanFail = false): string
18481854
return '';
18491855
}
18501856

1857+
/** Custom assets. */
1858+
if ($this->CustomAssetsPath) {
1859+
$Try = $this->Loader->buildPath($this->CustomAssetsPath . DIRECTORY_SEPARATOR . $Asset);
1860+
if (is_readable($Try)) {
1861+
return $Try;
1862+
}
1863+
}
1864+
18511865
/** Non-default assets. */
18521866
if (
18531867
$this->Loader->Configuration['frontend']['theme'] !== 'default' &&

0 commit comments

Comments
 (0)