123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Dhl\Setup\Patch\Data;
- use Magento\Framework\Locale\Bundle\DataBundle;
- use Magento\Framework\Locale\ResolverInterface;
- use Magento\Framework\App\ResourceConnection;
- use Magento\Framework\Setup\ModuleDataSetupInterface;
- use Magento\Framework\Setup\Patch\DataPatchInterface;
- use Magento\Framework\Setup\Patch\PatchVersionInterface;
- /**
- * Class PrepareShipmentDays
- * @package Magento\Dhl\Setup\Patch
- */
- class PrepareShipmentDays implements DataPatchInterface, PatchVersionInterface
- {
- /**
- * @var ModuleDataSetupInterface
- */
- private $moduleDataSetup;
- /**
- * @var ResolverInterface
- */
- private $localeResolver;
- /**
- * PrepareShipmentDays constructor.
- * @param ModuleDataSetupInterface $moduleDataSetup
- * @param ResolverInterface $localeResolver
- */
- public function __construct(
- ModuleDataSetupInterface $moduleDataSetup,
- \Magento\Framework\Locale\ResolverInterface $localeResolver
- ) {
- $this->moduleDataSetup = $moduleDataSetup;
- $this->localeResolver = $localeResolver;
- }
- /**
- * {@inheritdoc}
- */
- public function apply()
- {
- $days = (new DataBundle())->get(
- $this->localeResolver->getLocale()
- )['calendar']['gregorian']['dayNames']['format']['abbreviated'];
- $select = $this->moduleDataSetup->getConnection()->select()->from(
- $this->moduleDataSetup->getTable('core_config_data'),
- ['config_id', 'value']
- )->where(
- 'path = ?',
- 'carriers/dhl/shipment_days'
- );
- foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $configRow) {
- $row = [
- 'value' => implode(
- ',',
- array_intersect_key(iterator_to_array($days), array_flip(explode(',', $configRow['value'])))
- )
- ];
- $this->moduleDataSetup->getConnection()->update(
- $this->moduleDataSetup->getTable('core_config_data'),
- $row,
- ['config_id = ?' => $configRow['config_id']]
- );
- }
- }
- /**
- * {@inheritdoc}
- */
- public static function getDependencies()
- {
- return [];
- }
- /**
- * {@inheritdoc}
- */
- public static function getVersion()
- {
- return '2.0.0';
- }
- /**
- * {@inheritdoc}
- */
- public function getAliases()
- {
- return [];
- }
- }
|