Open Data Catalog v2.0.0
ImportInfoList.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
7 use FileFetcher\FileFetcher;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
9 
13 class ImportInfoList implements ContainerInjectionInterface {
14 
20  private $jobStoreFactory;
21 
22  private $importInfo;
23 
29  public static function create(ContainerInterface $container) {
30  return new static(
31  $container->get('dkan.common.job_store'),
32  $container->get('dkan.datastore.import_info')
33  );
34  }
35 
39  public function __construct(JobStoreFactory $jobStoreFactory, ImportInfo $importInfo) {
40  $this->jobStoreFactory = $jobStoreFactory;
41  $this->importInfo = $importInfo;
42  }
43 
53  public function buildList() {
54  $list = [];
55 
56  $store = $this->jobStoreFactory->getInstance(FileFetcher::class);
57 
58  foreach ($store->retrieveAll() as $id) {
59  $pieces = explode("_", $id);
60 
61  // The filefetcher identifier for resources has the form <id>_<version>
62  // by doing this check we can eliminate processing some unrelated file
63  // fetching activities, but we should @todo better.
64  if (count($pieces) == 2) {
65  $list[$id] = $this->importInfo->getItem($pieces[0], $pieces[1]);
66  }
67  }
68 
69  return $list;
70  }
71 
72 }
Drupal\datastore\Service\Info
Definition: ImportInfo.php:3
Drupal\datastore\Service\Info\ImportInfoList\buildList
buildList()
Definition: ImportInfoList.php:53
Drupal\common\Storage\JobStoreFactory
Definition: JobStoreFactory.php:11
Drupal\datastore\Service\Info\ImportInfoList
Definition: ImportInfoList.php:13
Drupal\datastore\Service\Info\ImportInfoList\__construct
__construct(JobStoreFactory $jobStoreFactory, ImportInfo $importInfo)
Definition: ImportInfoList.php:39
Drupal\datastore\Service\Info\ImportInfoList\create
static create(ContainerInterface $container)
Definition: ImportInfoList.php:29
Drupal\datastore\Service\Info\ImportInfo
Definition: ImportInfo.php:15