collectionFactory = $collectionFactory; $this->data = $data; $this->urlBuilder = $urlBuilder; } /** * Get action options * * @return array */ public function jsonSerialize() { if ($this->options === null) { $options = $this->collectionFactory->create()->setRealGroupsFilter()->toOptionArray(); $this->prepareData(); foreach ($options as $optionCode) { $this->options[$optionCode['value']] = [ 'type' => 'customer_group_' . $optionCode['value'], 'label' => __($optionCode['label']), ]; if ($this->urlPath && $this->paramName) { $this->options[$optionCode['value']]['url'] = $this->urlBuilder->getUrl( $this->urlPath, [$this->paramName => $optionCode['value']] ); } $this->options[$optionCode['value']] = array_merge_recursive( $this->options[$optionCode['value']], $this->additionalData ); } $this->options = array_values($this->options); } return $this->options; } /** * Prepare addition data for subactions * * @return void */ protected function prepareData() { foreach ($this->data as $key => $value) { switch ($key) { case 'urlPath': $this->urlPath = $value; break; case 'paramName': $this->paramName = $value; break; case 'confirm': foreach ($value as $messageName => $message) { $this->additionalData[$key][$messageName] = (string) new Phrase($message); } break; default: $this->additionalData[$key] = $value; break; } } } }