TestTextCondition.php

Namespace

Drupal\rules_test\Plugin\Condition

File

tests/modules/rules_test/src/Plugin/Condition/TestTextCondition.php

View source
<?php

namespace Drupal\rules_test\Plugin\Condition;

use Drupal\rules\Core\RulesConditionBase;

/**
 * Returns TRUE if the 'text' context parameter equals 'test value'.
 *
 * @Condition(
 *   id = "rules_test_string_condition",
 *   label = @Translation("Test condition using a string"),
 *   category = @Translation("Tests"),
 *   context_definitions = {
 *     "text" = @ContextDefinition("string",
 *       label = @Translation("Text to compare")
 *     ),
 *   },
 *   configure_permissions = { "access test configuration" }
 * )
 */
class TestTextCondition extends RulesConditionBase {
    
    /**
     * {@inheritdoc}
     */
    public function evaluate() {
        $text = $this->getContextValue('text');
        return $text == 'test value';
    }
    
    /**
     * {@inheritdoc}
     */
    public function summary() {
        // We don't care about summaries for test condition plugins.
        return '';
    }

}

Classes

Title Deprecated Summary
TestTextCondition Returns TRUE if the 'text' context parameter equals 'test value'.