Newer
Older
* @file
* Contains \Drupal\rsvp_module\Plugin\Block\RSVPBlock
*/
namespace Drupal\rsvp_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Provides a 'RSVP' List Block
*
* @Block(
* id = "rsvp_block",
* admin_label = @Translation("RSVP Block"),
* category = @Translation("Blocks")
* )
*/
class RSVPBlock extends BlockBase {
return \Drupal::formBuilder()->getForm('Drupal\rsvp_module\Form\RSVPForm');
}
/**
* {@inheritdoc}
*/
/** @var \Drupal\node\Entity\Node $node */
$node = \Drupal::routeMatch()->getParameter('node');
$nid = $node->nid->value;
/** @var \Drupal\rsvp_module\EnablerService $enabler */
$enabler = \Drupal::service('rsvp_module.enabler');
if(is_numeric($nid)) {
if($enabler->isEnabled($node)) {
return AccessResult::allowedIfHasPermission($account, 'view rsvp_module');
}
}
return AccessResult::forbidden();