Drupal: bundle class

    0

    0

    Andrea Pistarini

    Library: Drupal

    // Crear una clase que extiende de Node
    final class MiClase extends Node {
    
      public function getMiMetodo(): Link {
        return 'mi-texto';
      }
    }
    
    // aΓ±adir el bundle class
    function mi_modulo_entity_bundle_info_alter(array &$bundles): void {
      if (isset($bundles['node']['mi_bundle'])) {
        $bundles['node']['mi_bundle']['class'] = MiClase::class;
      }
    }
    
    // llamar desde twig
    <div class="field--name-field-type-form-merchandising">
      {{ node.getMiMetodo() }}
    </div>
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.