Moved the PathMaker trait functionality to Filesystem class (see October Rain)
This commit is contained in:
parent
fbf5cbbb67
commit
b3936330a6
|
|
@ -14,10 +14,10 @@ use System\Traits\ViewMaker;
|
|||
*/
|
||||
class ControllerBehavior extends ExtensionBase
|
||||
{
|
||||
use \Backend\Traits\WidgetMaker;
|
||||
use \System\Traits\AssetMaker;
|
||||
use \System\Traits\ConfigMaker;
|
||||
use \Backend\Traits\WidgetMaker;
|
||||
use \Backend\Traits\ViewMaker {
|
||||
use \System\Traits\ViewMaker {
|
||||
ViewMaker::makeFileContents as localMakeFileContents;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ use Assetic\Cache\FilesystemCache;
|
|||
*/
|
||||
class CombineAssets
|
||||
{
|
||||
use \System\Traits\PathMaker;
|
||||
|
||||
/**
|
||||
* @var Self Instance for multi cycle execution.
|
||||
*/
|
||||
|
|
@ -376,7 +374,7 @@ class CombineAssets
|
|||
$filesSalt = null;
|
||||
foreach ($assets as $asset) {
|
||||
$filters = $this->getFilters(File::extension($asset));
|
||||
$path = $this->makePath($asset) ?: $this->path . $asset;
|
||||
$path = File::symbolizePath($asset) ?: $this->path . $asset;
|
||||
$files[] = new FileAsset($path, $filters, public_path());
|
||||
$filesSalt .= $this->path . $asset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
<?php namespace System\Traits;
|
||||
|
||||
/**
|
||||
* Path Maker Trait
|
||||
*
|
||||
* Converts path symbols to relevant points in the filesystem.
|
||||
*
|
||||
* $ - Relative to the plugins directory
|
||||
* ~ - Relative to the application directory
|
||||
*
|
||||
* @package october\system
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
|
||||
trait PathMaker
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array Known path symbols and their prefixes.
|
||||
*/
|
||||
protected $pathSymbols = [
|
||||
'$' => PATH_PLUGINS,
|
||||
'~' => PATH_BASE,
|
||||
// '/' => PATH_BASE, // @deprecated
|
||||
'@' => PATH_BASE, // @deprecated
|
||||
];
|
||||
|
||||
/**
|
||||
* Converts a path.
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function makePath($path, $default = false)
|
||||
{
|
||||
if (!$firstChar = $this->isPathSymbol($path))
|
||||
return $default;
|
||||
|
||||
$_path = substr($path, 1);
|
||||
return $this->pathSymbols[$firstChar] . $_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the path uses a symbol.
|
||||
* @param string $path
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPathSymbol($path)
|
||||
{
|
||||
$firstChar = substr($path, 0, 1);
|
||||
if (isset($this->pathSymbols[$firstChar]))
|
||||
return $firstChar;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,8 +16,6 @@ use System\Classes\SystemException;
|
|||
|
||||
trait ViewMaker
|
||||
{
|
||||
use \System\Traits\PathMaker;
|
||||
|
||||
/**
|
||||
* @var array A list of variables to pass to the page.
|
||||
*/
|
||||
|
|
@ -52,7 +50,7 @@ trait ViewMaker
|
|||
*/
|
||||
public function makePartial($partial, $params = [], $throwException = true)
|
||||
{
|
||||
if (!$this->isPathSymbol($partial) && realpath($partial) === false)
|
||||
if (!File::isPathSymbol($partial) && realpath($partial) === false)
|
||||
$partial = '_' . strtolower($partial) . '.htm';
|
||||
|
||||
$partialPath = $this->getViewPath($partial);
|
||||
|
|
@ -153,7 +151,7 @@ trait ViewMaker
|
|||
if (!$viewPath)
|
||||
$viewPath = $this->viewPath;
|
||||
|
||||
$fileName = $this->makePath($fileName, $fileName);
|
||||
$fileName = File::symbolizePath($fileName, $fileName);
|
||||
|
||||
if (substr($fileName, 0, 1) == '/' || realpath($fileName) !== false)
|
||||
return $fileName;
|
||||
|
|
|
|||
Loading…
Reference in New Issue