This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
344 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace Alltube; | ||
|
||
use Alltube\Controller\DownloadController; | ||
use Alltube\Controller\FrontController; | ||
use Alltube\Controller\JsonController; | ||
use Alltube\Exception\ConfigException; | ||
use Alltube\Exception\DependencyException; | ||
use Alltube\Factory\ConfigFactory; | ||
use Alltube\Factory\LocaleManagerFactory; | ||
use Alltube\Factory\LoggerFactory; | ||
use Alltube\Factory\SessionFactory; | ||
use Alltube\Factory\ViewFactory; | ||
use Alltube\Middleware\CspMiddleware; | ||
use Alltube\Middleware\LinkHeaderMiddleware; | ||
use Alltube\Middleware\LocaleMiddleware; | ||
use Alltube\Middleware\RouterPathMiddleware; | ||
use Slim\Container; | ||
use SmartyException; | ||
|
||
class App extends \Slim\App | ||
{ | ||
/** | ||
* App constructor. | ||
* @throws ConfigException | ||
* @throws DependencyException | ||
* @throws SmartyException | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
/** @var Container $container */ | ||
$container = $this->getContainer(); | ||
|
||
// Config. | ||
$container['config'] = ConfigFactory::create($container); | ||
|
||
// Session. | ||
$container['session'] = SessionFactory::create($container); | ||
|
||
// Locales. | ||
$container['locale'] = LocaleManagerFactory::create($container); | ||
|
||
// Smarty. | ||
$container['view'] = ViewFactory::create($container); | ||
|
||
// Logger. | ||
$container['logger'] = LoggerFactory::create($container); | ||
|
||
// Middlewares. | ||
$this->add(new LocaleMiddleware($container)); | ||
$this->add(new CspMiddleware($container)); | ||
$this->add(new LinkHeaderMiddleware($container)); | ||
$this->add(new RouterPathMiddleware($container)); | ||
|
||
// Controllers. | ||
$frontController = new FrontController($container); | ||
$jsonController = new JsonController($container); | ||
$downloadController = new DownloadController($container); | ||
|
||
// Error handling. | ||
$container['errorHandler'] = [$frontController, 'error']; | ||
$container['phpErrorHandler'] = [$frontController, 'error']; | ||
$container['notFoundHandler'] = [$frontController, 'notFound']; | ||
$container['notAllowedHandler'] = [$frontController, 'notAllowed']; | ||
|
||
// Routes. | ||
$this->get( | ||
'/', | ||
[$frontController, 'index'] | ||
)->setName('index'); | ||
|
||
$this->get( | ||
'/extractors', | ||
[$frontController, 'extractors'] | ||
)->setName('extractors'); | ||
|
||
$this->any( | ||
'/info', | ||
[$frontController, 'info'] | ||
)->setName('info'); | ||
|
||
$this->any( | ||
'/watch', | ||
[$frontController, 'info'] | ||
); | ||
|
||
$this->any( | ||
'/download', | ||
[$downloadController, 'download'] | ||
)->setName('download'); | ||
|
||
$this->get( | ||
'/locale/{locale}', | ||
[$frontController, 'locale'] | ||
)->setName('locale'); | ||
|
||
$this->get( | ||
'/json', | ||
[$jsonController, 'json'] | ||
)->setName('json'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.