You are here

public function Page::setParameter in Page Manager 8

Same name and namespace in other branches
  1. 8.4 src/Entity/Page.php \Drupal\page_manager\Entity\Page::setParameter()

Adds/updates a given parameter context.

Parameters

string $name: The parameter context name.

string $type: The parameter context type.

string $label: (optional) The parameter context label.

Return value

$this

Overrides PageInterface::setParameter

File

src/Entity/Page.php, line 271
Contains \Drupal\page_manager\Entity\Page.

Class

Page
Defines a Page entity class.

Namespace

Drupal\page_manager\Entity

Code

public function setParameter($name, $type, $label = '') {
  $this->parameters[$name] = [
    'machine_name' => $name,
    'type' => $type,
    'label' => $label,
  ];

  // Reset contexts when a parameter is added or changed.
  $this->contexts = [];

  // Reset the contexts of every variant.
  foreach ($this
    ->getVariants() as $page_variant) {
    $page_variant
      ->resetCollectedContexts();
  }
  return $this;
}