src/Strategy/EntityLink.php
public function extract($value)
    {
        if (is_null($value)) {
            return $value;
        }

        $entityValues = $this->getHydratorForEntity($value)->extract($value);
        $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))];

        $link = new Link('self');
        $link->setRoute($entityMetadata['route_name']);
        $link->setRouteParams([
            $entityMetadata['route_identifier_name'] => $entityValues[$entityMetadata['entity_identifier_name']]
        ]);

        $linkCollection = new LinkCollection();
        $linkCollection->add($link);

        $halEntity = new HalEntity(new stdClass());
        $halEntity->setLinks($linkCollection);

        return $halEntity;
    }
public function extract($value)
    {
        if (is_null($value)) {
            return $value;
        }

        $entityValues = $this->getHydratorForEntity($value)->extract($value);
        $entityMetadata = $this->getMetadataMap()[ClassUtils::getRealClass(get_class($value))];

        $link = new Link('self');
        $link->setRoute($entityMetadata['route_name']);
        $link->setRouteParams([
            $entityMetadata['route_identifier_name'] => $entityValues[$entityMetadata['entity_identifier_name']]
        ]);

        $linkCollection = new LinkCollection();
        $linkCollection->add($link);

        $halEntity = new HalEntity(new stdClass());
        $halEntity->setLinks($linkCollection);

        return $halEntity;
    }
public function extract ( $ value ) { if ( is_null ( $ value ) ) { return $ value ; } $ entityValues = $ this -> getHydratorForEntity ( $ value ) -> extract ( $ value ) ; $ entityMetadata = $ this -> getMetadataMap ( ) [ ClassUtils :: getRealClass ( get_class ( $ value ) ) ] ; $ link = new Link ( 'self' ) ; $ link -> setRoute ( $ entityMetadata [ 'route_name' ] ) ; $ link -> setRouteParams ( [ $ entityMetadata [ 'route_identifier_name' ] => $ entityValues [ $ entityMetadata [ 'entity_identifier_name' ] ] ] ) ; $ linkCollection = new LinkCollection ( ) ; $ linkCollection -> add ( $ link ) ; $ halEntity = new HalEntity ( new stdClass ( ) ) ; $ halEntity -> setLinks ( $ linkCollection ) ; return $ halEntity ; }
Return a HAL entity with just a self link
Return a HAL entity with just a self link