Skip to content

Commit

Permalink
Refactor profile summaries into additional classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Aug 27, 2017
1 parent 09a804d commit 8ae5ad2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
52 changes: 52 additions & 0 deletions ProfileSummary/BandwidthSummary.php
@@ -0,0 +1,52 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

namespace Piwik\Plugins\Bandwidth\ProfileSummary;

use Piwik\Piwik;
use Piwik\Plugins\Live\ProfileSummary\ProfileSummaryAbstract;
use Piwik\View;

/**
* Class BandwidthSummary
*
* @api
*/
class BandwidthSummary extends ProfileSummaryAbstract
{
/**
* @inheritdoc
*/
public function getName()
{
return Piwik::translate('Bandwidth_Bandwidth');
}

/**
* @inheritdoc
*/
public function render()
{
if (!isset($this->profile['avgBandwidth'])) {
return '';
}

$view = new View('@Bandwidth/_profileSummary.twig');
$view->visitorData = $this->profile;
return $view->render();
}

/**
* @inheritdoc
*/
public function getOrder()
{
return 70;
}
}
11 changes: 0 additions & 11 deletions VisitorDetails.php
Expand Up @@ -70,15 +70,4 @@ public function finalizeProfile($visits, &$profile)
$profile['avgBandwidth'] = $formatter->getPrettySizeFromBytes(round($this->sumBandwidth / $this->actionsWithBandwidth));
}
}

public function renderProfileSummary($profile)
{
if (!isset($profile['avgBandwidth'])) {
return array();
}

$view = new View('@Bandwidth/_profileSummary.twig');
$view->visitorData = $profile;
return array(array(70, $view->render()));
}
}

0 comments on commit 8ae5ad2

Please sign in to comment.