You are here

abstract class SlickEntityFormatterBase in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/SlickEntityFormatterBase.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickEntityFormatterBase
  2. 7.3 src/Plugin/Field/FieldFormatter/SlickEntityFormatterBase.php \Drupal\slick\Plugin\Field\FieldFormatter\SlickEntityFormatterBase

Base class for slick entity reference formatters without field details.

Hierarchy

Expanded class hierarchy of SlickEntityFormatterBase

See also

\Drupal\slick_paragraphs\Plugin\Field\FieldFormatter

\Drupal\slick_entityreference\Plugin\Field\FieldFormatter

File

src/Plugin/Field/FieldFormatter/SlickEntityFormatterBase.php, line 17

Namespace

Drupal\slick\Plugin\Field\FieldFormatter
View source
abstract class SlickEntityFormatterBase extends BlazyEntityBase implements ContainerFactoryPluginInterface {
  use SlickFormatterViewTrait;
  use SlickFormatterTrait {
    buildSettings as traitBuildSettings;
  }

  /**
   * The logger factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $loggerFactory;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
    return self::injectServices($instance, $container, 'entity');
  }

  /**
   * Returns the blazy manager.
   */
  public function blazyManager() {
    return $this->formatter;
  }

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return [
      'view_mode' => '',
    ] + SlickDefault::baseSettings();
  }

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $entities = $this
      ->getEntitiesToView($items, $langcode);

    // Early opt-out if the field is empty.
    if (empty($entities)) {
      return [];
    }
    return $this
      ->commonViewElements($items, $langcode, $entities);
  }

  /**
   * Builds the settings.
   *
   * @todo inherit and extend parent post Blazy 2.x release.
   */
  public function buildSettings() {
    return [
      'blazy' => TRUE,
      'vanilla' => TRUE,
    ] + $this
      ->traitBuildSettings();
  }

  /**
   * {@inheritdoc}
   */
  public function getScopedFormElements() {
    return [
      'no_layouts' => TRUE,
    ] + $this
      ->getCommonScopedFormElements() + parent::getScopedFormElements();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SlickEntityFormatterBase::$loggerFactory protected property The logger factory.
SlickEntityFormatterBase::blazyManager public function Returns the blazy manager.
SlickEntityFormatterBase::buildSettings public function Builds the settings.
SlickEntityFormatterBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
SlickEntityFormatterBase::defaultSettings public static function
SlickEntityFormatterBase::getScopedFormElements public function
SlickEntityFormatterBase::viewElements public function
SlickFormatterTrait::$imageFactory protected property The image factory service.
SlickFormatterTrait::$manager protected property The slick field formatter manager.
SlickFormatterTrait::admin public function Returns the slick admin service shortcut.
SlickFormatterTrait::buildSettings public function Builds the settings. Aliased as: traitBuildSettings 1
SlickFormatterTrait::formatter public function Returns the slick field formatter service.
SlickFormatterTrait::getCommonFieldDefinition public function Defines the common scope for both front and admin.
SlickFormatterTrait::getCommonScopedFormElements public function Defines the common scope for the form elements.
SlickFormatterTrait::imageFactory public function Returns the image factory.
SlickFormatterTrait::injectServices protected static function Injects DI services.
SlickFormatterTrait::isApplicable public static function 2
SlickFormatterTrait::manager public function Returns the slick service.
SlickFormatterTrait::settingsSummary public function
SlickFormatterViewTrait::commonViewElements public function Returns similar view elements.