Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted to PSR-2 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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