Example #1
0
 /**
  * @inheritDoc
  */
 public function extract(Property $object)
 {
     if (!$object->isComplete()) {
         throw new DomainException(sprintf('Property from resource provided to %s was incomplete; must contain a URL or a route', __METHOD__));
     }
     if ($object->hasValue()) {
         $value = $object->getValue();
         if ($value instanceof PropertyCollection) {
             $extractor = new PropertyCollectionExtractor($this);
             $value = $extractor->extract($value);
         }
         return $value;
     }
     if ($object->hasUrl()) {
         return $object->getUrl();
     }
     $reuseMatchedParams = true;
     $options = $object->getRouteOptions();
     if (isset($options['reuse_matched_params'])) {
         $reuseMatchedParams = (bool) $options['reuse_matched_params'];
         unset($options['reuse_matched_params']);
     }
     $path = call_user_func($this->urlHelper, $object->getRoute(), $object->getRouteParams(), $options, $reuseMatchedParams);
     if (substr($path, 0, 4) == 'http') {
         return $path;
     }
     return $this->getServerUrl() . $path;
 }
Example #2
0
 public function testCanSetPropertyUrl()
 {
     $url = 'http://example.com/docs.html';
     $property = new Property('describedby');
     $property->setUrl($url);
     $this->assertEquals($url, $property->getUrl());
 }