public function testExtractMethodData()
 {
     $classReflection = new \Zend\Code\Reflection\ClassReflection('\\Magento\\Webapi\\Test\\Unit\\Model\\Config\\TestServiceForClassReflector');
     /** @var $methodReflection \Zend\Code\Reflection\MethodReflection */
     $methodReflection = $classReflection->getMethods()[0];
     $methodData = $this->_classReflector->extractMethodData($methodReflection);
     $expectedResponse = $this->_getSampleReflectionData();
     $this->assertEquals($expectedResponse, $methodData);
 }
Ejemplo n.º 2
0
 /**
  * Collect the list of services metadata
  *
  * @return array
  */
 protected function initServicesMetadata()
 {
     $services = [];
     foreach ($this->config->getServices()[Converter::KEY_SERVICES] as $serviceClass => $serviceVersionData) {
         foreach ($serviceVersionData as $version => $serviceData) {
             $serviceName = $this->getServiceName($serviceClass, $version);
             foreach ($serviceData[Converter::KEY_METHODS] as $methodName => $methodMetadata) {
                 $services[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [self::KEY_METHOD => $methodName, self::KEY_IS_REQUIRED => (bool) $methodMetadata[Converter::KEY_SECURE], self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE], self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES]];
                 $services[$serviceName][self::KEY_CLASS] = $serviceClass;
             }
             $reflectedMethodsMetadata = $this->classReflector->reflectClassMethods($serviceClass, $services[$serviceName][self::KEY_SERVICE_METHODS]);
             $services[$serviceName][self::KEY_SERVICE_METHODS] = array_merge_recursive($services[$serviceName][self::KEY_SERVICE_METHODS], $reflectedMethodsMetadata);
             $services[$serviceName][Converter::KEY_DESCRIPTION] = $this->classReflector->extractClassDescription($serviceClass);
         }
     }
     return $services;
 }
Ejemplo n.º 3
0
 /**
  * Collect the list of services with their operations available in SOAP.
  *
  * @return array
  */
 protected function _initServicesMetadata()
 {
     // TODO: Implement caching if this approach is approved
     if (is_null($this->_soapServices)) {
         $this->_soapServices = [];
         foreach ($this->_config->getServices()[Converter::KEY_SERVICES] as $serviceClass => $serviceData) {
             $serviceName = $this->_helper->getServiceName($serviceClass);
             foreach ($serviceData as $methodName => $methodMetadata) {
                 $this->_soapServices[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [self::KEY_METHOD => $methodName, self::KEY_IS_REQUIRED => (bool) $methodMetadata[Converter::KEY_SECURE], self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE], self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES]];
                 $this->_soapServices[$serviceName][self::KEY_CLASS] = $serviceClass;
             }
             $reflectedMethodsMetadata = $this->_classReflector->reflectClassMethods($serviceClass, $this->_soapServices[$serviceName][self::KEY_SERVICE_METHODS]);
             // TODO: Consider service documentation extraction via reflection
             $this->_soapServices[$serviceName][self::KEY_SERVICE_METHODS] = array_merge_recursive($this->_soapServices[$serviceName][self::KEY_SERVICE_METHODS], $reflectedMethodsMetadata);
         }
     }
     return $this->_soapServices;
 }