drupal-eca-recipe/eca_lib_0004

Switch Case Default

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Type:drupal-recipe

dev-main 2024-08-07 10:59 UTC

This package is auto-updated.

Last update: 2024-11-07 11:30:47 UTC


README

ID: eca_lib_0004

Demonstrate how typical switch-case PHP constructors could be simulated in ECA models - similar to if-elsif-else statements.

The model is similar to what you would normally do in PHP like this:

switch ($field_select) {
  case 'a1':
  case 'a2':
  case 'a3':
  case 'c7':
    // Set Status to 3
    $field_status = 3;

  case 'b1':
  case 'b2':
    // Set Status to 4
    $field_status = 4;

  default:
    // Set default Status
    $field_status = 2;
}

Installation

composer require drupal-eca-recipe/eca_lib_0004
cd web && php core/scripts/drupal recipe ../vendor/drupal-eca-recipe/eca_lib_0004