Skip to content

Switch - Case - Default

Purpose

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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;
}

Dependencies

  • config
    • node.type.article
  • module
    • eca_content

Events

  • Presave content entity

Last update: August 29, 2022 14:50:34