Move building of each component to separate method

Created on 5 December 2022, about 2 years ago
Updated 13 February 2023, almost 2 years ago

Problem/Motivation

In view builder src/Entity/ViewBuilder/Domain.php all components are built in `buildComponents()` method. I suggest to move building of each component to own separate method.
This will make it easier to override the building of components.
Currently, if someone would like to override default building of component, it's needed to implement own view builder, extend Domain view builder from drd module, override buildComponents, call buildComponents from parent class and override component using something like that:

if ($displays['drd_domain']->getComponent('monitoring')) {
  ...    
}

Even after all this actions component will not be fully overriden because component will be built in parent class and in custom view builder it will be rebuilded, not builded from scratch.
If we move building of components to separate methods it will be possible to just override method for building specific component. For example:

   /**
   * {@inheritDoc}
   */
  protected function buildMonitoringComponent(DomainInterface $domain): array {
    $build = [];

    $monitoring = $domain->getMonitoring();
    if (!empty($monitoring)) {
      ...
    }

    return $build;

Proposed resolution

Move building of each component to separate method

User interface changes

No

API changes

No

Data model changes

No

Feature request
Status

Fixed

Version

4.1

Component

Code

Created by

🇷🇺Russia qzmenko Novosibirsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024