DependentFields.php 913 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\MessageQueue\Topology\Config\Validator;
  7. use Magento\Framework\MessageQueue\Topology\Config\ValidatorInterface;
  8. /**
  9. * Topology config data validator.
  10. */
  11. class DependentFields implements ValidatorInterface
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function validate($configData)
  17. {
  18. $errors = [];
  19. foreach ($configData as $name => $data) {
  20. foreach ((array)$data['bindings'] as $binding) {
  21. if (isset($data['type']) && $data['type'] == 'topic' && !isset($binding['topic'])) {
  22. $errors[] = 'Topic name is required for topic based exchange: ' . $name;
  23. }
  24. }
  25. }
  26. if (!empty($errors)) {
  27. throw new \LogicException(implode(PHP_EOL, $errors));
  28. }
  29. }
  30. }