Skip to content
Snippets Groups Projects
Commit c5415163 authored by Erik Seifert's avatar Erik Seifert
Browse files

Fix: Coding conventions

parent e3ae1dee
No related branches found
No related tags found
No related merge requests found
......@@ -102,9 +102,8 @@ abstract class MatomoBase extends DashboardLazyBuildBase {
* Data from matomo.
* @param string $label
* Label for display.
*
* @param array $column
* columns to show.
* Columns to show.
*/
protected function buildDateRows($response, $label, array $column) {
$labels = [$label];
......@@ -113,7 +112,7 @@ abstract class MatomoBase extends DashboardLazyBuildBase {
$labels[$r['label']] = $r['label'];
unset($row[$key]);
$row[$r['label']] = $r;
uksort($row, function($a, $b) {
uksort($row, function ($a, $b) {
return strcmp($a, $b);
});
}
......@@ -156,7 +155,7 @@ abstract class MatomoBase extends DashboardLazyBuildBase {
* @return array
* Response array
*/
protected function query($action, $params): array {
protected function query($action, array $params): array {
$query = $this->matomoQuery->getQuery($action);
$query->setParameters($params);
......
......@@ -93,7 +93,7 @@ class Submissions extends DashboardBase {
$configuration['period'],
$configuration['date'],
]));
$dateLabel = t('Date');
$dateLabel = $this->t('Date');
$cache = $this->getCache($cid);
$cache = FALSE;
......@@ -181,7 +181,7 @@ class Submissions extends DashboardBase {
array_unshift($rows[$key], $key);
}
usort($rows, function($a, $b) {
usort($rows, function ($a, $b) {
return strcmp($a[0], $b[0]);
});
$labels = array_merge([$dateLabel], $labels);
......
......@@ -11,6 +11,10 @@ use Drupal\Core\Entity\EntityAccessControlHandler;
* DashboardAccessControlHandler class.
*/
class DashboardAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'delete' && $entity
->isNew()) {
......@@ -25,15 +29,14 @@ class DashboardAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::allowedIfHasPermission($account, $this->entityType->getAdminPermission())
->orIf(AccessResult::allowedIfHasPermission($account, 'can override ' . $entity->id() . ' dashboard'));
}
if ($admin_permission = $this->entityType
if ($this->entityType
->getAdminPermission()) {
return AccessResult::allowedIfHasPermission($account, $this->entityType
->getAdminPermission());
}
else {
// No opinion.
return AccessResult::neutral();
}
}
}
......@@ -119,7 +119,7 @@ class DashboardViewBuilder extends EntityViewBuilder {
'dashboards-container',
],
],
$build,
'content' => $build,
];
}
......
......@@ -3,10 +3,15 @@
namespace Drupal\dashboards\Plugin;
use Drupal\Component\Serialization\Json;
use Drupal\dashboards\Plugin\DashboardLazyBuildInterface;
/**
* Abstract class helper for lazy builds.
*/
abstract class DashboardLazyBuildBase extends DashboardBase implements DashboardLazyBuildInterface {
/**
* {@inheritdoc}
*/
public static function lazyBuildPreRender(string $pluginId, string $configuration): array {
$configuration = Json::decode($configuration);
$plugin = \Drupal::service('plugin.manager.dashboard')->createInstance($pluginId, $configuration);
......
......@@ -2,8 +2,6 @@
namespace Drupal\dashboards\Plugin;
use Drupal\dashboards\Plugin\DashboardBase;
/**
* Interface for lazy builds.
*/
......@@ -28,11 +26,11 @@ interface DashboardLazyBuildInterface {
* @param string $pluginId
* Dashboard plugin id.
* @param string $configuration
* Serizalized configuration
* Serizalized configuration.
*
* @return array
* Renderable array
*/
public static function lazyBuildPreRender(string $pluginId,string $configuration): array;
public static function lazyBuildPreRender(string $pluginId, string $configuration): array;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment