ConditionTestDualUser.php

Same filename and directory in other branches
  1. 9 core/modules/system/tests/modules/condition_test/src/Plugin/Condition/ConditionTestDualUser.php
  2. 8.9.x core/modules/system/tests/modules/condition_test/src/Plugin/Condition/ConditionTestDualUser.php
  3. 10 core/modules/system/tests/modules/condition_test/src/Plugin/Condition/ConditionTestDualUser.php

Namespace

Drupal\condition_test\Plugin\Condition

File

core/modules/system/tests/modules/condition_test/src/Plugin/Condition/ConditionTestDualUser.php

View source
<?php

declare (strict_types=1);
namespace Drupal\condition_test\Plugin\Condition;

use Drupal\Core\Condition\Attribute\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a condition that requires two users.
 */
class ConditionTestDualUser extends ConditionPluginBase {
  
  /**
   * {@inheritdoc}
   */
  public function evaluate() {
    $user1 = $this->getContextValue('user1');
    $user2 = $this->getContextValue('user2');
    return $user1->id() === $user2->id();
  }
  
  /**
   * {@inheritdoc}
   */
  public function summary() {
    return $this->t('This condition has two users.');
  }

}

Classes

Title Deprecated Summary
ConditionTestDualUser Provides a condition that requires two users.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.