Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jirisvoboda committed Dec 22, 2015
1 parent 4e35fcb commit e855609
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 23 deletions.
7 changes: 6 additions & 1 deletion Metronic.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ public function parseAssetsParams(&$string)
*/
public static function getComponent()
{
return Yii::$app->{static::$componentName};
if (isset(Yii::$app->{static::$componentName}))
{
return Yii::$app->{static::$componentName};
}

return false;
}

/**
Expand Down
15 changes: 8 additions & 7 deletions bundles/StyleBasedAsset.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* @link http://www.digitaldeals.cz/
* @copyright Copyright (c) 2014 Digital Deals s.r.o.
Expand Down Expand Up @@ -37,9 +36,9 @@ class StyleBasedAsset extends AssetBundle {
* @var array js assets
*/
public $js = [
//'scripts/layout.js',
//'scripts/app.js',
//'scripts/init.js',
//'scripts/layout.js',
//'scripts/app.js',
//'scripts/init.js',
];

/**
Expand Down Expand Up @@ -69,7 +68,9 @@ public function init()
*/
private function _handleStyleBased()
{
$this->css = ArrayHelper::merge($this->styleBasedCss[Metronic::getComponent()->style], $this->css);
if (Metronic::getComponent())
{
$this->css = ArrayHelper::merge($this->styleBasedCss[Metronic::getComponent()->style], $this->css);
}
}

}
}
11 changes: 6 additions & 5 deletions bundles/ThemeAsset.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* @link http://www.digitaldeals.cz/
* @copyright Copyright (c) 2014 Digital Deals s.r.o.
Expand Down Expand Up @@ -61,15 +60,17 @@ public function init()
*/
private function _handleSourcePath()
{
Metronic::getComponent()->parseAssetsParams($this->sourcePath);
if (Metronic::getComponent())
{
Metronic::getComponent()->parseAssetsParams($this->sourcePath);
}
}

/**
* Parses dynamic css
*/
private function _handleDynamicCss()
{
array_walk($this->css, array(Metronic::getComponent(), 'parseAssetsParams'));
array_walk($this->css, [Metronic::getComponent(), 'parseAssetsParams']);
}

}
}
12 changes: 6 additions & 6 deletions helpers/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ private static function _bodyOptions($options)
{
Html::addCssClass($options, 'page-sidebar-closed-hide-logo');

if (Metronic::LAYOUT_BOXED === Metronic::getComponent()->layoutOption)
if (Metronic::getComponent() && Metronic::LAYOUT_BOXED === Metronic::getComponent()->layoutOption)
{
Html::addCssClass($options, 'page-boxed');
}

if (Metronic::HEADER_FIXED === Metronic::getComponent()->headerOption)
if (Metronic::getComponent() && Metronic::HEADER_FIXED === Metronic::getComponent()->headerOption)
{
Html::addCssClass($options, 'page-header-fixed');
}

if (Metronic::SIDEBAR_POSITION_RIGHT === Metronic::getComponent()->sidebarPosition)
if (Metronic::getComponent() && Metronic::SIDEBAR_POSITION_RIGHT === Metronic::getComponent()->sidebarPosition)
{
Html::addCssClass($options, 'page-sidebar-reversed');
}

if (Metronic::SIDEBAR_FIXED === Metronic::getComponent()->sidebarOption)
if (Metronic::getComponent() && Metronic::SIDEBAR_FIXED === Metronic::getComponent()->sidebarOption)
{
Html::addCssClass($options, 'page-sidebar-fixed');
}

if (Metronic::FOOTER_FIXED === Metronic::getComponent()->footerOption)
if (Metronic::getComponent() && Metronic::FOOTER_FIXED === Metronic::getComponent()->footerOption)
{
Html::addCssClass($options, 'page-footer-fixed');
}
Expand All @@ -74,7 +74,7 @@ private static function _headerOptions($options)
{
Html::addCssClass($options, 'page-header navbar');

if (Metronic::HEADER_FIXED === Metronic::getComponent()->headerOption)
if (Metronic::getComponent() && Metronic::HEADER_FIXED === Metronic::getComponent()->headerOption)
{
Html::addCssClass($options, 'navbar-fixed-top');
}
Expand Down
4 changes: 2 additions & 2 deletions layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
NavBar::end();
?>
<?=
(Metronic::getComponent()->layoutOption == Metronic::LAYOUT_BOXED) ?
(Metronic::getComponent() && Metronic::getComponent()->layoutOption == Metronic::LAYOUT_BOXED) ?
Html::beginTag('div', ['class' => 'container']) : '';
?>
<!-- BEGIN CONTAINER -->
Expand Down Expand Up @@ -333,7 +333,7 @@
</span>
</div>
</div>
<?= (Metronic::getComponent()->layoutOption == Metronic::LAYOUT_BOXED) ? Html::endTag('div') : ''; ?>
<?= (Metronic::getComponent() && Metronic::getComponent()->layoutOption == Metronic::LAYOUT_BOXED) ? Html::endTag('div') : ''; ?>
<?php $this->endBody() ?>
</body>
<!-- END BODY -->
Expand Down
2 changes: 1 addition & 1 deletion widgets/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private function _initOptions()
{
Html::addCssClass($this->options, 'page-sidebar-menu');

if (Metronic::SIDEBAR_MENU_HOVER === Metronic::getComponent()->sidebarMenu)
if (Metronic::getComponent() && Metronic::SIDEBAR_MENU_HOVER === Metronic::getComponent()->sidebarMenu)
{
Html::addCssClass($this->options, 'page-sidebar-menu-hover-submenu');
}
Expand Down
2 changes: 1 addition & 1 deletion widgets/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function renderItem($item)

Html::addCssClass($options, 'dropdown-'.$dropdownType);

if (Metronic::HEADER_DROPDOWN_DARK === Metronic::getComponent()->headerDropdown)
if (Metronic::getComponent() && Metronic::HEADER_DROPDOWN_DARK === Metronic::getComponent()->headerDropdown)
{
Html::addCssClass($options, 'dropdown-dark');
}
Expand Down

0 comments on commit e855609

Please sign in to comment.