Commit 5d068bd3 authored by Jakob P's avatar Jakob P
Browse files

Issue #3263077 by fskreuz, DamienMcKenna, japerry: PHP 8.1 compatibility fixes for Page Manager

parent dc69fb36
Loading
Loading
Loading
Loading
+3 −1
Changes for page_manager_ui/page_manager_ui.module: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ function template_preprocess_page_manager_wizard_tree(&$variables) {
  /** @var $wizard \Drupal\ctools\Wizard\FormWizardInterface|\Drupal\ctools\Wizard\EntityFormWizardInterface */
  $wizard = $variables['wizard'];
  $cached_values = $variables['cached_values'];
  $tree = $variables['tree'];
  $tree = !empty($variables['tree']) ? $variables['tree'] : [];
  $variables['step'] = $wizard->getStep($cached_values);

  foreach ($wizard->getOperations($cached_values) as $step => $operation) {
@@ -98,6 +98,7 @@ function template_preprocess_page_manager_wizard_tree(&$variables) {

    // Fill in parents if there are breadcrumbs.
    $parent =& $tree;
    if (is_array($parent)) {
      if (isset($operation['breadcrumbs'])) {
        foreach ($operation['breadcrumbs'] as $breadcrumb) {
          $breadcrumb_string = (string) $breadcrumb;
@@ -117,6 +118,7 @@ function template_preprocess_page_manager_wizard_tree(&$variables) {
        'step' => $step,
      ];
    }
  }

  $variables['tree'] = $tree;
}
+1 −1
Changes for page_manager_ui/src/Wizard/PageWizardBase.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class PageWizardBase extends EntityFormWizardBase {
    /** @var $page \Drupal\page_manager\Entity\Page */
    $page = $cached_values['page'];

    if ($page) {
    if ($page && $page->getPath()) {
      $matches = [];
      preg_match_all('|\{\w+\}|', $page->getPath(), $matches);
      if (array_filter($matches)) {
+3 −8
Changes for src/Entity/Page.php: 3 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -137,14 +137,14 @@ class Page extends ConfigEntityBase implements PageInterface {
   * {@inheritdoc}
   */
  public function getPath() {
    return $this->path;
    return $this->path ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function usesAdminTheme() {
    return isset($this->use_admin_theme) ? $this->use_admin_theme : strpos($this->getPath(), '/admin/') === 0;
    return $this->use_admin_theme ?? strpos($this->getPath(), '/admin/') === 0;
  }

  /**
@@ -296,7 +296,7 @@ class Page extends ConfigEntityBase implements PageInterface {
   * {@inheritdoc}
   */
  public function getParameterNames() {
    if (preg_match_all('|\{(\w+)\}|', $this->getPath(), $matches)) {
    if ($this->getPath() && preg_match_all('|\{(\w+)\}|', $this->getPath(), $matches)) {
      return $matches[1];
    }
    return [];
@@ -339,11 +339,6 @@ class Page extends ConfigEntityBase implements PageInterface {
   * {@inheritdoc}
   */
  public function getContexts() {
    // @todo add the other global contexts here as they are added
    // @todo maybe come up with a non-hardcoded way of doing this?
    $global_contexts = [
      'current_user',
    ];
    if (!$this->contexts) {
      $this->eventDispatcher()->dispatch(PageManagerEvents::PAGE_CONTEXT, new PageManagerContextEvent($this));
      foreach ($this->getParameters() as $machine_name => $configuration) {