You are here

class LazyRenderer in Open Social 10.1.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_post/modules/social_post_album/src/LazyRenderer.php \Drupal\social_post_album\LazyRenderer
  2. 10.0.x modules/social_features/social_post/modules/social_post_album/src/LazyRenderer.php \Drupal\social_post_album\LazyRenderer
  3. 10.2.x modules/social_features/social_post/modules/social_post_album/src/LazyRenderer.php \Drupal\social_post_album\LazyRenderer

Provides lazy builder for content inside modal window.

@package Drupal\social_post_album

Hierarchy

Expanded class hierarchy of LazyRenderer

1 string reference to 'LazyRenderer'
social_post_album.services.yml in modules/social_features/social_post/modules/social_post_album/social_post_album.services.yml
modules/social_features/social_post/modules/social_post_album/social_post_album.services.yml
1 service uses LazyRenderer
social_post_album.lazy_renderer in modules/social_features/social_post/modules/social_post_album/social_post_album.services.yml
Drupal\social_post_album\LazyRenderer

File

modules/social_features/social_post/modules/social_post_album/src/LazyRenderer.php, line 13

Namespace

Drupal\social_post_album
View source
class LazyRenderer implements TrustedCallbackInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * LazyRenderer constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * Get post with specific view mode via lazy builder.
   *
   * @param string $entity_type
   *   The entity type ID.
   * @param string|int $post_id
   *   The post ID.
   * @param string $view_mode
   *   The view mode.
   *
   * @return array
   *   The render array of post.
   */
  public function getPost($entity_type, $post_id, $view_mode) {
    $post = $this->entityTypeManager
      ->getStorage($entity_type)
      ->load($post_id);
    return $this->entityTypeManager
      ->getViewBuilder($entity_type)
      ->view($post, $view_mode);
  }

  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return [
      'getPost',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LazyRenderer::$entityTypeManager protected property The entity type manager.
LazyRenderer::getPost public function Get post with specific view mode via lazy builder.
LazyRenderer::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
LazyRenderer::__construct public function LazyRenderer constructor.
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.