Created
December 6, 2016 21:08
-
-
Save volgar1x/b69acc986548d47f55cfd48f78580e72 to your computer and use it in GitHub Desktop.
This file contains 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 | |
namespace SciMS; | |
use SciMS\Secure; | |
use SciMS\Model\User; | |
use SciMS\Model\ArticleQuery; | |
return [ | |
'/articles' => [ | |
'method' => 'GET', | |
'controller' => 'SciMS\Controller\ArticleController:getPage', | |
'secure' => false, // can be omitted | |
], | |
'/articles' => [ | |
'method' => 'POST', | |
'controller' => 'SciMS\Controller\ArticleController:index', | |
'secure' => Secure::hasRole('user'), | |
], | |
'/articles/:id' => [ | |
'method' => 'PATCH', | |
'controller' => 'SciMS\Controller\ArticleController:update', | |
'secure' => function(User $currentUser, array $args) { | |
$article = ArticleQuery::create()->findById($args['id']); | |
return $user->getId() === $article->getAccountId(); | |
}, | |
], | |
'/articles/:id' => [ | |
'method' => 'DELETE', | |
'controller' => 'SciMS\Controller\ArticleController:destroy', | |
'secure' => Secure::hasRole('admin'), | |
], | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment