Add configuration for session, add Odan Session classes.
This commit is contained in:
parent
c5feb240c3
commit
d6bb157b73
4
app/.phpactor.json
Normal file
4
app/.phpactor.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "/phpactor.schema.json",
|
||||||
|
"prophecy.enabled": true
|
||||||
|
}
|
@ -10,8 +10,8 @@
|
|||||||
"league/flysystem": "^3.27",
|
"league/flysystem": "^3.27",
|
||||||
"league/config": "^1.2",
|
"league/config": "^1.2",
|
||||||
"monolog/monolog": "^3.6",
|
"monolog/monolog": "^3.6",
|
||||||
"middlewares/php-session": "^3.1",
|
"slim/flash": "^0.4.0",
|
||||||
"slim/flash": "^0.4.0"
|
"odan/session": "^6.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^11.1",
|
"phpunit/phpunit": "^11.1",
|
||||||
|
56
app/composer.lock
generated
56
app/composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2b7ce82429ac8209451138f3a4803fd0",
|
"content-hash": "ef0dabb2ed1f62b79526b77f3db35cd4",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "dflydev/dot-access-data",
|
"name": "dflydev/dot-access-data",
|
||||||
@ -819,6 +819,60 @@
|
|||||||
},
|
},
|
||||||
"time": "2018-02-13T20:26:39+00:00"
|
"time": "2018-02-13T20:26:39+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "odan/session",
|
||||||
|
"version": "6.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/odan/session.git",
|
||||||
|
"reference": "b30e66903ab2cfa012c1d6c49b9bb11caa4c9f57"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/odan/session/zipball/b30e66903ab2cfa012c1d6c49b9bb11caa4c9f57",
|
||||||
|
"reference": "b30e66903ab2cfa012c1d6c49b9bb11caa4c9f57",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^8.0",
|
||||||
|
"psr/http-message": "^1",
|
||||||
|
"psr/http-server-handler": "^1",
|
||||||
|
"psr/http-server-middleware": "^1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3",
|
||||||
|
"middlewares/utils": "^3",
|
||||||
|
"nyholm/psr7": "^1.5",
|
||||||
|
"phpstan/phpstan": "^1",
|
||||||
|
"phpunit/phpunit": "^7 || ^8 || ^9 || ^10",
|
||||||
|
"squizlabs/php_codesniffer": "^3",
|
||||||
|
"symfony/console": "6.0.*",
|
||||||
|
"symfony/event-dispatcher": "6.0.*",
|
||||||
|
"symfony/filesystem": "6.0.*",
|
||||||
|
"symfony/finder": "6.0.*"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Odan\\Session\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "A Slim session handler",
|
||||||
|
"homepage": "https://github.com/odan/session",
|
||||||
|
"keywords": [
|
||||||
|
"session",
|
||||||
|
"slim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/odan/session/issues",
|
||||||
|
"source": "https://github.com/odan/session/tree/6.1.0"
|
||||||
|
},
|
||||||
|
"time": "2023-01-22T10:40:26+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "php-di/invoker",
|
"name": "php-di/invoker",
|
||||||
"version": "2.3.4",
|
"version": "2.3.4",
|
||||||
|
@ -7,6 +7,7 @@ use Slim\Factory\AppFactory;
|
|||||||
|
|
||||||
use League\Config\Configuration;
|
use League\Config\Configuration;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
use DI\Container;
|
use DI\Container;
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
|
|
||||||
@ -16,11 +17,15 @@ use Slim\Views\TwigMiddleware;
|
|||||||
use Slovocast\Routes;
|
use Slovocast\Routes;
|
||||||
use Slovocast\Configuration\SiteInformationSchema;
|
use Slovocast\Configuration\SiteInformationSchema;
|
||||||
use Slovocast\Configuration\DatabaseConnectionSchema;
|
use Slovocast\Configuration\DatabaseConnectionSchema;
|
||||||
|
use Slovocast\Configuration\SessionSchema;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Monolog\Level;
|
use Monolog\Level;
|
||||||
|
use Odan\Session\PhpSession;
|
||||||
|
use Odan\Session\SessionInterface;
|
||||||
|
use Odan\Session\SessionManagerInterface;
|
||||||
|
|
||||||
class Bootstrap
|
class Bootstrap
|
||||||
{
|
{
|
||||||
@ -36,6 +41,7 @@ class Bootstrap
|
|||||||
// set all configuration details
|
// set all configuration details
|
||||||
$config->addSchema('site', SiteInformationSchema::getSchema());
|
$config->addSchema('site', SiteInformationSchema::getSchema());
|
||||||
$config->addSchema('database', DatabaseConnectionSchema::getSchema());
|
$config->addSchema('database', DatabaseConnectionSchema::getSchema());
|
||||||
|
$config->addSchema('session', SessionSchema::getSchema());
|
||||||
|
|
||||||
$config->merge([
|
$config->merge([
|
||||||
'site' => [
|
'site' => [
|
||||||
@ -45,6 +51,9 @@ class Bootstrap
|
|||||||
'podcast', 'hosting', 'indie', 'independent', 'easy'
|
'podcast', 'hosting', 'indie', 'independent', 'easy'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'session' => [
|
||||||
|
'name' => 'slovocast'
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
@ -74,6 +83,13 @@ class Bootstrap
|
|||||||
new StreamHandler(__DIR__ . '/var/logs', Level::Warning)
|
new StreamHandler(__DIR__ . '/var/logs', Level::Warning)
|
||||||
);
|
);
|
||||||
return $logger;
|
return $logger;
|
||||||
|
},
|
||||||
|
SessionManagerInterface::class => function (ContainerInterface $container) {
|
||||||
|
return $container->get(SessionInterface::class);
|
||||||
|
},
|
||||||
|
SessionInterface::class => function (ContainerInterface $container) {
|
||||||
|
$options = $container->get('config')->get('session');
|
||||||
|
return new PhpSession($options);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -18,5 +18,4 @@ class DatabaseConnectionSchema
|
|||||||
'password' => Expect::string()->nullable()
|
'password' => Expect::string()->nullable()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
22
app/src/Configuration/SessionSchema.php
Normal file
22
app/src/Configuration/SessionSchema.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Slovocast\Configuration;
|
||||||
|
|
||||||
|
use Nette\Schema\Expect;
|
||||||
|
use Nette\Schema\Schema;
|
||||||
|
|
||||||
|
class SessionSchema
|
||||||
|
{
|
||||||
|
public static function getSchema(): Schema
|
||||||
|
{
|
||||||
|
return Expect::structure([
|
||||||
|
'name' => Expect::string()->default('slovocast'),
|
||||||
|
'lifetime' => Expect::int()->min(0)->max(65535)->default(7200),
|
||||||
|
'path' => Expect::string()->nullable(),
|
||||||
|
'domain' => Expect::string()->nullable(),
|
||||||
|
'secure' => Expect::bool()->default(false),
|
||||||
|
'httponly' => Expect::bool()->default(false),
|
||||||
|
'cache_limiter' => Expect::string()->nullable()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
15
app/src/Controller/Channel/CreateChannelPage.php
Normal file
15
app/src/Controller/Channel/CreateChannelPage.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Slovocast\Controller\Channel;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Slovocast\Controller\Controller;
|
||||||
|
|
||||||
|
class CreateChannelPage extends Controller
|
||||||
|
{
|
||||||
|
public function respond(): Response
|
||||||
|
{
|
||||||
|
// set up the form key
|
||||||
|
return $this->render('channel/create.twig');
|
||||||
|
}
|
||||||
|
}
|
@ -86,15 +86,15 @@ class Channel
|
|||||||
$props['explicit'] ?? false
|
$props['explicit'] ?? false
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($props['id']) {
|
if (isset($props['id'])) {
|
||||||
$channel->setId($props['id']);
|
$channel->setId($props['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($props['createdAt']) {
|
if (isset($props['createdAt'])) {
|
||||||
$channel->setCreatedAt($props['createdAt']);
|
$channel->setCreatedAt($props['createdAt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($props['updatedAt']) {
|
if (isset($props['updatedAt'])) {
|
||||||
$channel->setUpdatedAt($props['updatedAt']);
|
$channel->setUpdatedAt($props['updatedAt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,15 +55,15 @@ class User
|
|||||||
{
|
{
|
||||||
$user = new self($props['email'], $props['password'], $props['name']);
|
$user = new self($props['email'], $props['password'], $props['name']);
|
||||||
|
|
||||||
if (array_key_exists('id', $props)) {
|
if (isset($props['id'])) {
|
||||||
$user->setId($props['id']);
|
$user->setId($props['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('createdAt', $props)) {
|
if (isset($props['createdAt'])) {
|
||||||
$user->setCreatedAt($props['createdAt']);
|
$user->setCreatedAt($props['createdAt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('updatedAt', $props)) {
|
if (isset($props['updatedAt'])) {
|
||||||
$user->setUpdatedAt($props['updatedAt']);
|
$user->setUpdatedAt($props['updatedAt']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
app/templates/channel/create.twig
Normal file
28
app/templates/channel/create.twig
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'layouts/skeleton.twig' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div>
|
||||||
|
<form action="/channel/create" method="post">
|
||||||
|
<input name="form_key" type="hidden" value="{{ form_key }}">
|
||||||
|
<div>
|
||||||
|
<label for="name">Name<br>
|
||||||
|
<input name="name" type="text" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="email">Email<br>
|
||||||
|
<input name="email" type="text" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="password">Password<br>
|
||||||
|
<input name="password" type="password" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="check_password">Confirm Password<br>
|
||||||
|
<input name="check_password" type="password" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="submit" label="Submit">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user