/** * Returns a list of available integration types * * @return array [{integration type} => [{attr1} => {val1}, ...], ...] */ protected function getAvailableIntegrationTypes() { if (null === $this->itemsCache) { $this->itemsCache = $this->registry->getAvailableIntegrationTypesDetailedData(); } return $this->itemsCache; }
/** * @return array */ protected function getChoices() { $choices = []; $choicesData = $this->registry->getAvailableIntegrationTypesDetailedData(); foreach ($choicesData as $typeName => $data) { $attributes = []; if (!empty($data['icon'])) { $attributes['data-icon'] = $this->assetHelper->getUrl($data['icon']); } $choices[$typeName] = new ChoiceListItem($data['label'], $attributes); } return $choices; }
/** * {@inheritdoc} */ public function finishView(FormView $view, FormInterface $form, array $options) { $typeData = $this->typesRegistry->getAvailableIntegrationTypesDetailedData(); /** @var ChoiceView $choiceView */ foreach ($view->vars['choices'] as $choiceView) { /** @var Integration $integration */ $integration = $choiceView->data; $attributes = ['data-status' => $integration->isEnabled()]; if (isset($typeData[$integration->getType()], $typeData[$integration->getType()]['icon'])) { $attributes['data-icon'] = $this->assetHelper->getUrl($typeData[$integration->getType()]['icon']); } $choiceView->label = new ChoiceListItem($choiceView->label, $attributes); } }
public function testGetAvailableIntegrationTypesChoiceListWithIcon() { $this->assertEquals([self::CHANNEL_TYPE_ONE => ["label" => "oro.type1.label", "icon" => "bundles/acmedemo/img/logo.png"], self::CHANNEL_TYPE_TWO => ["label" => "oro.type2.label"]], $this->typesRegistry->getAvailableIntegrationTypesDetailedData()); }