Skip to content

Commit

Permalink
Merge branch 'release/REl-0.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Hare committed Dec 31, 2015
2 parents 2201536 + 28dac56 commit 05ac2b2
Show file tree
Hide file tree
Showing 72 changed files with 1,029 additions and 498 deletions.
File renamed without changes.
181 changes: 63 additions & 118 deletions app/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// DIC configuration

$container = $app->getContainer();
$injector = new \pavlakis\seaudi\Injector($container);


$container['notFoundHandler'] = function ($c) {
return function ($request, $response) use ($c) {
Expand All @@ -14,17 +16,17 @@

/* ---------- Configs ------------ */

$container['events.config'] = function ($c) {
$container['PHPMinds\Config\EventsConfig'] = function ($c) {

return new App\Config\EventsConfig($c->get('settings')['events']);
return new PHPMinds\Config\EventsConfig($c->get('settings')['events']);

};


$container['meetup.config'] = function ($c) {
$meetup = $c->get('settings')['meetups'];

return new App\Config\MeetupConfig([
return new PHPMinds\Config\MeetupConfig([
'apiKey' => $meetup['apiKey'],
'baseUrl' => $meetup['baseUrl'],
'groupUrlName' => $meetup['PHPMinds']['group_urlname'],
Expand All @@ -36,7 +38,7 @@
$container['joindin.config'] = function ($c) {
$joindin = $c->get('settings')['joindin'];

return new App\Config\JoindinConfig([
return new PHPMinds\Config\JoindinConfig([
'apiKey' => $joindin['key'],
'baseUrl' => $joindin['baseUrl'],
'frontendBaseUrl' => $joindin['frontendBaseUrl'],
Expand All @@ -46,40 +48,53 @@
};

$container['meetup.event'] = function ($c) {
return new \App\Model\MeetupEvent($c->get('meetup.config'));
return new \PHPMinds\Model\MeetupEvent($c->get('meetup.config'));
};

$container['joindin.event'] = function ($c) {

return new \App\Model\JoindinEvent(
$c->get('joindin.config'), $c->get('file.repository')
return new \PHPMinds\Model\JoindinEvent(
$c->get('joindin.config'), $c->get('PHPMinds\Repository\FileRepository')
);
};


$container['parsedown'] = function($c)
{
return new Parsedown();
};

$container['service.joindin'] = function ($c) {
return new \App\Service\JoindinService($c->get('http.client'), $c->get('joindin.event'));
return new \PHPMinds\Service\JoindinService($c->get('http.client'), $c->get('joindin.event'));
};

$container['service.meetup'] = function ($c) {
return new \App\Service\MeetupService($c->get('http.client'), $c->get('meetup.event'));

return new \PHPMinds\Service\MeetupService(
\DMS\Service\Meetup\MeetupKeyAuthClient::factory(
[
'key' => $c->get('meetup.config')->apiKey,
'base_url' => $c->get('meetup.config')->baseUrl,
'group_urlname' => $c->get('meetup.config')->groupUrlName,
'publish_status' => $c->get('meetup.config')->publishStatus
]
),
$c->get('meetup.event'),
$c->get('meetup.config')
);
};


$container['service.content'] = function ($c) {
$container['PHPMinds\Service\ContentService'] = function ($c) {
$content = $c->get('settings')['content-folder'];
return new \App\Service\ContentService($c->get('parsedown'),$content['location']);
return new \PHPMinds\Service\ContentService($c->get('parsedown'),$content['location']);
};

$container['service.event'] = function ($c) {
return new \App\Service\EventsService(
$container['PHPMinds\Service\EventsService'] = function ($c) {
return new \PHPMinds\Service\EventsService(
$c->get('service.meetup'),
$c->get('service.joindin'),
$c->get('event.manager')
$c->get('PHPMinds\Model\Event\EventManager')
);
};

Expand All @@ -88,58 +103,47 @@
return new \GuzzleHttp\Client();
};

$container['cache'] = function () {
$container['Slim\HttpCache\CacheProvider'] = function () {
return new \Slim\HttpCache\CacheProvider();
};

$container ['db'] = function ($c) {
$container ['PHPMinds\Model\Db'] = function ($c) {
$db = $c->get('settings')['db'];

return new \App\Model\Db (
return new \PHPMinds\Model\Db (
'mysql:host=' . $db['host'] . ';dbname=' . $db['dbname'], $db['username'], $db['password']
);
};

// Repositories

$container['file.repository'] = function ($c) {
return new \App\Repository\FileRepository(
$container['PHPMinds\Repository\FileRepository'] = function ($c) {
return new \PHPMinds\Repository\FileRepository(
$c->get('settings')['file_store']['path']
);
};

$container['users.repository'] = function ($c) {
return new \App\Repository\UsersRepository($c->get('db'));
};

$container['speakers.repository'] = function ($c) {
return new \App\Repository\SpeakersRepository($c->get('db'));
};

$container['events.repository'] = function ($c) {
return new \App\Repository\EventsRepository($c->get('db'));
};

$container['supporters.repository'] = function ($c) {
return new \App\Repository\SupportersRepository($c->get('db'));
};
$injector->add('PHPMinds\Repository\UsersRepository');
$injector->add('PHPMinds\Repository\SpeakersRepository');
$injector->add('PHPMinds\Repository\EventsRepository');
$injector->add('PHPMinds\Repository\SupportersRepository');

// Managers

$container['event.manager'] = function ($c) {
return new \App\Model\Event\EventManager(
$c->get('events.repository'),
$c->get('speakers.repository'),
$c->get('supporters.repository')
$container['PHPMinds\Model\Event\EventManager'] = function ($c) {
return new PHPMinds\Model\Event\EventManager(
$c->get('PHPMinds\Repository\EventsRepository'),
$c->get('PHPMinds\Repository\SpeakersRepository'),
$c->get('PHPMinds\Repository\SupportersRepository')
);
};

$container['auth.middleware'] = function ($c) {
return new App\Middleware\AuthCheck($_SESSION, 'auth', $c->get('settings')['auth-routes']);
$container['PHPMinds\Middleware\AuthCheck'] = function ($c) {
return new PHPMinds\Middleware\AuthCheck($_SESSION, 'auth', $c->get('settings')['auth-routes']);

};

$container['csrf'] = function ($c) {
$container['Slim\Csrf\Guard'] = function ($c) {
$guard = new \Slim\Csrf\Guard();
$guard->setFailureCallable(function ($request, $response, $next) {
$request = $request->withAttribute("csrf_status", false);
Expand All @@ -148,9 +152,9 @@
return $guard;
};

$container['auth.model'] = function ($c) {
return new \App\Model\Auth(
$c->get('users.repository')
$container['PHPMinds\Model\Auth'] = function ($c) {
return new PHPMinds\Model\Auth(
$c->get('PHPMinds\Repository\UsersRepository')
);
};

Expand All @@ -159,7 +163,7 @@
// -----------------------------------------------------------------------------

// Twig
$container['view'] = function ($c) {
$container['Slim\Views\Twig'] = function ($c) {
$settings = $c->get('settings');
$view = new \Slim\Views\Twig($settings['view']['template_path'], $settings['view']['twig']);

Expand All @@ -171,16 +175,14 @@
};

// Flash messages
$container['flash'] = function ($c) {
return new \Slim\Flash\Messages;
};
$injector->add('Slim\Flash\Messages');

// -----------------------------------------------------------------------------
// Service factories
// -----------------------------------------------------------------------------

// monolog
$container['logger'] = function ($c) {
$container['Psr\Log\LoggerInterface'] = function ($c) {
$settings = $c->get('settings');
$logger = new \Monolog\Logger($settings['logger']['name']);
$logger->pushProcessor(new \Monolog\Processor\UidProcessor());
Expand All @@ -192,74 +194,17 @@
// Action factories
// -----------------------------------------------------------------------------

$container['App\Action\HomeAction'] = function ($c) {
return new App\Action\HomeAction(
$c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('service.content'), $c->get('cache')
);
};

$container['App\Action\AdminDashboardAction'] = function ($c) {

return new App\Action\AdminDashboardAction(
$c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('event.manager')
);
};

$container['App\Action\LoginAction'] = function ($c) {

return new App\Action\LoginAction(
$c->get('view'), $c->get('logger'), $c->get('auth.model'), $c->get('csrf')
);
};

$container['App\Action\CreateSpeakerAction'] = function ($c) {

return new App\Action\CreateSpeakerAction(
$c->get('view'), $c->get('logger'), $c->get('speakers.repository')
);
};

$container['App\Action\LogoutAction'] = function ($c) {

return new App\Action\LogoutAction(
$c->get('view'), $c->get('logger'), $c->get('auth.model')
);
};

$container['App\Action\NotFoundAction'] = function ($c) {

return new App\Action\NotFoundAction(
$c->get('view'), $c->get('logger')
);
};


$container['App\Action\CreateEventAction'] = function ($c) {

return new App\Action\CreateEventAction(
$c->get('view'), $c->get('logger'), $c->get('service.event'),
$c->get('csrf'), $c->get('event.manager'), $c->get('events.config'),
$c->get('auth.model'), $c->get('flash')
);
};

$container['App\Action\EventDetailsAction'] = function ($c) {

return new App\Action\EventDetailsAction(
$c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('flash')
);
};

$container['App\Action\CallbackAction'] = function ($c) {

return new App\Action\CallbackAction(
$c->get('logger'), $c->get('auth.model'), $c->get('file.repository')
);
};

$container['App\Action\EventStatusAction'] = function ($c) {

return new App\Action\EventStatusAction(
$c->get('logger'), $c->get('service.event')
);
};
$injector->add('PHPMinds\Action\NotFoundAction');
$injector->add('PHPMinds\Action\HomeAction');
$injector->add('PHPMinds\Action\LoginAction');
$injector->add('PHPMinds\Action\LogoutAction');
$injector->add('PHPMinds\Action\AdminDashboardAction');
$injector->add('PHPMinds\Action\EventDetailsAction');
$injector->add('PHPMinds\Action\CreateSpeakerAction');
$injector->add('PHPMinds\Action\CreateEventAction');
$injector->add('PHPMinds\Action\CallbackAction');
$injector->add('PHPMinds\Action\EventStatusAction');
$injector->add('PHPMinds\Action\PastEventsAction');
8 changes: 3 additions & 5 deletions app/middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
$app->add(new \Slim\HttpCache\Cache('public', 86400));


$app->add($container->get('auth.middleware'));

$app->add($container->get('csrf'));
$app->add($container->get('Slim\Csrf\Guard'));

$app->add($container->get('auth.middleware'));

$app->add(new App\Middleware\CliRequest());
$app->add($container->get('PHPMinds\Middleware\AuthCheck'));

$app->add(new \pavlakis\cli\CliRequest());
26 changes: 14 additions & 12 deletions app/routes.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
<?php
// Routes

$app->get('/', 'App\Action\HomeAction:dispatch')
$app->get('/', 'PHPMinds\Action\HomeAction:dispatch')
->setName('homepage');

$app->get('/login', 'App\Action\LoginAction:dispatch')
$app->get('/login', 'PHPMinds\Action\LoginAction:dispatch')
->setName('login');

$app->post('/login', 'App\Action\LoginAction:dispatch')
$app->post('/login', 'PHPMinds\Action\LoginAction:dispatch')
->setName('login-post');

$app->get('/logout', 'App\Action\LogoutAction:dispatch')
$app->get('/logout', 'PHPMinds\Action\LogoutAction:dispatch')
->setName('logout');

$app->get('/404', 'App\Action\NotFoundAction:dispatch')
$app->get('/404', 'PHPMinds\Action\NotFoundAction:dispatch')
->setName('notfound');

$app->get('/event/{year:[0-9]+}/{month:[0-9]+}','PHPMinds\Action\PastEventsAction:eventByYearMonth')
->setName('pastEvents');

// -- auth --
$app->get('/admin', 'App\Action\AdminDashboardAction:dispatch')
$app->get('/admin', 'PHPMinds\Action\AdminDashboardAction:dispatch')
->setName('dashboard');

$app->get('/create-event', 'App\Action\CreateEventAction:dispatch')
$app->get('/create-event', 'PHPMinds\Action\CreateEventAction:dispatch')
->setName('create-event');

$app->post('/create-event', 'App\Action\CreateEventAction:dispatch')
$app->post('/create-event', 'PHPMinds\Action\CreateEventAction:dispatch')
->setName('create-event-post');

$app->post('/create-speaker', 'App\Action\CreateSpeakerAction:dispatch')
$app->post('/create-speaker', 'PHPMinds\Action\CreateSpeakerAction:dispatch')
->setName('create-speaker');

$app->get('/event-details', 'App\Action\EventDetailsAction:dispatch')
$app->get('/event-details', 'PHPMinds\Action\EventDetailsAction:dispatch')
->setName('event-details');

$app->get('/callback/{callback}', 'App\Action\CallbackAction:dispatch')
$app->get('/callback/{callback}', 'PHPMinds\Action\CallbackAction:dispatch')
->setName('calbacks');

$app->get('/status', 'App\Action\EventStatusAction:dispatch')
$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch')
->setName('status');

6 changes: 3 additions & 3 deletions app/src/Action/AdminDashboardAction.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Action;
namespace PHPMinds\Action;

use App\Model\Event\EventManager;
use App\Service\EventsService;
use PHPMinds\Model\Event\EventManager;
use PHPMinds\Service\EventsService;
use Slim\Views\Twig;
use Psr\Log\LoggerInterface;

Expand Down
Loading

0 comments on commit 05ac2b2

Please sign in to comment.