Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/Improvement for cases when a theme was selected but than removed #855

Merged
merged 1 commit into from
Jan 2, 2021
Merged

Fix/Improvement for cases when a theme was selected but than removed #855

merged 1 commit into from
Jan 2, 2021

Conversation

MekDrop
Copy link
Member

@MekDrop MekDrop commented Dec 30, 2020

At current moment if theme was selected in site preferences and than theme folder was removed, user will not be able to access website and select different theme. So for these rare times, another theme will be selected automatically and user could access site.

/**
* @var Config $configHandler
*/
$configHandler = icms::getInstance()->get('config');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to undeclared method \icms::get

@@ -73,7 +77,7 @@ public function __construct() {

parent::__construct();

foreach (\icms::getInstance()->get('smarty.resource') as $plugin) {
foreach (icms::getInstance()->get('smarty.resource') as $plugin) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to undeclared method \icms::get

@@ -84,7 +88,7 @@ public function __construct() {
'modifier' => 'register_modifier',
'compiler' => 'register_compiler_function',
] as $type => $function) {
foreach (\icms::getInstance()->get('smarty.' . $type) as $plugin) {
foreach (icms::getInstance()->get('smarty.' . $type) as $plugin) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call to undeclared method \icms::get

public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
try {
return parent::fetch($template, $cache_id, $compile_id, $parent);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to undeclared class \SmartyBC

{
try {
return parent::fetch($template, $cache_id, $compile_id, $parent);
} catch (SmartyException $exception) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching undeclared class \SmartyException

core/View/Template.php Show resolved Hide resolved
core/View/Template.php Show resolved Hide resolved
} catch (SmartyException $exception) {
if (strpos($exception->getMessage(), 'Unable to load template') === 0) {
$this->handleDeletedTemplateSet($exception);
} else {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method fetch uses an else expression. Else is never necessary and you can simplify the code to work without else.

*/
private function handleDeletedTemplateSet(SmartyException $exception): void {
$isAdmin = $this->getTemplateVars('icms_isadmin');
$themesList = $isAdmin ? ThemeFactory::getAdminThemesList() : ThemeFactory::getThemesList();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using static access to class '\ImpressCMS\Core\View\Theme\ThemeFactory' in method 'handleDeletedTemplateSet'.

*/
private function handleDeletedTemplateSet(SmartyException $exception): void {
$isAdmin = $this->getTemplateVars('icms_isadmin');
$themesList = $isAdmin ? ThemeFactory::getAdminThemesList() : ThemeFactory::getThemesList();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using static access to class '\ImpressCMS\Core\View\Theme\ThemeFactory' in method 'handleDeletedTemplateSet'.

@fiammybe fiammybe merged commit ef341d3 into ImpressCMS:master Jan 2, 2021
@MekDrop MekDrop deleted the improvement+fix/autoselect-another-theme-if-deleted branch January 2, 2021 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants