You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
<?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;
|
|
}
|
|
}
|