Piwik\Plugins\Marketplace\Consumer::getConsumer PHP Method

getConsumer() public method

public getConsumer ( )
    public function getConsumer()
    {
        if ($this->consumer === false) {
            $consumer = $this->marketplaceClient->getConsumer();
            if (!empty($consumer)) {
                $this->consumer = $consumer;
            } else {
                $this->consumer = array();
            }
        }
        return $this->consumer;
    }

Usage Example

Example #1
0
 public function subscriptionOverview()
 {
     Piwik::checkUserHasSuperUserAccess();
     // we want to make sure to fetch the latest results, eg in case user has purchased a subscription meanwhile
     // this is also like a self-repair to clear the caches :)
     $this->marketplaceApi->clearAllCacheEntries();
     $this->consumer->clearCache();
     $hasLicenseKey = $this->licenseKey->has();
     $consumer = $this->consumer->getConsumer();
     $subscriptions = array();
     $loginUrl = '';
     if (!empty($consumer['loginUrl'])) {
         $loginUrl = $consumer['loginUrl'];
     }
     if (!empty($consumer['licenses'])) {
         foreach ($consumer['licenses'] as $subscription) {
             $subscription['start'] = $this->getPrettyLongDate($subscription['startDate']);
             $subscription['end'] = $this->getPrettyLongDate($subscription['endDate']);
             $subscription['nextPayment'] = $this->getPrettyLongDate($subscription['nextPaymentDate']);
             $subscriptions[] = $subscription;
         }
     }
     return $this->renderTemplate('@Marketplace/subscription-overview', array('hasLicenseKey' => $hasLicenseKey, 'subscriptions' => $subscriptions, 'loginUrl' => $loginUrl, 'numUsers' => $this->environment->getNumUsers()));
 }