class GetterEvent

An Event that has getter methods defined for its properties.

"Getter" events expose their properties through getter methods. Rules learns about these methods through the 'getter' metadata declared in a MODULE.rules.events.yml file. This allows Rules to access event properties even if the getter methods don't follow the naming convention of get<PropertyName>().

This class is meant for testing, to ensure Rules can access properties using the methods declared in the 'getter' metadata. A 'real' event class would also have a constructor and/or setter methods to set the initial values of the properties, and might have other methods that make use of these properties to return a value.

Hierarchy

  • class \Drupal\Component\EventDispatcher\Event extends \Symfony\Component\EventDispatcher\Event
    • class \Drupal\rules_test_event\Event\GetterEvent extends \Drupal\Component\EventDispatcher\Event

Expanded class hierarchy of GetterEvent

See also

\Drupal\rules\EventSubscriber\GenericEventSubscriber

3 files declare their use of GetterEvent
DispatchForm.php in tests/modules/rules_test_event/src/Form/DispatchForm.php
EventPropertyAccessTest.php in tests/src/Unit/Integration/Event/EventPropertyAccessTest.php
EventPropertyAccessTest.php in tests/src/Kernel/EventPropertyAccessTest.php
1 string reference to 'GetterEvent'
DispatchForm::buildForm in tests/modules/rules_test_event/src/Form/DispatchForm.php
Form constructor.

File

tests/modules/rules_test_event/src/Event/GetterEvent.php, line 24

Namespace

Drupal\rules_test_event\Event
View source
class GetterEvent extends Event {
    const EVENT_NAME = 'rules_test_event.getter_event';
    
    /**
     * A public property.
     *
     * @var string
     */
    public $publicProperty = 'public property';
    
    /**
     * A protected property.
     *
     * @var string
     */
    protected $protectedProperty = 'protected property';
    
    /**
     * A private property.
     *
     * @var string
     */
    private $privateProperty = 'private property';
    
    /**
     * Getter method for $publicProperty.
     *
     * @return string
     *   The value of publicProperty.
     */
    public function publicGetter() {
        return $this->publicProperty;
    }
    
    /**
     * Getter method for $protectedProperty.
     *
     * @return string
     *   The value of protectedProperty.
     */
    public function protectedGetter() {
        return $this->protectedProperty;
    }
    
    /**
     * Getter method for $publicProperty.
     *
     * @return string
     *   The value of privateProperty.
     */
    public function privateGetter() {
        return $this->privateProperty;
    }

}

Members

Title Sort descending Modifiers Object type Summary
GetterEvent::$privateProperty private property A private property.
GetterEvent::$protectedProperty protected property A protected property.
GetterEvent::$publicProperty public property A public property.
GetterEvent::EVENT_NAME constant
GetterEvent::privateGetter public function Getter method for $publicProperty.
GetterEvent::protectedGetter public function Getter method for $protectedProperty.
GetterEvent::publicGetter public function Getter method for $publicProperty.