Example #1
0
 /**
  * Returns all continuous jobs with the given language.
  *
  * @param string $source_langcode
  *   Source language.
  *
  * @return array
  *   Array of continuous jobs.
  */
 public function getContinuousJobs($source_langcode)
 {
     $jobs = array();
     $ids = $this->entityTypeManager->getStorage('tmgmt_job')->getQuery()->condition('source_language', $source_langcode)->condition('job_type', Job::TYPE_CONTINUOUS)->condition('state', Job::STATE_CONTINUOUS)->execute();
     if (!empty($ids)) {
         $jobs = Job::loadMultiple($ids);
     }
     return $jobs;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     // We are never going to have many entities here, so we can risk a loop.
     foreach ($entities as $key => $name) {
         // Find active jobs associated with the translator that is being deleted.
         $job_ids = \Drupal::entityQuery('tmgmt_job')->condition('state', [Job::STATE_ACTIVE, Job::STATE_CONTINUOUS, Job::STATE_UNPROCESSED], 'IN')->condition('translator', $key)->execute();
         $jobs = Job::loadMultiple($job_ids);
         /** @var \Drupal\tmgmt\JobInterface $job */
         foreach ($jobs as $job) {
             $job->aborted('Job has been aborted because the translation provider %provider was deleted.', ['%provider' => $job->getTranslatorLabel()]);
         }
     }
     parent::preDelete($storage, $entities);
 }