buildLayoutRoutes example

$defaults['entity_type_id'] = $entity_type_id;

      // Retrieve the requirements from the canonical route.       $requirements = $collection->get("entity.$entity_type_id.canonical")->getRequirements();

      $options = [];
      // Ensure that upcasting is run in the correct order.       $options['parameters']['section_storage'] = [];
      $options['parameters'][$entity_type_id]['type'] = 'entity:' . $entity_type_id;

      $template = $entity_type->getLinkTemplate('canonical') . '/layout';
      $this->buildLayoutRoutes($collection$this->getPluginDefinition()$template$defaults$requirements$options$entity_type_id$entity_type_id);
    }
  }

  /** * {@inheritdoc} */
  public function buildLocalTasks($base_plugin_definition) {
    $local_tasks = [];
    foreach ($this->getEntityTypes() as $entity_type_id => $entity_type) {
      $local_tasks["layout_builder.overrides.$entity_type_id.view"] = $base_plugin_definition + [
        'route_name' => "layout_builder.overrides.$entity_type_id.view",
        
$config = $this->configFactory->getEditable($this->getConfigName());
    $return = $config->get('sections') ? SAVED_UPDATED : SAVED_NEW;
    $config->set('sections', $sections)->save();
    return $return;
  }

  /** * {@inheritdoc} */
  public function buildRoutes(RouteCollection $collection) {
    $this->buildLayoutRoutes($collection$this->getPluginDefinition(), 'layout-builder-test-simple-config/{id}');
  }

  /** * {@inheritdoc} */
  public function deriveContextsFromRoute($value$definition$name, array $defaults) {
    $contexts['config_id'] = new Context(new ContextDefinition('string')$value ?: $defaults['id']);
    return $contexts;
  }

  /** * {@inheritdoc} */
else {
          $defaults['bundle_key'] = $entity_type->getBundleEntityType();
        }
      }

      $requirements = [];
      $requirements['_field_ui_view_mode_access'] = 'administer ' . $entity_type_id . ' display';

      $options = $entity_route->getOptions();
      $options['_admin_route'] = FALSE;

      $this->buildLayoutRoutes($collection$this->getPluginDefinition()$path$defaults$requirements$options$entity_type_id, 'entity_view_display');

      // Set field_ui.route_enhancer to run on the manage layout form.       if (isset($defaults['bundle_key'])) {
        $collection->get("layout_builder.defaults.$entity_type_id.view")
          ->setOption('_field_ui', TRUE)
          ->setDefault('bundle', '');
      }

      $route_names = [
        "entity.entity_view_display.{$entity_type_id}.default",
        "entity.entity_view_display.{$entity_type_id}.view_mode",
      ];
Home | Imprint | This part of the site doesn't use cookies.