ValueProcessor.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Model\Design\Config;
  7. use Magento\Theme\Model\Design\BackendModelFactory;
  8. class ValueProcessor
  9. {
  10. /**
  11. * @var BackendModelFactory
  12. */
  13. protected $backendModelFactory;
  14. /**
  15. * @param BackendModelFactory $backendModelFactory
  16. */
  17. public function __construct(
  18. BackendModelFactory $backendModelFactory
  19. ) {
  20. $this->backendModelFactory = $backendModelFactory;
  21. }
  22. /**
  23. * Process value
  24. *
  25. * @param string $value
  26. * @param string $scope
  27. * @param string $scopeId
  28. * @param array $fieldConfig
  29. * @return mixed
  30. */
  31. public function process($value, $scope, $scopeId, array $fieldConfig)
  32. {
  33. $backendModel = $this->backendModelFactory->createByPath(
  34. $fieldConfig['path'],
  35. [
  36. 'value' => $value,
  37. 'field_config' => $fieldConfig,
  38. 'scope' => $scope,
  39. 'scope_id' => $scopeId
  40. ]
  41. );
  42. $backendModel->afterLoad();
  43. return $backendModel->getValue();
  44. }
  45. }