コード例 #1
0
ファイル: Primate.php プロジェクト: linkorb/primate
 public function getDataByPath($path, $expands)
 {
     $part = explode('/', $path);
     if ($part[0] != '') {
         throw new InvalidArgument("URI should start with a slash: " . $path);
     }
     $serializer = new Serializer($this);
     $typeName = $part[1];
     $type = $this->getType($typeName);
     if (isset($part[2])) {
         $resourceId = $part[2];
         $resource = new Resource($type, $resourceId);
         $resource = $this->loadResource($resource, $expands);
         $data = $serializer->serializeResource($resource);
         return $data;
     } else {
         $collection = $this->getResourceCollection($typeName);
         $data = $serializer->serializeCollection($collection);
         return $data;
     }
 }