79 lines
1.7 KiB
Plaintext
79 lines
1.7 KiB
Plaintext
/**
|
|
* Compiler Utilities Counter
|
|
*
|
|
* @var Counter
|
|
* @since 3.2.0
|
|
*/
|
|
protected Counter $counter;
|
|
|
|
/**
|
|
* Compiler Utilities Paths
|
|
*
|
|
* @var Paths
|
|
* @since 3.2.0
|
|
*/
|
|
protected Paths $paths;
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param Counter|null $counter The compiler counter object.
|
|
* @param Paths|null $paths The compiler paths object.
|
|
*
|
|
* @since 3.2.0
|
|
*/
|
|
public function __construct(?Counter $counter = null, ?Paths $paths = null)
|
|
{
|
|
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
|
|
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
|
|
}
|
|
|
|
/**
|
|
* set HTML blank file to a path
|
|
*
|
|
* @param string $path The path to where to set the blank html file
|
|
* @param string $root The root path
|
|
*
|
|
* @return void
|
|
*/
|
|
public function html(string $path = '', string $root = 'component')
|
|
{
|
|
if ('component' === $root)
|
|
{
|
|
$root = $this->paths->component_path . '/';
|
|
}
|
|
|
|
// use path if exist
|
|
if (strlen($path) > 0)
|
|
{
|
|
JoomlaFile::copy(
|
|
$this->paths->template_path . '/index.html',
|
|
$root . $path . '/index.html'
|
|
);
|
|
}
|
|
else
|
|
{
|
|
JoomlaFile::copy(
|
|
$this->paths->template_path . '/index.html',
|
|
$root . '/index.html'
|
|
);
|
|
}
|
|
|
|
// count the file created
|
|
$this->counter->file++;
|
|
}
|
|
|
|
/**
|
|
* Create a file on the server if it does not exist, or Overwrite existing files
|
|
*
|
|
* @param string $path The path and file name where to safe the data
|
|
* @param string $data The data to safe
|
|
*
|
|
* @return bool true On success
|
|
* @since 3.2.0
|
|
*/
|
|
public function write(string $path, string $data): bool
|
|
{
|
|
return FileHelper::write($path, $data);
|
|
}
|