techdivision /
import-customer
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * TechDivision\Import\Customer\Plugins\GlobalDataPlugin |
||
| 5 | * |
||
| 6 | * PHP version 7 |
||
| 7 | * |
||
| 8 | * @author MET <[email protected]> |
||
| 9 | * @copyright 2023 TechDivision GmbH <[email protected]> |
||
| 10 | * @license https://opensource.org/licenses/MIT |
||
| 11 | * @link https://github.com/techdivision/import |
||
| 12 | * @link http://www.techdivision.com |
||
| 13 | */ |
||
| 14 | declare(strict_types=1); |
||
| 15 | |||
| 16 | namespace TechDivision\Import\Customer\Plugins; |
||
| 17 | |||
| 18 | use TechDivision\Import\ApplicationInterface; |
||
| 19 | use TechDivision\Import\Customer\Services\CustomerBunchProcessorInterface; |
||
| 20 | use TechDivision\Import\Plugins\AbstractPlugin; |
||
| 21 | use TechDivision\Import\Customer\Utils\RegistryKeys; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Plugin that loads the global data. |
||
| 25 | * |
||
| 26 | * @author MET <[email protected]> |
||
| 27 | * @copyright 2023 TechDivision GmbH <[email protected]> |
||
| 28 | * @license https://opensource.org/licenses/MIT |
||
| 29 | * @link https://github.com/techdivision/import |
||
| 30 | * @link http://www.techdivision.com |
||
| 31 | */ |
||
| 32 | class GlobalDataPlugin extends AbstractPlugin |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * @var CustomerBunchProcessorInterface |
||
| 36 | */ |
||
| 37 | protected $customerBunchProcessor; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param ApplicationInterface $application The application instance |
||
| 41 | * @param CustomerBunchProcessorInterface $customerBunchProcessor The processor instance |
||
| 42 | */ |
||
| 43 | public function __construct( |
||
| 44 | ApplicationInterface $application, |
||
| 45 | CustomerBunchProcessorInterface $customerBunchProcessor |
||
| 46 | ) { |
||
| 47 | $this->customerBunchProcessor = $customerBunchProcessor; |
||
| 48 | parent::__construct($application); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Process the plugin functionality. |
||
| 53 | * |
||
| 54 | * @return void |
||
| 55 | * @throws \Exception Is thrown, if the plugin can not be processed |
||
| 56 | */ |
||
| 57 | public function process() |
||
| 58 | { |
||
| 59 | // initialize the array for the global data |
||
| 60 | $globalData = array(); |
||
| 61 | |||
| 62 | // initialize the global data |
||
| 63 | $globalData[RegistryKeys::COUNTRY_REGIONS] = $this->getCountryRegions(); |
||
| 64 | |||
| 65 | $globalData = array_merge($this->getImportProcessor()->getGlobalData(), $globalData); |
||
| 66 | |||
| 67 | // add the status with the global data |
||
| 68 | $this->getRegistryProcessor()->mergeAttributesRecursive( |
||
| 69 | RegistryKeys::STATUS, |
||
| 70 | array(RegistryKeys::GLOBAL_DATA => $globalData) |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return mixed |
||
| 76 | */ |
||
| 77 | public function getCountryRegions() |
||
| 78 | { |
||
| 79 | return $this->customerBunchProcessor->loadDirectoryCountryRegions(); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 80 | } |
||
| 81 | } |
||
| 82 |