Commit ab2992e8 authored by Georgios Tsakalos's avatar Georgios Tsakalos

add software action

add software action and routing to  bootstrap file
add authorization of software
parent 86aa0aeb
......@@ -12,6 +12,15 @@ return [
'file_upload' => [
'tmp_path' => 'data/tmp',
'target_path' => 'data/uploads',
'acl' => [
'guards' => [
'routes' => [
['/school', ['school'], ['get']],
['/school/labs', ['school'], ['get', 'post']],
['/school/staff', ['school'], ['get', 'post', 'delete']],
['/school/assets', ['school'], ['get', 'post', 'delete']],
['/school/software', ['school'], ['get', 'post', 'delete']],
],
],
],
];
......@@ -111,6 +111,13 @@ return function (Slim\App $app) {
);
};
$container[Action\Software\ListAll::class] = function ($c) {
return new Action\Software\ListAll(
$c->get('view'),
$c->get(Service\SoftwareServiceInterface::class)
);
};
// services
$container['schoolservice'] = function ($c) {
......@@ -140,6 +147,10 @@ return function (Slim\App $app) {
return new Service\LabService($uploadTargetPath);
};
$container[Service\SoftwareServiceInterface::class] = function ($c) {
return new Service\SoftwareService();
};
$container[Service\AssetServiceInterface::class] = function ($c) {
return new Service\AssetService();
};
......@@ -228,6 +239,8 @@ return function (Slim\App $app) {
->add(Middleware\InputFilterSchoolAsset::class);
$this->delete('/assets', Action\Assets\DeleteAsset::class);
$this->get('/software', Action\Software\ListAll::class)->setName('school.software');
})->add(Middleware\FetchSchoolFromIdentity::class);
});
};
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\Schools\Action\Software;
use GrEduLabs\Schools\Service\SoftwareServiceInterface;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class ListAll
{
private $view;
private $softwareService;
public function __construct(Twig $view, SoftwareServiceInterface $softwareService)
{
$this->view = $view;
$this->softwareService = $softwareService;
}
public function __invoke(Request $req, Response $res, array $args = [])
{
$school = $req->getAttribute('school', false);
if (!$school) {
return $res->withStatus(403, 'No school');
}
$software = $this->softwareService->getSoftwareBySchoolId($school->id);
$categories = $this->softwareService->getSoftwareCategories();
return $this->view->render($res, 'schools/software.twig', [
'software' => $software,
'categories' => $categories
]);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment