60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
|
<?php namespace Wpstudio\Assetsmanifest\Components;
|
||
|
|
||
|
use Cms\Classes\ComponentBase;
|
||
|
use Wpstudio\AssetsManifest\Classes\ManifestReader;
|
||
|
|
||
|
class Manifest extends ComponentBase
|
||
|
{
|
||
|
const LANG_PREFIX = 'wpstudio.assetsmanifest::lang.components.manifest.';
|
||
|
|
||
|
private ?ManifestReader $manifestReader;
|
||
|
|
||
|
public function componentDetails(): array
|
||
|
{
|
||
|
return [
|
||
|
'name' => self::LANG_PREFIX . 'name',
|
||
|
'description' => self::LANG_PREFIX . 'description',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function defineProperties(): array
|
||
|
{
|
||
|
return [
|
||
|
'path' => [
|
||
|
'title' => self::LANG_PREFIX . 'properties.path.title',
|
||
|
'description' => self::LANG_PREFIX . 'properties.path.description',
|
||
|
'validationPattern' => '^[^/].*/manifest.json',
|
||
|
'validationMessage' => self::LANG_PREFIX . 'properties.path.validationMessage',
|
||
|
'placeholder' => 'assets/build/manifest.json',
|
||
|
'showExternalParam' => false,
|
||
|
'required' => true,
|
||
|
]
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return void
|
||
|
* @throws \Wpstudio\AssetsManifest\Classes\AssetsManifestException
|
||
|
*/
|
||
|
public function init(): void
|
||
|
{
|
||
|
app()->instance(Manifest::class, $this);
|
||
|
|
||
|
$this->prepareVars();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return void
|
||
|
* @throws \Wpstudio\AssetsManifest\Classes\AssetsManifestException
|
||
|
*/
|
||
|
private function prepareVars(): void
|
||
|
{
|
||
|
$this->manifestReader = new ManifestReader(base_path($this->property('path')));
|
||
|
}
|
||
|
|
||
|
public function getManifestReader(): ManifestReader
|
||
|
{
|
||
|
return $this->manifestReader;
|
||
|
}
|
||
|
}
|