You are here

public function Webform::getAssets in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::getAssets()

Returns the webform's global and custom CSS and JavaScript assets.

Return value

array An associative array container the webform's CSS and JavaScript.

Overrides WebformInterface::getAssets

File

src/Entity/Webform.php, line 896

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function getAssets() {
  $this
    ->initElements();

  // Css.
  $css = [];
  $shared_css = \Drupal::config('webform.settings')
    ->get('assets.css') ?: '';
  if ($shared_css) {
    $css[] = $shared_css;
  }
  $webform_css = $this->css ?: '';
  if ($webform_css) {
    $css[] = $webform_css;
  }
  $css += $this->elementsCss;

  // JavaScript.
  $javascript = [];
  $shared_javascript = \Drupal::config('webform.settings')
    ->get('assets.javascript') ?: '';
  if ($shared_javascript) {
    $javascript[] = $shared_javascript;
  }
  $webform_javascript = $this->javascript ?: '';
  if ($webform_javascript) {
    $javascript[] = $webform_javascript;
  }
  $javascript += $this->elementsJavaScript;
  return [
    'css' => implode(PHP_EOL, $css),
    'javascript' => implode(PHP_EOL, $javascript),
  ];
}