/**
  * @param HalApiLink $link
  */
 private function addSubordinateRoutes(HalApiLink $link)
 {
     $subordinateRoutes = $this->routeHelper->subordinates($link->getRoute());
     foreach ($subordinateRoutes as $subRoute) {
         /** @var HalApiController $class */
         list($class, $method) = explode('@', $subRoute->getActionName());
         $this->link($class::getRelation($method), $this->linkFactory->create($subRoute, $link->getParameters()));
     }
 }
Exemplo n.º 2
0
 /**
  * @param HalApiControllerParameters $parameters
  */
 public function __construct(HalApiControllerParameters $parameters)
 {
     $this->app = $parameters->getApplication();
     $this->linkFactory = $parameters->getLinkFactory();
     $this->representationFactory = $parameters->getRepresentationFactory();
     $this->routeHelper = $parameters->getRouteHelper();
     $this->responseFactory = $parameters->getResponseFactory();
     $this->request = $parameters->getRequest();
     $this->parameters = new SafeIndexArray($this->request->input());
     $this->body = new SafeIndexArray($this->request->json()->all());
     /** @var Route $route */
     $route = $this->request->route();
     if ($route) {
         $routeParameters = $route->parameters();
         $this->self = $this->linkFactory->create($route, $routeParameters);
         $this->parent = $this->linkFactory->create($this->routeHelper->parent($route), $routeParameters);
     }
 }
Exemplo n.º 3
0
 /**
  * @param Model $model
  * @return HalApiLink
  */
 protected function getParent(Model $model)
 {
     return $this->linkFactory->create($this->parent);
 }