Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
- Remove unused classes/services
- Use `::class` constant whenever possible
- Remove debug statements
  • Loading branch information
weierophinney committed Aug 10, 2015
1 parent 808506b commit 1630c23
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
2 changes: 0 additions & 2 deletions config/autoload/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
'factories' => [
'http' => 'Mwop\Factory\HttpClient',
'mail.transport' => 'Mwop\Factory\MailTransport',
'renderer' => 'Mwop\Factory\Renderer',
'session' => 'Mwop\Factory\Session',
'Mwop\Auth\AuthCallback' => 'Mwop\Auth\AuthCallbackFactory',
'Mwop\Auth\Auth' => 'Mwop\Auth\AuthFactory',
Expand All @@ -145,7 +144,6 @@
'Mwop\Job\Middleware' => 'Mwop\Job\MiddlewareFactory',
'Mwop\ResumePage' => 'Mwop\Factory\PageFactory',
'Mwop\Site' => 'Zend\Expressive\Container\ApplicationFactory',
'Mwop\Templated' => 'Mwop\Factory\Templated',
'Mwop\Template\TemplateInterface' => 'Mwop\Template\MustacheTemplateFactory',
'Mwop\Unauthorized' => 'Mwop\Factory\Unauthorized',
],
Expand Down
12 changes: 6 additions & 6 deletions src/Blog/MiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ public function __invoke($services)
{
$blog = AppFactory::create($services);

$blog->get('/tag/php.xml', 'Mwop\Blog\FeedMiddleware')
$blog->get('/tag/php.xml', FeedMiddleware::class)
->setOptions([
'values' => [
'tag' => 'php',
'type' => 'rss',
],
]);

$blog->get('/tag/{tag}/{type}.xml', 'Mwop\Blog\FeedMiddleware')
$blog->get('/tag/{tag}/{type}.xml', FeedMiddleware::class)
->setOptions([
'tokens' => [
'tag' => '[^/]+',
'type' => '(atom|rss)',
],
]);

$blog->get('/tag/{tag}', 'Mwop\Blog\ListPostsMiddleware')
$blog->get('/tag/{tag}', ListPostsMiddleware::class)
->setOptions([
'tokens' => [
'tag' => '[^/]+',
],
]);

$blog->get('/{type}.xml', 'Mwop\Blog\FeedMiddleware')
$blog->get('/{type}.xml', FeedMiddleware::class)
->setOptions([
'tokens' => [
'type' => '(atom|rss)',
],
]);

$blog->get('/{id}.html', 'Mwop\Blog\DisplayPostMiddleware')
$blog->get('/{id}.html', DisplayPostMiddleware::class)
->setOptions([
'tokens' => [
'id' => '[^/]',
Expand All @@ -54,7 +54,7 @@ public function __invoke($services)
return $next($req, $res, $next, 405);
}

$middleware = $services->get('Mwop\Blog\ListPostsMiddleware');
$middleware = $services->get(ListPostsMiddleware::class);
return $middleware($req, $res, $next);
});

Expand Down
3 changes: 0 additions & 3 deletions src/ComicsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ class ComicsPage extends Page
{
public function __invoke($request, $response, $next)
{
error_log(sprintf("In %s", __CLASS__));
if (! $request->getAttribute('user', false)) {
error_log('No user present; calling next with error');
return $next($request, $response->withStatus(401), 401);
}

error_log('User found; returning page');
return parent::__invoke($request, $response, $next);
}
}
9 changes: 4 additions & 5 deletions src/Contact/MiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ class MiddlewareFactory
{
public function __invoke($services)
{
error_log(sprintf("In %s", __CLASS__));
$contact = AppFactory::create($services);

$contact->get('', 'Mwop\Contact\LandingPage');
$contact->get('/', 'Mwop\Contact\LandingPage');
$contact->post('/process', 'Mwop\Contact\Process');
$contact->get('/thank-you', 'Mwop\Contact\ThankYouPage');
$contact->get('', LandingPage::class);
$contact->get('/', LandingPage::class);
$contact->post('/process', Process::class);
$contact->get('/thank-you', ThankYouPage::class);

return $contact;
}
Expand Down
17 changes: 0 additions & 17 deletions src/Factory/Renderer.php

This file was deleted.

0 comments on commit 1630c23

Please sign in to comment.