Skip to content
Snippets Groups Projects
Commit f98e1896 authored by Owen Bush's avatar Owen Bush
Browse files

Reworking the inheritance configurations

parent 1e885901
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,16 @@ show_capacity: true
email_notifications: true
registration_notification_enabled: true
registration_notification_subject: "You've Successfully Registered"
registration_notification_body: "Your registration for the [eventinstance:title] event was successful."
registration_notification_body: "Your registration for the [eventinstance:title] [eventinstance:reg_type] was successful."
waitlist_notification_enabled: true
waitlist_notification_subject: "You've Been Added To The Waitlist"
waitlist_notification_body: "You have been added to the waitlist for the [eventinstance:title] event."
waitlist_notification_body: "You have been added to the waitlist for the [eventinstance:title] [eventinstance:reg_type]."
promotion_notification_enabled: true
promotion_notification_subject: "You've Been Added To The Registration List"
promotion_notification_body: "You have been promoted from the waitlist to the registration list for the [eventinstance:title] event."
promotion_notification_body: "You have been promoted from the waitlist to the registration list for the [eventinstance:title] [eventinstance:reg_type]."
cancellation_notification_enabled: true
cancellation_notification_subject: "An Event Has Been Cancelled"
cancellation_notification_body: "Unfortunately, the [eventinstance:title] event has been cancelled."
cancellation_notification_body: "Unfortunately, the [eventinstance:title] [eventinstance:reg_type] has been cancelled."
modification_notification_enabled: true
modification_notification_subject: "An Event Has Been Modified"
modification_notification_body: "The [eventinstance:title] event has been modified, please check back for details."
\ No newline at end of file
modification_notification_body: "The [eventinstance:title] [eventinstance:reg_type] has been modified, please check back for details."
\ No newline at end of file
......@@ -56,7 +56,7 @@ function recurring_events_registration_tokens($type, $tokens, array $data, array
break;
case 'reg_type':
$replacements[$original] = $creation_service->getRegistrationType();
$replacements[$original] = $creation_service->getRegistrationType() == 'series' ?: 'event';
break;
}
}
......
......@@ -382,7 +382,7 @@ class EventInstance extends EditorialContentEntityBase implements EventInterface
// Inherited fields from eventseries entity.
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
->setLabel(t('Inherited Series Title'))
->setDescription(t('The title as inherited from the series.'))
->setComputed(TRUE)
->setClass('\Drupal\recurring_events\FieldInheritanceFactory')
......@@ -399,7 +399,7 @@ class EventInstance extends EditorialContentEntityBase implements EventInterface
]);
$fields['description'] = BaseFieldDefinition::create('text_long')
->setLabel(t('Description'))
->setLabel(t('Inherited Series Description'))
->setDescription(t('The description as inherited from the series.'))
->setComputed(TRUE)
->setClass('\Drupal\recurring_events\FieldInheritanceFactory')
......
......@@ -45,7 +45,7 @@ class FieldInheritanceFactory extends FieldItemList {
}
/**
* Compute the list property from state.
* Compute the field property from state.
*/
protected function computeValue() {
$entity = $this->getEntity();
......
......@@ -102,11 +102,13 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
* {@inheritdoc}
*/
public function computeValue() {
$this->validateArguments();
$method = $this->getMethod();
$field = $this->getSourceField();
$instance = $this->entity;
$series = $instance->getEventSeries();
$value = '';
switch ($method) {
case 'inherit':
......@@ -114,9 +116,6 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
break;
case 'prepend':
if (empty($this->getEntityField())) {
throw new \InvalidArgumentException("The definition's 'entity field' key must be set to prepend data.");
}
$entity_field = $this->getEntityField();
$fields = [];
......@@ -130,9 +129,6 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
break;
case 'append':
if (empty($this->getEntityField())) {
throw new \InvalidArgumentException("The definition's 'entity field' key must be set to append data.");
}
$entity_field = $this->getEntityField();
$fields = [];
......@@ -146,9 +142,6 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
break;
case 'fallback':
if (empty($this->getEntityField())) {
throw new \InvalidArgumentException("The definition's 'entity field' key must be set to fallback to series data.");
}
$entity_field = $this->getEntityField();
$value = '';
......@@ -161,13 +154,36 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
}
break;
}
return $value;
}
default:
throw new \InvalidArgumentException("The definition's 'method' key must be one of: inherit, prepend, or append.");
/**
* Validate the configuration arguments of the plugin.
*/
protected function validateArguments() {
if (empty($this->getMethod())) {
throw new \InvalidArgumentException("The definition's 'method' key must be set to inherit data.");
}
if (empty($this->getSourceField())) {
throw new \InvalidArgumentException("The definition's 'source field' key must be set to inherit data.");
}
return $value;
$method = $this->getMethod();
$entity_field_methods = [
'prepend',
'append',
'fallback',
];
if (array_search($method, $entity_field_methods)) {
if (empty($this->getEntityField())) {
throw new \InvalidArgumentException("The definition's 'entity field' key must be set to prepend, append, or fallback to series data.");
}
}
return TRUE;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment