Exemplo n.º 1
0
 /**
  * return params route
  * @param $name
  * @param string $type
  * @return array
  */
 protected function getParamsByResource(&$name, $type = 'item')
 {
     $parentResource = null;
     $parameters = [];
     $version = $this->getScope()->getDunglasResource()->getVersion();
     if ($resource = $this->resourceCollection->getResourceForEntityWithVersion($name, $version)) {
         $parameters = $resource->getRouteKeyParams($name);
         if (empty($parameters)) {
             $parameters['id'] = $this->propertyAccessor->getValue($name, 'id');
         }
         if (null !== $resource->getParent() && !isset($parameters[$resource->getParentName()])) {
             $parentResource = $resource->getParent();
             $parentObject = $this->propertyAccessor->getValue($name, Inflector::singularize($resource->getParentName()));
             $parentParams = $parentResource->getRouteKeyParams($parentObject);
             $parameters = array_merge($parentParams, $parameters);
         }
         $name = $this->getItemRouteName($resource, $type);
     }
     return $parameters;
 }