Skip to content

Commit

Permalink
Fix the Using $this when not in object context issue
Browse files Browse the repository at this point in the history
  • Loading branch information
myconcretelab committed Sep 4, 2015
1 parent 328e716 commit 683b87a
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,39 @@ public function on_start() {
$this->registerRoutes();
$this->registerAssets();
$this->registerEvents();

}

function registerEvents () {
Events::addListener(
'on_before_render',
function() {
$session = \Core::make('session');

$c = Page::getCurrentPage();
// Register options into the session
$options = ThemeSupermintOptions::get_options_from_active_preset_ID();
$session->set('supermint.options',$options);

// Register colors from active or default preset in the session
if (is_object( Page::getCurrentPage())) :
if (is_object($c)) :
$colors = PresetColors::GetColorsFromPage();
$session->set('supermint.colors',$colors);
endif;

$this->registerMenuItem();

if (!is_object($c)) return;
// Now we build the button
$pt = $c->getCollectionThemeObject();
if ($pt->getThemeHandle() != $this->themeHandle) return;
$status = t('Supermint Options');
$icon = 'toggle-on';
$ihm = Core::make('helper/concrete/ui/menu');

$ihm->addPageHeaderMenuItem('theme_supermint', 'theme_supermint',
array(
'label' => $status,
'icon' => $icon,
'position' => 'right',
'href' => URL::to('/dashboard/supermint_options/theme_options')
));
});
}

Expand Down Expand Up @@ -224,26 +236,6 @@ public function registerRoutes() {
);
}

public function registerMenuItem () {
// First we check if Supermint is the activated theme
$pt = Page::getCurrentPage();
if (!is_object($c)) return;
$pt = $pt->getCollectionThemeObject();
if ($pt->getThemeHandle() != $this->themeHandle) return;
// Now we build the button
$status = t('Supermint Options');
$icon = 'toggle-on';
$ihm = Core::make('helper/concrete/ui/menu');

$ihm->addPageHeaderMenuItem('theme_supermint', 'theme_supermint',
array(
'label' => $status,
'icon' => $icon,
'position' => 'right',
'href' => URL::to('/dashboard/supermint_options/theme_options')
));
}

public function swapContent($options) {

if ($this->validateClearSiteContents($options)) {
Expand Down

0 comments on commit 683b87a

Please sign in to comment.