コード例 #1
0
ファイル: PropertyTest.php プロジェクト: vixriihi/zf-jsonld
 public function testCanSetRouteOptionsSeparately()
 {
     $route = 'api/docs';
     $options = ['query' => 'version=1.1'];
     $property = new Property('describedby');
     $property->setRoute($route);
     $property->setRouteOptions($options);
     $this->assertEquals($route, $property->getRoute());
     $this->assertEquals($options, $property->getRouteOptions());
 }
コード例 #2
0
ファイル: JsonLD.php プロジェクト: vixriihi/zf-jsonld
 /**
  * Inject a "id"  based on the route and identifier
  *
  * @param  PropertyCollectionAwareInterface $resource
  * @param  string $route
  * @param  string $routeIdentifier
  */
 public function injectIDProperty(PropertyCollectionAwareInterface $resource, $route, $routeIdentifier = 'id')
 {
     $properties = $resource->getProperties();
     if ($properties->has('id')) {
         return;
     }
     $id = new Property('id');
     $id->setRoute($route);
     $routeParams = [];
     $routeOptions = [];
     if ($resource instanceof Entity && null !== $resource->id) {
         $routeParams = [$routeIdentifier => $resource->id];
     }
     if ($resource instanceof Collection) {
         $routeParams = $resource->getCollectionRouteParams();
         $routeOptions = $resource->getCollectionRouteOptions();
     }
     if (!empty($routeParams)) {
         $id->setRouteParams($routeParams);
     }
     if (!empty($routeOptions)) {
         $id->setRouteOptions($routeOptions);
     }
     $properties->add($id, true);
 }