Skip to content

Instantly share code, notes, and snippets.

@volgar1x
Created December 6, 2016 21:08
Show Gist options
  • Save volgar1x/b69acc986548d47f55cfd48f78580e72 to your computer and use it in GitHub Desktop.
Save volgar1x/b69acc986548d47f55cfd48f78580e72 to your computer and use it in GitHub Desktop.
<?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