Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PrepareShipmentDays.php
Go to the documentation of this file.
1 <?php
8 
15 
21 {
25  private $moduleDataSetup;
26 
30  private $localeResolver;
31 
37  public function __construct(
38  ModuleDataSetupInterface $moduleDataSetup,
39  \Magento\Framework\Locale\ResolverInterface $localeResolver
40  ) {
41  $this->moduleDataSetup = $moduleDataSetup;
42  $this->localeResolver = $localeResolver;
43  }
44 
48  public function apply()
49  {
50  $days = (new DataBundle())->get(
51  $this->localeResolver->getLocale()
52  )['calendar']['gregorian']['dayNames']['format']['abbreviated'];
53 
54  $select = $this->moduleDataSetup->getConnection()->select()->from(
55  $this->moduleDataSetup->getTable('core_config_data'),
56  ['config_id', 'value']
57  )->where(
58  'path = ?',
59  'carriers/dhl/shipment_days'
60  );
61  foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $configRow) {
62  $row = [
63  'value' => implode(
64  ',',
65  array_intersect_key(iterator_to_array($days), array_flip(explode(',', $configRow['value'])))
66  )
67  ];
68  $this->moduleDataSetup->getConnection()->update(
69  $this->moduleDataSetup->getTable('core_config_data'),
70  $row,
71  ['config_id = ?' => $configRow['config_id']]
72  );
73  }
74  }
75 
79  public static function getDependencies()
80  {
81  return [];
82  }
83 
87  public static function getVersion()
88  {
89  return '2.0.0';
90  }
91 
95  public function getAliases()
96  {
97  return [];
98  }
99 }
__construct(ModuleDataSetupInterface $moduleDataSetup, \Magento\Framework\Locale\ResolverInterface $localeResolver)