Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LockProcessor.php
Go to the documentation of this file.
1 <?php
7 
16 
25 {
31  private $preparedValueFactory;
32 
38  private $deploymentConfigWriter;
39 
45  private $arrayManager;
46 
52  private $configPathResolver;
56  private $target;
57 
65  public function __construct(
66  PreparedValueFactory $preparedValueFactory,
67  DeploymentConfig\Writer $writer,
68  ArrayManager $arrayManager,
69  ConfigPathResolver $configPathResolver,
70  $target = ConfigFilePool::APP_ENV
71  ) {
72  $this->preparedValueFactory = $preparedValueFactory;
73  $this->deploymentConfigWriter = $writer;
74  $this->arrayManager = $arrayManager;
75  $this->configPathResolver = $configPathResolver;
76  $this->target = $target;
77  }
78 
85  public function process($path, $value, $scope, $scopeCode)
86  {
87  try {
88  $configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode, System::CONFIG_TYPE);
89  $backendModel = $this->preparedValueFactory->create($path, $value, $scope, $scopeCode);
90 
91  if ($backendModel instanceof Value) {
96  $backendModel->validateBeforeSave();
97  $backendModel->beforeSave();
98 
99  $value = $backendModel->getValue();
100 
101  $backendModel->afterSave();
102 
107  $this->deploymentConfigWriter->saveConfig(
108  [$this->target => $this->arrayManager->set($configPath, [], $value)],
109  false
110  );
111  }
112  } catch (\Exception $exception) {
113  throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception);
114  }
115  }
116 }
__construct(PreparedValueFactory $preparedValueFactory, DeploymentConfig\Writer $writer, ArrayManager $arrayManager, ConfigPathResolver $configPathResolver, $target=ConfigFilePool::APP_ENV)
return false
Definition: gallery.phtml:36
__()
Definition: __.php:13
$value
Definition: gender.phtml:16