This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
// Handle application | |
} catch (Exception $e) { | |
$response = $di->get(Services::RESPONSE); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function all() { | |
return $this->createCollectionResponse($items, new ItemTransformer, 'items'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function find($id) { | |
return $this->createItemResponse($item, new ItemTransformer, 'item'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function find($id) { | |
return $this->createItemOkResponse($item, new ItemTransformer, 'item'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function delete($id) { | |
// Remove object code here | |
return $this->createOkResponse(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function authenticate() { | |
// Authentication code here | |
// We've successfully created a session | |
return $this->createArrayResponse([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomController extends \PhalconRest\Mvc\Controller\Fractal | |
{ | |
public function createResponse($response) { | |
// For example | |
if ($this->responseValid($response)) { | |
return $response; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \PhalconRest\Data\Query $query */ | |
$query = $this->get(AppServices::QUERY); | |
/** @var \PhalconRest\Data\Query\Parser\Phql $phqlQueryParser */ | |
$phqlQueryParser = $this->get(AppServices::PHQL_QUERY_PARSER); | |
/** @var \Phalcon\Mvc\Model\Query\Builder $phqlBuilder */ | |
$phqlBuilder = $phqlQueryParser->fromQuery($query); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($this->authManager->loggedIn()) { | |
$session = $this->authManager->getSession(); | |
$userId = $session->getIdentity(); // For example; 1 | |
$user = \Users::findFirstById($userId); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($this->authManager->loggedIn()) { | |
$session = $this->authManager->getSession(); | |
} |