/** * @param \Netlogix\JsonApiOrg\ExampleData\Domain\Dto\NodeResource $node */ public function createAction(\Netlogix\JsonApiOrg\ExampleData\Domain\Dto\NodeResource $node) { $this->nodeRepository->add($node->getPayload()); $this->response->setStatus(201); $this->response->setHeader('Content-Location', $node->getLinks()['self']); $this->forward('show', NULL, NULL, array('node' => $node->getPayload())); }
/** * Creates a new node tree */ public function createCommand() { $root = new Node('Root node'); $firstChild = new Node('First level child'); $firstChild->setParent($root); $firstChildOfFirstChild = new Node('Second level child'); $firstChildOfFirstChild->setParent($firstChild); $secondChildOfFirstChild = new Node('Second level child, 2nd edition'); $secondChildOfFirstChild->setParent($firstChild); $secondChild = new Node('First level child, 2nd edition'); $secondChild->setParent($root); $firstChildOfSecondChild = new Node('Second level child, 3rd edition'); $firstChildOfSecondChild->setParent($secondChild); $secondChildOfSecondChild = new Node('Second level child, 4th edition'); $secondChildOfSecondChild->setParent($secondChild); $thirdChildOfSecondChild = new Node('Second level child, 5th edition'); $thirdChildOfSecondChild->setParent($secondChild); $thirdChild = new Node('First level child, 4rd edition'); $thirdChild->setParent($root); $this->nodeRepository->add($root); }