/** * @param $runner_settings * * @return UpdateRunnerInterface */ protected function createRunnerInstance(&$runner_settings, FormStateInterface $form_state) { if (empty($runner_settings)) { $runner_settings = $this->entity->getUpdateRunnerSettings(); } if (!$this->runnerManager->hasDefinition($runner_settings['id'])) { // Settings is using plugin which no longer exists. $runner_settings = ['id' => 'default_embedded']; } /** @var UpdateRunnerInterface $update_runner */ $update_runner = $this->runnerManager->createInstance($runner_settings['id'], $runner_settings); $form_state->set('update_runner', $runner_settings); $form_state->set('scheduled_update_type', $this->entity); return $update_runner; }
/** * Save the entity on submit. * * @param array $form * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return int */ public function doSave(array $form, FormStateInterface $form_state) { $definition = $this->runnerManager->getDefinition($this->entity->getUpdateRunnerSettings()['id']); $this->entity->setUpdateTypesSupported($definition['update_types']); $status = $this->entity->save(); if ($status == SAVED_NEW) { drupal_set_message($this->t('Created the %label Scheduled Update Type.', [ '%label' => $this->entity->label(), ])); if (in_array('embedded',$this->entity->getUpdateTypesSupported())) { if ($form_state->getValue('reference_settings')) { $this->setUpFieldReferences($form_state); } } } return $status; }