Skip to content
Snippets Groups Projects
Commit e109f9e8 authored by Norman Kämper-Leymann's avatar Norman Kämper-Leymann Committed by João Ventura
Browse files

Issue #3259797 by leymannx, jcnventura: TypeError: Argument 1 passed to...

Issue #3259797 by leymannx, jcnventura: TypeError: Argument 1 passed to Drupal\Core\Render\Element::isEmpty() must be of the type array, bool given
parent 01be4d7b
No related branches found
No related tags found
1 merge request!6#3259797 Add blockAccess to control block visibility if Klaro not enabled
......@@ -2,9 +2,11 @@
namespace Drupal\simple_klaro\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -58,14 +60,21 @@ class PreferencesDialog extends BlockBase implements ContainerFactoryPluginInter
*/
public function build() {
$config = $this->configFactory->get('simple_klaro.settings');
$klaro_enabled = $config->get('enabled');
if (!$klaro_enabled) {
return FALSE;
}
return [
'#markup' => '<a href="#" id="klaro-preferences">' . $config->get('preferences') . '</a>',
];
}
/**
* {@inheritdoc}
*/
protected function blockAccess(AccountInterface $account) {
$config = $this->configFactory->get('simple_klaro.settings');
$klaro_enabled = $config->get('enabled');
if (!$klaro_enabled) {
return AccessResult::forbidden();
}
return parent::blockAccess($account);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment