You are here

ContentPublishingSettingsTrait.php in Acquia Lift Connector 8.4

File

modules/acquia_lift_publisher/src/Form/ContentPublishingSettingsTrait.php
View source
<?php

namespace Drupal\acquia_lift_publisher\Form;

use Drupal\Core\Entity\EntityInterface;

/**
 * Provides common methods for classes that involve publisher settings.
 *
 * @package Drupal\acquia_lift_publisher\Form
 */
trait ContentPublishingSettingsTrait {

  /**
   * Acquia lift publisher configuration object.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   * @see \Drupal\acquia_lift_publisher\Form\ContentPublishingForm
   */
  private $publisherSettings;

  /**
   * Returns the value of the entity view modes setting.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The current entity.
   *
   * @return array
   *   The setting value.
   */
  protected function getEntityViewModesSettingValue(EntityInterface $entity) : array {
    return $this->publisherSettings
      ->get("view_modes.{$entity->getEntityTypeId()}.{$entity->bundle()}") ?? [];
  }

}

Traits

Namesort descending Description
ContentPublishingSettingsTrait Provides common methods for classes that involve publisher settings.