14 use Zend\Code\Reflection\MethodReflection;
26 private $dataObjectProcessor;
31 private $methodsMapProcessor;
36 private $authorization;
46 private $isPermissionChecked;
74 $isPermissionChecked =
false 76 $this->dataObjectProcessor = $dataObjectProcessor;
77 $this->methodsMapProcessor = $methodsMapProcessor;
78 $this->typeCaster = $typeCaster;
79 $this->fieldNamer = $fieldNamer;
80 $this->authorization = $authorization;
82 $this->isPermissionChecked = $isPermissionChecked;
95 $methods = $this->methodsMapProcessor->getMethodsMap($dataObjectType);
99 foreach (array_keys(
$methods) as $methodName) {
100 if (!$this->methodsMapProcessor->isMethodValidForDataField($dataObjectType, $methodName)) {
104 $key = $this->fieldNamer->getFieldNameForMethodName($methodName);
105 if ($this->isPermissionChecked && !$this->isAttributePermissionValid($dataObjectType, $key)) {
109 $value = $dataObject->{$methodName}();
115 $returnType = $this->methodsMapProcessor->getMethodReturnType($dataObjectType, $methodName);
118 $value = $this->dataObjectProcessor->buildOutputDataArray(
$value, $returnType);
121 $arrayElementType = substr($returnType, 0, -2);
122 foreach (
$value as $singleValue) {
123 if (is_object($singleValue) && !($singleValue instanceof Phrase)) {
124 $singleValue = $this->dataObjectProcessor->buildOutputDataArray(
129 $valueResult[] = $this->typeCaster->castValueToType($singleValue, $arrayElementType);
133 $value = $this->typeCaster->castValueToType(
$value, $returnType);
136 $outputData[$key] =
$value;
147 private function isAttributePermissionValid($dataObjectType,
$attributeCode)
149 $typeName = $this->getRegularTypeForExtensionAttributesType($dataObjectType);
152 if (!$this->authorization->isAllowed($permission)) {
164 private function getRegularTypeForExtensionAttributesType(
$name)
166 return ltrim(str_replace(
'ExtensionInterface',
'Interface',
$name),
'\\');
174 private function getPermissionsForTypeAndMethod($typeName,
$attributeCode)
elseif(isset( $params[ 'redirect_parent']))
const RESOURCE_PERMISSIONS
__construct(DataObjectProcessor $dataObjectProcessor, MethodsMap $methodsMapProcessor, TypeCaster $typeCaster, FieldNamer $fieldNamer, AuthorizationInterface $authorization, Config $config, $isPermissionChecked=false)
if(!isset($_GET['name'])) $name