Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominus77 committed May 2, 2018
1 parent ac8e8d2 commit 9b1a267
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions SocialLikes.php
Expand Up @@ -83,26 +83,34 @@ public function init()
*/
public function run()
{
$this->renderWidget($this->items);
if (!empty($this->items)) {
echo Html::beginTag('div', $this->containerOptions) . PHP_EOL;
$this->renderItems($this->items);
echo Html::endTag('div') . PHP_EOL;
}
}

/**
* Render widget
* Render items
* @param array $items
*/
public function renderWidget($items = [])
public function renderItems($items = [])
{
if (!empty($items)) {
echo Html::beginTag('div', $this->containerOptions) . PHP_EOL;
foreach ($items as $key => $options) {
$title = (isset($options['title'])) ? $options['title'] : $this->title;
if (isset($options['serviceOptions']))
echo Html::tag('div', $title ? $key : '', $options['serviceOptions']) . PHP_EOL;
}
echo Html::endTag('div') . PHP_EOL;
foreach ($items as $key => $options) {
if (isset($options['serviceOptions']))
echo Html::tag('div', $this->getContentTitle($options) ? $key : '', $options['serviceOptions']) . PHP_EOL;
}
}

/**
* @param array $options
* @return bool|mixed
*/
protected function getContentTitle($options = [])
{
return (isset($options['title'])) ? $options['title'] : $this->title;
}

/**
* Register client assets
*/
Expand Down

0 comments on commit 9b1a267

Please sign in to comment.