IdentityIsRegistrant.php in RNG - Events and Registrations 8.2
Same filename and directory in other branches
Namespace
Drupal\rng\Plugin\ConditionFile
src/Plugin/Condition/IdentityIsRegistrant.phpView source
<?php
namespace Drupal\rng\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a identity is registrant condition.
*
* Detects whether the identity is a registrant on the registration.
*
* @Condition(
* id = "rng_registration_identity",
* label = @Translation("Registration has identity"),
* context = {
* "user" = @ContextDefinition("entity:user",
* label = @Translation("Registrant"),
* required = TRUE
* ),
* "registration" = @ContextDefinition("entity:registration",
* label = @Translation("Registration"),
* required = TRUE
* )
* }
* )
*/
class IdentityIsRegistrant extends ConditionPluginBase {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['description']['#markup'] = $this
->t('There are no configuration options.');
return $form;
}
/**
* {@inheritdoc}
*/
public function summary() {
return $this
->t('Logged-in user is a registrant.');
}
/**
* {@inheritdoc}
*/
public function evaluate() {
/* @var \Drupal\user\UserInterface $user */
$user = $this
->getContextValue('user');
/* @var \Drupal\rng\Entity\RegistrationInterface $registration */
$registration = $this
->getContextValue('registration');
// Does not support new registrations ('create' operation).
if (!$registration
->isNew()) {
return $registration
->hasIdentity($user);
}
return FALSE;
}
}
Classes
Name | Description |
---|---|
IdentityIsRegistrant | Provides a identity is registrant condition. |