You are here

public static function Webform::addCacheableDependency in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/Webform.php \Drupal\webform\Element\Webform::addCacheableDependency()

Adds webform.settings and webform as cache dependencies to a render array.

Parameters

array &$elements: The render array to update.

\Drupal\webform\WebformInterface $webform: A webform.

Return value

array A render array with webform.settings and webform as cache dependencies.

2 calls to Webform::addCacheableDependency()
Webform::buildAccessDenied in src/Element/Webform.php
Build access denied message for a webform.
Webform::preRenderWebformElement in src/Element/Webform.php
Webform element pre render callback.

File

src/Element/Webform.php, line 160

Class

Webform
Provides a render element to display a webform.

Namespace

Drupal\webform\Element

Code

public static function addCacheableDependency(array &$elements, WebformInterface $webform) {

  /** @var \Drupal\Core\Render\RendererInterface $renderer */
  $renderer = \Drupal::service('renderer');

  // Track if webform.settings is updated.
  $config = \Drupal::configFactory()
    ->get('webform.settings');
  $renderer
    ->addCacheableDependency($elements, $config);

  // Track if the webform is updated.
  $renderer
    ->addCacheableDependency($elements, $webform);
  return $elements;
}