Skip to content

Commit

Permalink
Converted to PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
helpfulrobot committed Dec 27, 2015
1 parent 085fd7d commit bfb733a
Show file tree
Hide file tree
Showing 10 changed files with 1,684 additions and 1,389 deletions.
34 changes: 20 additions & 14 deletions code/RESTCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@
* - Collection only has one type of Item nested under it, but it can have multiple of that type of Item
* - Item has many types of Nouns (Collections & Items) nested under it, but it can only have one of each type of Noun
*/
trait RESTCollection {
use RESTNoun;
trait RESTCollection
{
use RESTNoun;

abstract function getItems();
abstract function getItem($id);
abstract public function getItems();
abstract public function getItem($id);

function LinkFor($item) {
if ($item->parent !== $this) user_error('Tried to get link for noun that was not gotten from this collection', E_USER_ERROR);
return Controller::join_links($this->Link(), $item->getID());
}
public function LinkFor($item)
{
if ($item->parent !== $this) {
user_error('Tried to get link for noun that was not gotten from this collection', E_USER_ERROR);
}
return Controller::join_links($this->Link(), $item->getID());
}

protected function markAsNested($obj) {
$obj->parent = $this;
return $obj;
}
protected function markAsNested($obj)
{
$obj->parent = $this;
return $obj;
}
}

class RESTCollection_Handler extends RESTNoun_Handler {
}
class RESTCollection_Handler extends RESTNoun_Handler
{
}
Loading

0 comments on commit bfb733a

Please sign in to comment.