| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/StyleEdit3/classes/Repositories/ |
Upload File : |
<?php
/* --------------------------------------------------------------
ConfigDeleter.inc.php 2019-06-07
Gambio GmbH
http://www.gambio.de
Copyright (c) 2019 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------*/
namespace StyleEdit\Repositories;
use \StyleEdit\Entities\StoredConfig;
use \StyleEdit\ConfigSettings;
/**
* Class ConfigDeleter
*
* @package StyleEdit\Repositories
*/
class ConfigDeleter
{
/** @var ConfigSettings $settings */
private $settings;
/**
* ConfigDeleter constructor.
*
* @param \StyleEdit\ConfigSettings $settings
*/
public function __construct(ConfigSettings $settings)
{
$this->settings = $settings;
}
/**
* Deletes a stored style edit config file.
*
* @param \StyleEdit\Entities\StoredConfig $styleConfig
* @param bool $p_fromOriginalTheme Delete files from original theme directory.
*
* @throws \RuntimeException if the given style is active
* @throws \RuntimeException if the file could not be deleted
*
* @return bool
*/
public function delete(StoredConfig $styleConfig, $p_fromOriginalTheme = false)
{
if($styleConfig->isActive())
{
throw new \RuntimeException('You can not delete the active Style. You must activate another Style before deleting this one.');
}
$filepath = $this->settings->getStylesDirectory($p_fromOriginalTheme) . $styleConfig->getFilename();
if(!file_exists($filepath))
{
return true;
}
try
{
return unlink($filepath);
}
catch(\Exception $e)
{
throw new \RuntimeException('The file "' . $filepath . '" could not be deleted"');
}
}
}