drupal-eca-recipe/eca_lib_0004

默认情况下的开关

安装: 7

依赖项: 0

建议者: 0

安全: 0

类型:drupal-recipe

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

This package is auto-updated.

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


README

ID: eca_lib_0004

展示如何模拟典型的 switch-case PHP 构造函数,在 ECA 模型中类似 if-elsif-else 语句。

该模型类似于您在 PHP 中通常所做的那样

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;
}

安装

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