public function testCreateByPath() { $path = 'design/head/default_title'; $backendModelType = 'Magento\\Theme\\Model\\Design\\Backend\\Exceptions'; $backendModel = $this->getMockBuilder($backendModelType)->disableOriginalConstructor()->getMock(); $this->metadataProviderMock->expects($this->once())->method('get')->willReturn(['head_default_title' => ['path' => $path, 'backend_model' => $backendModelType]]); $this->objectManagerMock->expects($this->once())->method('create')->with($backendModelType, ['data' => []])->willReturn($backendModel); $this->assertEquals($backendModel, $this->model->createByPath($path)); }
/** * Retrieve backend model by field code * * @param string $code * @return File * @throws LocalizedException */ protected function getBackendModel($code) { $metadata = $this->metadataProvider->get(); if (!(isset($metadata[$code]) && isset($metadata[$code]['backend_model']))) { throw new LocalizedException(__('Backend model is not specified for %1', $code)); } return $this->backendModelFactory->createByPath($metadata[$code]['path']); }
/** * Process value * * @param string $value * @param string $scope * @param string $scopeId * @param array $fieldConfig * @return mixed */ public function process($value, $scope, $scopeId, array $fieldConfig) { $backendModel = $this->backendModelFactory->createByPath($fieldConfig['path'], ['value' => $value, 'field_config' => $fieldConfig, 'scope' => $scope, 'scope_id' => $scopeId]); $backendModel->afterLoad(); return $backendModel->getValue(); }
/** * Process value * * @param string $value * @param string $path * @return mixed */ public function process($value, $path) { $backendModel = $this->backendModelFactory->createByPath($path, ['value' => $value]); $backendModel->afterLoad(); return $backendModel->getValue(); }