Commit 7964d6fc authored by Volodymyr Mostepaniuk's avatar Volodymyr Mostepaniuk
Browse files

Issue #3295753 by mostepaniukvm: Code clean-up.

parent 85b968eb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ function custom_elements_ui_form_entity_view_display_edit_form_alter(&$form, For
  $display_entity = $display_form->getEntity();
  $is_enabled = $display_entity->getThirdPartySetting('custom_elements', 'enabled', FALSE);

  // Hide the table of fields same as in field_ui.
  // Hide the table of fields custom_elements display is activated.
  if ($is_enabled) {
    $form['fields']['#access'] = FALSE;
    $form['#fields'] = [];
@@ -81,6 +81,6 @@ function _custom_elements_ui_entity_view_display_edit_form_submit($form, FormSta
  /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $display_entity */
  $display_entity = $display_form->getEntity();
  $display_entity->setThirdPartySetting('custom_elements', 'enabled', $enabled);
  // @todo Autogenerate fields and name from view display entity?
  // @todo Autogenerate fields and names from view display entity?
  $display_entity->save();
}
+2 −3
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ namespace Drupal\custom_elements_ui\Form;

use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\PluginSettingsInterface;
use Drupal\Core\Form\FormStateInterface;
+3 −4
Original line number Diff line number Diff line
@@ -50,17 +50,16 @@ class RouteSubscriber extends RouteSubscriberBase {
        }
        // Special parameter used to easily recognize all _field_ui routes.
        // routes.
        // Usage example: Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer
        // Usage example: Drupal\Core\Entity\Enhancer\EntityBundleRouteEnhancer.
        $options['_field_ui'] = TRUE;

        $defaults = [
          'entity_type_id' => $entity_type_id,
        ];

        // If the entity type has no bundles and it doesn't use {bundle} in its
        // admin path, use the entity type.
        // If the entity type has no bundles and it doesn't use {bundle} in its
        // admin path, use the entity type.
        if (strpos($path, '{bundle}') === FALSE) {
        if (!str_contains($path, '{bundle}')) {
          if (!$entity_type->hasKey('bundle')) {
            $defaults['bundle'] = $entity_type_id;
          }
+2 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
    if (!empty($ce_display_fields)) {
      $this->buildConfiguredCustomElement($entity, $element, $display);
    }
    // Otherwise render it from layout builder config if enabled/
    // Otherwise render it from layout builder config if enabled.
    elseif ($display->getThirdPartySetting('layout_builder', 'enabled')) {
      // Skip processing of the fields and let the layout builder render it all.
      $this->addLayoutBuilderContent($entity, $element, $display);
@@ -176,6 +176,7 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
          case 'auto':
            $this->processAuto($field_items, $custom_element, $field_options['is_slot'], $field_options['label'], $display->getMode());
            break;

          case 'raw':
          default:
            $this->processRaw($field_items, $custom_element, $field_options['is_slot'], $field_options['label']);