Popup.php in Entity Legal 3.0.x
File
src/Plugin/EntityLegal/Popup.php
View source
<?php
namespace Drupal\entity_legal\Plugin\EntityLegal;
use Drupal\entity_legal\EntityLegalPluginBase;
class Popup extends EntityLegalPluginBase {
public function execute(array &$context = []) {
if (!empty($this->documents)) {
$renderer = \Drupal::service('renderer');
$view_builder = \Drupal::entityTypeManager()
->getViewBuilder(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME);
foreach ($this->documents as $document) {
$context['attachments']['#cache']['tags'][] = "entity_legal_document:{$document->id()}";
$document_markup = $view_builder
->view($document
->getPublishedVersion());
$context['attachments']['#attached']['library'][] = 'entity_legal/popup';
$context['attachments']['#attached']['drupalSettings']['entityLegalPopup'] = [
[
'popupTitle' => $document
->getPublishedVersion()
->label(),
'popupContent' => $renderer
->renderPlain($document_markup),
],
];
}
}
}
}
Classes
Name |
Description |
Popup |
Method class for alerting existing users via a jQuery UI popup window. |