/** * {@inheritdoc} */ public function addConfiguration(ArrayNodeDefinition $builder) { parent::addConfiguration($builder); $builder->children()->scalarNode('type')->isRequired()->cannotBeEmpty()->end()->arrayNode('options')->isRequired()->useAttributeAsKey('key')->prototype('scalar')->end()->end()->end(); $builder->validate()->ifTrue(function ($v) { $gatewayFactory = new GatewayFactory(); $gatewayFactory->find(); $supportedTypes = $gatewayFactory->all(); if (false == in_array($v['type'], $supportedTypes)) { throw new LogicException(sprintf('Given type %s is not supported. Try one of supported types: %s.', $v['type'], implode(', ', $supportedTypes))); } return false; })->thenInvalid('A message'); }