You are here

trait PlaceholderResolverTrait in Typed Data API enhancements 8

Helper for classes that need the placeholder resolver.

Hierarchy

File

src/PlaceholderResolverTrait.php, line 8

Namespace

Drupal\typed_data
View source
trait PlaceholderResolverTrait {

  /**
   * The placeholder resolver.
   *
   * @var \Drupal\typed_data\PlaceholderResolverInterface
   */
  protected $placeholderResolver;

  /**
   * Sets the placeholder resolver.
   *
   * @param \Drupal\typed_data\PlaceholderResolverInterface $placeholder_resolver
   *   The placeholder resolver.
   *
   * @return $this
   */
  public function setPlaceholderResolver(PlaceholderResolverInterface $placeholder_resolver) {
    $this->placeholderResolver = $placeholder_resolver;
    return $this;
  }

  /**
   * Gets the placeholder resolver.
   *
   * @return \Drupal\typed_data\PlaceholderResolverInterface
   *   The placeholder resolver.
   */
  public function getPlaceholderResolver() {
    if (empty($this->placeholderResolver)) {
      $this->placeholderResolver = \Drupal::service('typed_data.placeholder_resolver');
    }
    return $this->placeholderResolver;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PlaceholderResolverTrait::$placeholderResolver protected property The placeholder resolver.
PlaceholderResolverTrait::getPlaceholderResolver public function Gets the placeholder resolver.
PlaceholderResolverTrait::setPlaceholderResolver public function Sets the placeholder resolver.