ZF\Apigility\Admin\Model\RpcServiceEntity::exchangeArray PHP Method

exchangeArray() public method

public exchangeArray ( array $data )
$data array
    public function exchangeArray(array $data)
    {
        foreach ($data as $key => $value) {
            $key = strtolower($key);
            $key = str_replace('_', '', $key);
            switch ($key) {
                case 'acceptwhitelist':
                    if (!is_array($value)) {
                        throw new InvalidArgumentException(sprintf('%s expects an array value for "%s"; received "%s"', __CLASS__, is_object($value) ? get_class($value) : gettype($value)));
                    }
                    $this->acceptWhitelist = $value;
                    break;
                case 'contenttypewhitelist':
                    if (!is_array($value)) {
                        throw new InvalidArgumentException(sprintf('%s expects an array value for "%s"; received "%s"', __CLASS__, is_object($value) ? get_class($value) : gettype($value)));
                    }
                    $this->contentTypeWhitelist = $value;
                    break;
                case 'controllerclass':
                    $this->controllerClass = $value;
                    break;
                case 'controllerservicename':
                    $this->controllerServiceName = $value;
                    break;
                case 'httpmethods':
                    if (!is_array($value)) {
                        throw new InvalidArgumentException(sprintf('%s expects an array value for "%s"; received "%s"', __CLASS__, is_object($value) ? get_class($value) : gettype($value)));
                    }
                    $this->httpMethods = $value;
                    break;
                case 'inputfilters':
                    if ($value instanceof InputFilterCollection || $value instanceof HalCollection) {
                        $this->inputFilters = $value;
                    }
                    break;
                case 'documentation':
                    $this->documentation = $value;
                    break;
                case 'routematch':
                    $this->routeMatch = $value;
                    break;
                case 'routename':
                    $this->routeName = $value;
                    break;
                case 'selector':
                    $this->selector = $value;
                    break;
                case 'servicename':
                    $this->serviceName = $value;
                    break;
                default:
                    break;
            }
        }
        if (empty($this->controllerServiceName) || !is_string($this->controllerServiceName)) {
            throw new RuntimeException(sprintf('%s requires a controller service name; none present following population', __CLASS__));
        }
    }

Usage Example

 /**
  * Inject the class name of the controller, if it can be resolved.
  *
  * @param RpcServiceEntity $service
  */
 protected function injectControllerClass(RpcServiceEntity $service)
 {
     $controllerServiceName = $service->controllerServiceName;
     if (!$this->controllerManager->has($controllerServiceName)) {
         return;
     }
     $controller = $this->controllerManager->get($controllerServiceName);
     $service->exchangeArray(['controller_class' => get_class($controller)]);
 }
All Usage Examples Of ZF\Apigility\Admin\Model\RpcServiceEntity::exchangeArray