10 use Zend\Code\Reflection\ClassReflection;
    11 use Zend\Code\Reflection\MethodReflection;
    12 use Zend\Code\Reflection\ParameterReflection;
    37     private $typeProcessor;
    42     private $serviceInterfaceMethodsMap = [];
    61         \
Magento\Framework\Cache\FrontendInterface $cache,
    67         $this->typeProcessor = $typeProcessor;
    68         $this->attributeTypeResolver = $typeResolver;
    69         $this->fieldNamer = $fieldNamer;
   100         $key = self::SERVICE_INTERFACE_METHODS_CACHE_PREFIX . 
"-" . md5($interfaceName);
   101         if (!isset($this->serviceInterfaceMethodsMap[$key])) {
   102             $methodMap = $this->cache->load($key);
   104                 $this->serviceInterfaceMethodsMap[$key] = $this->getSerializer()->unserialize($methodMap);
   106                 $methodMap = $this->getMethodMapViaReflection($interfaceName);
   107                 $this->serviceInterfaceMethodsMap[$key] = $methodMap;
   108                 $this->cache->save($this->getSerializer()->serialize($this->serviceInterfaceMethodsMap[$key]), $key);
   111         return $this->serviceInterfaceMethodsMap[$key];
   121     public function getMethodParams($serviceClassName, $serviceMethodName)
   123         $cacheId = self::SERVICE_METHOD_PARAMS_CACHE_PREFIX . hash(
'md5', $serviceClassName . $serviceMethodName);
   124         $params = $this->cache->load($cacheId);
   126             return $this->getSerializer()->unserialize(
$params);
   128         $serviceClass = 
new ClassReflection($serviceClassName);
   130         $serviceMethod = $serviceClass->getMethod($serviceMethodName);
   133         foreach ($serviceMethod->getParameters() as $paramReflection) {
   134             $isDefaultValueAvailable = $paramReflection->isDefaultValueAvailable();
   136                 self::METHOD_META_NAME => $paramReflection->getName(),
   137                 self::METHOD_META_TYPE => $this->typeProcessor->getParamType($paramReflection),
   138                 self::METHOD_META_HAS_DEFAULT_VALUE => $isDefaultValueAvailable,
   139                 self::METHOD_META_DEFAULT_VALUE => $isDefaultValueAvailable ? $paramReflection->getDefaultValue() : null
   142         $this->cache->save($this->getSerializer()->serialize(
$params), $cacheId, [ReflectionCache::CACHE_TAG]);
   152     private function getMethodMapViaReflection($interfaceName)
   155         $class = 
new ClassReflection($interfaceName);
   156         $baseClassMethods = 
false;
   157         foreach (
$class->getMethods(\ReflectionMethod::IS_PUBLIC) as 
$method) {
   160             if (
$method->class === self::BASE_MODEL_CLASS) {
   161                 $baseClassMethods = 
true;
   162             } 
elseif ($baseClassMethods) {
   168             if ($this->isSuitableMethod(
$method)) {
   169                 $methodMap[
$method->getName()] = $this->typeProcessor->getGetterReturnType(
$method);
   181     private function isSuitableMethod(
$method)
   183         $isSuitableMethodType = !(
$method->isConstructor() || 
$method->isFinal()
   186         $isExcludedMagicMethod = strpos(
$method->getName(), 
'__') === 0;
   187         return $isSuitableMethodType && !$isExcludedMagicMethod;
   201             $methodMetadata = 
$methods[$methodName];
   204             if ($methodMetadata[
'parameterCount'] > 0) {
   208             return $this->fieldNamer->getFieldNameForMethodName($methodName) !== 
null;
   224         return $methods[$methodName][
'isRequired'];
   233     private function getSerializer()
   235         if ($this->serializer === 
null) {
   237                 ->get(SerializerInterface::class);
   239         return $this->serializer;
 const METHOD_META_DEFAULT_VALUE
elseif(isset( $params[ 'redirect_parent']))
const SERVICE_METHOD_PARAMS_CACHE_PREFIX
__construct(\Magento\Framework\Cache\FrontendInterface $cache, TypeProcessor $typeProcessor, \Magento\Framework\Api\AttributeTypeResolverInterface $typeResolver, FieldNamer $fieldNamer)
$_option $_optionId $class
const SERVICE_INTERFACE_METHODS_CACHE_PREFIX
const METHOD_META_HAS_DEFAULT_VALUE
getMethodReturnType($typeName, $methodName)
getMethodsMap($interfaceName)
isMethodValidForDataField($type, $methodName)
isMethodReturnValueRequired($type, $methodName)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]