Skip to content

Instantly share code, notes, and snippets.

@baldurrensch
Created August 10, 2012 21:23
Show Gist options
  • Save baldurrensch/3318103 to your computer and use it in GitHub Desktop.
Save baldurrensch/3318103 to your computer and use it in GitHub Desktop.
HalResource Interface
<?php
namespace Hautelook\ApiBundle\Entity;
/**
* Hautelook\MainBundle\Entity\HalResource
* This interface should be implemented by all entities that are used in a Hal enabled JSON response.
* It standardizes the way to specify the resource rel and the links that should be added to the entities.
*
* @author Baldur Rensch <baldur.rensch@hautelook.com>
*/
interface HalResource
{
/**
* Returns the Resource's "Rel"
* @return String
*/
public static function getHalRel();
/**
* Returns an array of \Hal\Link links. This array should then be passed into the \Hal\Resource::setLinks() function.
* @return array
*/
public function getHalLinks();
/**
* Returns the link to the entity specified by the primary keys
* @return String
*/
public static function getHalSelfByPK($primaryKeys = null);
/**
* Returns the link to the entity
* @return String
*/
public function getHalSelf();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment