You are here

class Browser in Dashboards with Layout Builder 2.0.x

Same name and namespace in other branches
  1. 8 modules/dashboards_matomo/src/Plugin/Dashboard/Browser.php \Drupal\dashboards_matomo\Plugin\Dashboard\Browser

Show account info.

Plugin annotation


@Dashboard(
  id = "matomo_browser",
  label = @Translation("Browser."),
  category = @Translation("Matomo"),
)

Hierarchy

Expanded class hierarchy of Browser

File

modules/dashboards_matomo/src/Plugin/Dashboard/Browser.php, line 16

Namespace

Drupal\dashboards_matomo\Plugin\Dashboard
View source
class Browser extends MatomoBase {

  /**
   * Lazy build callback.
   *
   * @param \Drupal\dashboards\Plugin\DashboardBase $plugin
   *   Matomo base plugin.
   * @param array $configuration
   *   Configuration.
   */
  public static function lazyBuild(DashboardBase $plugin, array $configuration) : array {
    try {
      $response = $plugin
        ->query('DevicesDetection.getBrowsers', [
        'filter_limit' => 20,
        'period' => $configuration['period'],
        'date' => $plugin
          ->getDateTranslated($configuration['date']),
        'flat' => 1,
      ]);
      if (empty($response)) {
        $plugin
          ->setEmpty(TRUE);
        return $plugin
          ->renderChart($configuration);
      }
      $plugin
        ->buildDateRows($response, $plugin
        ->t('Date'), [
        'nb_visits',
      ]);
      $plugin
        ->setChartType($configuration['chart_type']);
      return $plugin
        ->renderChart($configuration);
    } catch (\Exception $ex) {
      return [
        '#markup' => $plugin
          ->t('Error occured: @error', [
          '@error' => $ex
            ->getMessage(),
        ]),
        '#cache' => [
          'max-age' => 0,
        ],
      ];
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Browser::lazyBuild public static function Lazy build callback. Overrides DashboardLazyBuildInterface::lazyBuild
ChartTrait::$empty protected property Empty flag.
ChartTrait::$labels protected property Labels.
ChartTrait::$rows protected property Rows.
ChartTrait::$type protected property Chart type.
ChartTrait::addLabel public function Add a label.
ChartTrait::addRow public function Add a row.
ChartTrait::getAllowedStyles public function Get allowed styles.
ChartTrait::renderChart public function Set all rows.
ChartTrait::setChartType public function Add a label.
ChartTrait::setEmpty public function Set this chart is empty.
ChartTrait::setLabels public function Set all labels.
ChartTrait::setRows public function Set all rows.
DashboardBase::$cache protected property Cache backend.
DashboardBase::getCache protected function Get cache for cid.
DashboardBase::massageFormValues public function Validate settings form.
DashboardBase::setCache protected function Set a new cache entry. Cache is prefixed by pluginid.
DashboardBase::validateForm public function Validate settings form. 1
DashboardLazyBuildBase::buildRenderArray public function Build render array. Overrides DashboardBase::buildRenderArray
DashboardLazyBuildBase::lazyBuildPreRender public static function Helper for lazy build render. Overrides DashboardLazyBuildInterface::lazyBuildPreRender
DashboardLazyBuildBase::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
MatomoBase::$matomoQuery protected property Entity query.
MatomoBase::buildDateRows protected function Helper function for build rows from matomo.
MatomoBase::buildSettingsForm public function Build render array. Overrides DashboardBase::buildSettingsForm 2
MatomoBase::create public static function Creates an instance of the plugin. Overrides DashboardBase::create
MatomoBase::formatDateRange public static function Helper function for short date ranges.
MatomoBase::getDateTranslated protected function Translate date matomo string.
MatomoBase::getQuery public function Get matomo query.
MatomoBase::query protected function Helper function for query matomo.
MatomoBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides DashboardBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.