Loading modules/smart_date_recur/src/Controller/Instances.php +9 −10 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ class Instances extends ControllerBase { if (!$entity = $this->rrule->getParentEntity()) { return $this->returnError(); } $field_name = $this->rrule->field_name->getString(); if ($this->rrule->limit->isEmpty()) { $month_limit = SmartDateRule::getMonthsLimit($this->rrule); Loading Loading @@ -95,7 +94,6 @@ class Instances extends ControllerBase { // Build headers. // Iterate through rows and check for existing overrides. foreach ($instances as $index => &$instance) { $row_class = ''; // Check for an override. if (isset($overrides[$index])) { Loading @@ -107,14 +105,13 @@ class Instances extends ControllerBase { $override_type = 'overridden'; $override = $entity_storage ->load($override->entity_id->getString()); $field = $override->get($field_name); // TODO: drill down and retrieve, replace values. // TODO: drop in the URL to edit. // @todo drill down and retrieve, replace values. // @todo drop in the URL to edit. } elseif ($override->value->getString()) { // Rescheduled, use values from override. $override_type = 'rescheduled'; // TODO: drill down and retrieve, replace values. // @todo drill down and retrieve, replace values. $instance['value'] = $override->value->getString(); $instance['end_value'] = $override->end_value->getString(); } Loading Loading @@ -196,7 +193,7 @@ class Instances extends ControllerBase { */ public function buildRow(array $instance) { // Get format settings. // TODO: make the choice of format configurable? // @todo make the choice of format configurable? $format = \Drupal::getContainer() ->get('entity_type.manager') ->getStorage('smart_date_format') Loading Loading @@ -292,14 +289,16 @@ class Instances extends ControllerBase { ]), ]; if ($this->useAjax) { $operations['edit']['url'] = Url::fromRoute('smart_date_recur.instance.reschedule.ajax', ['rrule' => $instance['rrule'], 'index' => $instance['rrule_index']]); $operations['edit']['url'] = Url::fromRoute('smart_date_recur.instance.reschedule.ajax', [ 'rrule' => $instance['rrule'], 'index' => $instance['rrule_index'], ]); $operations['edit']['attributes']['class'][] = 'use-ajax'; } case 'overriden': // Removal handled by the delete action already defined. // TODO: Update the URL of the Edit button above to point to the // @todo Update the URL of the Edit button above to point to the // entity form of the referenced entity. break; Loading modules/smart_date_recur/src/Entity/SmartDateOverride.php +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ class SmartDateOverride extends ContentEntityBase { ->setLabel(t('Duration, in minutes')) ->setRequired(FALSE); // TODO: figure out a way to validate as required but accept zero. // @todo figure out a way to validate as required but accept zero. // Allow an instance to be overridden by a full entity. // NOTE: entity_type is skipped here because it will always match the rule. $fields['entity_id'] = BaseFieldDefinition::create('entity_reference') Loading modules/smart_date_recur/src/Entity/SmartDateRule.php +15 −11 Original line number Diff line number Diff line Loading @@ -175,11 +175,9 @@ class SmartDateRule extends ContentEntityBase { $override = $overrides[$index]; if ($override->entity_id->getString()) { // Overridden, retrieve appropriate entity. $override_type = 'overridden'; $override = $entity_storage ->load($override['entity_id']); $field = $override->get($field_name); // TODO: drill down and retrieve, replace values. // @todo drill down and retrieve, replace values. } elseif ($override->value->getString()) { // Rescheduled, use values from override. Loading Loading @@ -251,7 +249,7 @@ class SmartDateRule extends ContentEntityBase { $transformer = new ArrayTransformer(); $instances = $transformer->transform($rrule, $constraint); // TODO: Convert the generated instances into an array for later processing. // @todo Convert the generated instances into an array for later processing. return $instances; } Loading Loading @@ -352,7 +350,10 @@ class SmartDateRule extends ContentEntityBase { break; } $repeat = $this->t('every :num :period', [':num' => $params['interval'], ':period' => $period]); $repeat = $this->t('every :num :period', [ ':num' => $params['interval'], ':period' => $period, ]); } else { $frequency_labels = static::getFrequencyLabels(); Loading Loading @@ -393,7 +394,10 @@ class SmartDateRule extends ContentEntityBase { $range_start = array_shift($range); if ($range) { $range_end = array_pop($range); $range_text[] = $this->t(':start to :end', [':start' => $range_start, ':end' => $range_end], ['context' => 'Rule text']); $range_text[] = $this->t(':start to :end', [ ':start' => $range_start, ':end' => $range_end, ], ['context' => 'Rule text']); } else { $range_text[] = $range_start; Loading Loading @@ -647,7 +651,7 @@ class SmartDateRule extends ContentEntityBase { $value = $field_def->getThirdPartySetting($module, $setting_name); } elseif ($field_def instanceof BaseFieldDefinition) { // TODO: Document that for custom entities, you must enable recurring // @todo Document that for custom entities, you must enable recurring // functionality by adding ->setSetting('allow_recurring', TRUE) // to your field definition. $value = $field_def->getSetting($setting_name); Loading Loading @@ -757,7 +761,7 @@ class SmartDateRule extends ContentEntityBase { */ public static function postDelete(EntityStorageInterface $storage, array $entities) { parent::postDelete($storage, $entities); foreach ($entities as $id => $rrule) { foreach ($entities as $rrule) { // Delete any child overrides when a rule is deleted. $overrides = $rrule->getRuleOverrides(); foreach ($overrides as $override) { Loading @@ -780,7 +784,7 @@ class SmartDateRule extends ContentEntityBase { 'text_processing' => 0, ]) ->setDefaultValue('') // TODO add a unique constrain for a combination of values, // @todo add a unique constrain for a combination of values, // e.g. start field amd delta and revision. ->setDisplayOptions('view', [ 'label' => 'hidden', Loading Loading @@ -819,7 +823,7 @@ class SmartDateRule extends ContentEntityBase { ->setDescription(t('Additional parameters to define the recurrence.')) ->setSetting('is_ascii', TRUE); // TODO: Decide if this field is necessary, given the presence of the Limit. // @todo Decide if this field is necessary, given the presence of the Limit. $fields['unlimited'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Unlimited')) ->setDescription(t('Whether or not the rule has a limit or end.')) Loading @@ -837,7 +841,7 @@ class SmartDateRule extends ContentEntityBase { ->setLabel(t('Bundle')) ->setDescription(t('The bundle on which the date is set.')) ->setSetting('is_ascii', TRUE) // TODO: Check for a different limit on bundle max length. // @todo Check for a different limit on bundle max length. ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH); $fields['field_name'] = BaseFieldDefinition::create('string') Loading modules/smart_date_recur/src/Form/SmartDateOverrideDeleteAjaxForm.php +9 −3 Original line number Diff line number Diff line Loading @@ -23,8 +23,14 @@ class SmartDateOverrideDeleteAjaxForm extends FormBase { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, SmartDateOverride $entity = NULL) { $cancelurl = new Url('smart_date_recur.instances', ['rrule' => (int) $entity->rrule->value, 'modal' => TRUE]);; $submiturl = new Url('smart_date_recur.instance.revert.ajax', ['entity' => $entity->id(), 'confirm' => 1]);; $cancelurl = new Url('smart_date_recur.instances', [ 'rrule' => (int) $entity->rrule->value, 'modal' => TRUE, ]); $submiturl = new Url('smart_date_recur.instance.revert.ajax', [ 'entity' => $entity->id(), 'confirm' => 1, ]); $form['#prefix'] = '<div id="manage-instances">'; $form['#suffix'] = '</div>'; $form['message'] = [ Loading Loading @@ -70,7 +76,7 @@ class SmartDateOverrideDeleteAjaxForm extends FormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // TODO: Implement submitForm() method. // @todo Implement submitForm() method. } } modules/smart_date_recur/src/Form/SmartDateOverrideDeleteForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -40,13 +40,13 @@ class SmartDateOverrideDeleteForm extends ContentEntityConfirmFormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // TODO: Delete override entity, if it exists. // @todo Delete override entity, if it exists. $this->entity ->delete(); /* @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */ /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */ $entityTypeManager = \Drupal::service('entity_type.manager'); $rrid = $this->entity->rrule->getString(); /* @var \Drupal\smart_date_recur\Entity\SmartDateRule $rrule */ /** @var \Drupal\smart_date_recur\Entity\SmartDateRule $rrule */ $rrule = $entityTypeManager->getStorage('smart_date_rule')->load($rrid); $instanceController = new Instances(); // Force refresh of parent entity. Loading Loading
modules/smart_date_recur/src/Controller/Instances.php +9 −10 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ class Instances extends ControllerBase { if (!$entity = $this->rrule->getParentEntity()) { return $this->returnError(); } $field_name = $this->rrule->field_name->getString(); if ($this->rrule->limit->isEmpty()) { $month_limit = SmartDateRule::getMonthsLimit($this->rrule); Loading Loading @@ -95,7 +94,6 @@ class Instances extends ControllerBase { // Build headers. // Iterate through rows and check for existing overrides. foreach ($instances as $index => &$instance) { $row_class = ''; // Check for an override. if (isset($overrides[$index])) { Loading @@ -107,14 +105,13 @@ class Instances extends ControllerBase { $override_type = 'overridden'; $override = $entity_storage ->load($override->entity_id->getString()); $field = $override->get($field_name); // TODO: drill down and retrieve, replace values. // TODO: drop in the URL to edit. // @todo drill down and retrieve, replace values. // @todo drop in the URL to edit. } elseif ($override->value->getString()) { // Rescheduled, use values from override. $override_type = 'rescheduled'; // TODO: drill down and retrieve, replace values. // @todo drill down and retrieve, replace values. $instance['value'] = $override->value->getString(); $instance['end_value'] = $override->end_value->getString(); } Loading Loading @@ -196,7 +193,7 @@ class Instances extends ControllerBase { */ public function buildRow(array $instance) { // Get format settings. // TODO: make the choice of format configurable? // @todo make the choice of format configurable? $format = \Drupal::getContainer() ->get('entity_type.manager') ->getStorage('smart_date_format') Loading Loading @@ -292,14 +289,16 @@ class Instances extends ControllerBase { ]), ]; if ($this->useAjax) { $operations['edit']['url'] = Url::fromRoute('smart_date_recur.instance.reschedule.ajax', ['rrule' => $instance['rrule'], 'index' => $instance['rrule_index']]); $operations['edit']['url'] = Url::fromRoute('smart_date_recur.instance.reschedule.ajax', [ 'rrule' => $instance['rrule'], 'index' => $instance['rrule_index'], ]); $operations['edit']['attributes']['class'][] = 'use-ajax'; } case 'overriden': // Removal handled by the delete action already defined. // TODO: Update the URL of the Edit button above to point to the // @todo Update the URL of the Edit button above to point to the // entity form of the referenced entity. break; Loading
modules/smart_date_recur/src/Entity/SmartDateOverride.php +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ class SmartDateOverride extends ContentEntityBase { ->setLabel(t('Duration, in minutes')) ->setRequired(FALSE); // TODO: figure out a way to validate as required but accept zero. // @todo figure out a way to validate as required but accept zero. // Allow an instance to be overridden by a full entity. // NOTE: entity_type is skipped here because it will always match the rule. $fields['entity_id'] = BaseFieldDefinition::create('entity_reference') Loading
modules/smart_date_recur/src/Entity/SmartDateRule.php +15 −11 Original line number Diff line number Diff line Loading @@ -175,11 +175,9 @@ class SmartDateRule extends ContentEntityBase { $override = $overrides[$index]; if ($override->entity_id->getString()) { // Overridden, retrieve appropriate entity. $override_type = 'overridden'; $override = $entity_storage ->load($override['entity_id']); $field = $override->get($field_name); // TODO: drill down and retrieve, replace values. // @todo drill down and retrieve, replace values. } elseif ($override->value->getString()) { // Rescheduled, use values from override. Loading Loading @@ -251,7 +249,7 @@ class SmartDateRule extends ContentEntityBase { $transformer = new ArrayTransformer(); $instances = $transformer->transform($rrule, $constraint); // TODO: Convert the generated instances into an array for later processing. // @todo Convert the generated instances into an array for later processing. return $instances; } Loading Loading @@ -352,7 +350,10 @@ class SmartDateRule extends ContentEntityBase { break; } $repeat = $this->t('every :num :period', [':num' => $params['interval'], ':period' => $period]); $repeat = $this->t('every :num :period', [ ':num' => $params['interval'], ':period' => $period, ]); } else { $frequency_labels = static::getFrequencyLabels(); Loading Loading @@ -393,7 +394,10 @@ class SmartDateRule extends ContentEntityBase { $range_start = array_shift($range); if ($range) { $range_end = array_pop($range); $range_text[] = $this->t(':start to :end', [':start' => $range_start, ':end' => $range_end], ['context' => 'Rule text']); $range_text[] = $this->t(':start to :end', [ ':start' => $range_start, ':end' => $range_end, ], ['context' => 'Rule text']); } else { $range_text[] = $range_start; Loading Loading @@ -647,7 +651,7 @@ class SmartDateRule extends ContentEntityBase { $value = $field_def->getThirdPartySetting($module, $setting_name); } elseif ($field_def instanceof BaseFieldDefinition) { // TODO: Document that for custom entities, you must enable recurring // @todo Document that for custom entities, you must enable recurring // functionality by adding ->setSetting('allow_recurring', TRUE) // to your field definition. $value = $field_def->getSetting($setting_name); Loading Loading @@ -757,7 +761,7 @@ class SmartDateRule extends ContentEntityBase { */ public static function postDelete(EntityStorageInterface $storage, array $entities) { parent::postDelete($storage, $entities); foreach ($entities as $id => $rrule) { foreach ($entities as $rrule) { // Delete any child overrides when a rule is deleted. $overrides = $rrule->getRuleOverrides(); foreach ($overrides as $override) { Loading @@ -780,7 +784,7 @@ class SmartDateRule extends ContentEntityBase { 'text_processing' => 0, ]) ->setDefaultValue('') // TODO add a unique constrain for a combination of values, // @todo add a unique constrain for a combination of values, // e.g. start field amd delta and revision. ->setDisplayOptions('view', [ 'label' => 'hidden', Loading Loading @@ -819,7 +823,7 @@ class SmartDateRule extends ContentEntityBase { ->setDescription(t('Additional parameters to define the recurrence.')) ->setSetting('is_ascii', TRUE); // TODO: Decide if this field is necessary, given the presence of the Limit. // @todo Decide if this field is necessary, given the presence of the Limit. $fields['unlimited'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Unlimited')) ->setDescription(t('Whether or not the rule has a limit or end.')) Loading @@ -837,7 +841,7 @@ class SmartDateRule extends ContentEntityBase { ->setLabel(t('Bundle')) ->setDescription(t('The bundle on which the date is set.')) ->setSetting('is_ascii', TRUE) // TODO: Check for a different limit on bundle max length. // @todo Check for a different limit on bundle max length. ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH); $fields['field_name'] = BaseFieldDefinition::create('string') Loading
modules/smart_date_recur/src/Form/SmartDateOverrideDeleteAjaxForm.php +9 −3 Original line number Diff line number Diff line Loading @@ -23,8 +23,14 @@ class SmartDateOverrideDeleteAjaxForm extends FormBase { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, SmartDateOverride $entity = NULL) { $cancelurl = new Url('smart_date_recur.instances', ['rrule' => (int) $entity->rrule->value, 'modal' => TRUE]);; $submiturl = new Url('smart_date_recur.instance.revert.ajax', ['entity' => $entity->id(), 'confirm' => 1]);; $cancelurl = new Url('smart_date_recur.instances', [ 'rrule' => (int) $entity->rrule->value, 'modal' => TRUE, ]); $submiturl = new Url('smart_date_recur.instance.revert.ajax', [ 'entity' => $entity->id(), 'confirm' => 1, ]); $form['#prefix'] = '<div id="manage-instances">'; $form['#suffix'] = '</div>'; $form['message'] = [ Loading Loading @@ -70,7 +76,7 @@ class SmartDateOverrideDeleteAjaxForm extends FormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // TODO: Implement submitForm() method. // @todo Implement submitForm() method. } }
modules/smart_date_recur/src/Form/SmartDateOverrideDeleteForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -40,13 +40,13 @@ class SmartDateOverrideDeleteForm extends ContentEntityConfirmFormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // TODO: Delete override entity, if it exists. // @todo Delete override entity, if it exists. $this->entity ->delete(); /* @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */ /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */ $entityTypeManager = \Drupal::service('entity_type.manager'); $rrid = $this->entity->rrule->getString(); /* @var \Drupal\smart_date_recur\Entity\SmartDateRule $rrule */ /** @var \Drupal\smart_date_recur\Entity\SmartDateRule $rrule */ $rrule = $entityTypeManager->getStorage('smart_date_rule')->load($rrid); $instanceController = new Instances(); // Force refresh of parent entity. Loading