class SocialEventEnrollService in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 8.5 modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 8.6 modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 8.7 modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 8.8 modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 10.0.x modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 10.1.x modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
- 10.2.x modules/social_features/social_event/src/Service/SocialEventEnrollService.php \Drupal\social_event\Service\SocialEventEnrollService
Class SocialEventEnrollService.
@package Drupal\social_event\Service
Hierarchy
- class \Drupal\social_event\Service\SocialEventEnrollService implements SocialEventEnrollServiceInterface
Expanded class hierarchy of SocialEventEnrollService
1 string reference to 'SocialEventEnrollService'
- social_event.services.yml in modules/
social_features/ social_event/ social_event.services.yml - modules/social_features/social_event/social_event.services.yml
1 service uses SocialEventEnrollService
- social_event.enroll in modules/
social_features/ social_event/ social_event.services.yml - Drupal\social_event\Service\SocialEventEnrollService
File
- modules/
social_features/ social_event/ src/ Service/ SocialEventEnrollService.php, line 14
Namespace
Drupal\social_event\ServiceView source
class SocialEventEnrollService implements SocialEventEnrollServiceInterface {
/**
* The event settings.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $eventSettings;
/**
* SocialEventEnrollService constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->eventSettings = $config_factory
->get('social_event.settings');
}
/**
* {@inheritdoc}
*/
public function isEnabled(NodeInterface $node) {
if ($this->eventSettings
->get('disable_event_enroll') || !$node
->hasField('field_event_enable_enrollment') || $node
->get('field_event_enable_enrollment')
->isEmpty() || !(bool) $node
->get('field_event_enable_enrollment')
->first()
->getValue()['value']) {
return FALSE;
}
if ($node
->bundle() === 'event' && $node
->hasField('field_event_enroll')) {
$was_not_changed = $node
->get('field_event_enroll')
->isEmpty();
$is_enabled = $node
->get('field_event_enroll')
->first()
->getValue()['value'];
// Make an exception for the invite enroll method.
// This doesn't allow people to enroll themselves, but get invited.
if (!$node
->get('field_enroll_method')
->isEmpty() && (int) $node
->get('field_enroll_method')
->first()
->getValue()['value'] === EventEnrollmentInterface::ENROLL_METHOD_INVITE) {
$is_enabled = TRUE;
}
return $was_not_changed || $is_enabled;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialEventEnrollService:: |
protected | property | The event settings. | |
SocialEventEnrollService:: |
public | function |
Check if enrollment is allowed for given event. Overrides SocialEventEnrollServiceInterface:: |
|
SocialEventEnrollService:: |
public | function | SocialEventEnrollService constructor. |