class LeafletAjaxPopupController in Leaflet 2.0.x
Same name and namespace in other branches
- 8 modules/leaflet_views/src/Controller/LeafletAjaxPopupController.php \Drupal\leaflet_views\Controller\LeafletAjaxPopupController
- 2.1.x modules/leaflet_views/src/Controller/LeafletAjaxPopupController.php \Drupal\leaflet_views\Controller\LeafletAjaxPopupController
Default controller for the leaflet_views_ajax_popup module.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\leaflet_views\Controller\LeafletAjaxPopupController
Expanded class hierarchy of LeafletAjaxPopupController
1 file declares its use of LeafletAjaxPopupController
- LeafletMap.php in modules/
leaflet_views/ src/ Plugin/ views/ style/ LeafletMap.php
File
- modules/
leaflet_views/ src/ Controller/ LeafletAjaxPopupController.php, line 17
Namespace
Drupal\leaflet_views\ControllerView source
class LeafletAjaxPopupController extends ControllerBase {
/**
* The Entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
/**
* The Renderer service property.
*
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
*/
protected $renderer;
/**
* Constructs a new LeafletAjaxPopupController object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
*/
public function __construct(EntityTypeManagerInterface $entity_manager, RendererInterface $renderer) {
$this->entityManager = $entity_manager;
$this->renderer = $renderer;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('renderer'));
}
/**
* User LeafletAjaxPopup page access checker.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to check the permission for view.
*
* @return \Drupal\Core\Access\AccessResult
* The Access check results.
*/
public function accessCheck(EntityInterface $entity) {
return AccessResult::allowedIf($entity
->access('view'));
}
/**
* Leaflet Ajax Popup build callback..
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity whose build to return.
* @param string $view_mode
* The view mode identifier.
* @param string $langcode
* The langcode to render the entity by.
*
* @return \Symfony\Component\HttpFoundation\Response
* The Response to return.
*/
public function popupBuild(EntityInterface $entity, $view_mode, $langcode = NULL) {
$entity_view_builder = $this->entityManager
->getViewBuilder($entity
->getEntityTypeId());
$build = $entity_view_builder
->view($entity, $view_mode, $langcode);
$response = new AjaxResponse();
$response
->addCommand(new ReplaceCommand($this
->getPopupIdentifierSelector($entity
->getEntityTypeId(), $entity
->id(), $view_mode, $langcode), $build));
return $response;
}
/**
* Get popup identifier.
*
* @param string $entityType
* The entity type.
* @param int $entityId
* The entity id.
* @param string $viewMode
* The view mode.
* @param string $langcode
* The langcode.
*
* @return string
* The identifier.
*/
public static function getPopupIdentifier($entityType, $entityId, $viewMode, $langcode) {
return "{$entityType}-{$entityId}-{$viewMode}-{$langcode}";
}
/**
* Get popup identifier attribute.
*
* @param string $entityType
* The entity type.
* @param int $entityId
* The entity id.
* @param string $viewMode
* The view mode.
* @param string $langcode
* The langcode.
*
* @return string
* The identifier selector.
*/
public static function getPopupIdentifierAttribute($entityType, $entityId, $viewMode, $langcode) {
return sprintf('data-leaflet-popup-ajax-entity="%s"', self::getPopupIdentifier($entityType, $entityId, $viewMode, $langcode));
}
/**
* Get popup identifier selector.
*
* @param string $entityType
* The entity type.
* @param int $entityId
* The entity id.
* @param string $viewMode
* The view mode.
* @param string $langcode
* The langcode.
*
* @return string
* The identifier selector.
*/
public static function getPopupIdentifierSelector($entityType, $entityId, $viewMode, $langcode) {
return sprintf('[%s]', self::getPopupIdentifierAttribute($entityType, $entityId, $viewMode, $langcode));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The current user service. | 1 |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The form builder. | 2 |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function | Returns a redirect response object for the specified route. | |
ControllerBase:: |
protected | function | Returns the state storage service. | |
LeafletAjaxPopupController:: |
protected | property | The Entity type manager service. | |
LeafletAjaxPopupController:: |
protected | property | The Renderer service property. | |
LeafletAjaxPopupController:: |
public | function | User LeafletAjaxPopup page access checker. | |
LeafletAjaxPopupController:: |
public static | function |
Instantiates a new instance of this class. Overrides ControllerBase:: |
|
LeafletAjaxPopupController:: |
public static | function | Get popup identifier. | |
LeafletAjaxPopupController:: |
public static | function | Get popup identifier attribute. | |
LeafletAjaxPopupController:: |
public static | function | Get popup identifier selector. | |
LeafletAjaxPopupController:: |
public | function | Leaflet Ajax Popup build callback.. | |
LeafletAjaxPopupController:: |
public | function | Constructs a new LeafletAjaxPopupController object. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |