-
Notifications
You must be signed in to change notification settings - Fork 6
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
2 changed files
with
71 additions
and
45 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 |
---|---|---|
@@ -1,49 +1,5 @@ | ||
<?php | ||
|
||
use Punkstar\RugbyFeed\DataManager; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$config = ['debug' => true]; | ||
|
||
$app = new Silex\Application($config); | ||
|
||
$app->mount('/fixtures', new \Punkstar\RugbyFeedService\Controller\FixtureController()); | ||
$app->mount('/table', new \Punkstar\RugbyFeedService\Controller\TableController()); | ||
|
||
$app->get('/', function () { | ||
$links = []; | ||
|
||
$data = new DataManager(); | ||
$leagues = $data->getLeagues(); | ||
|
||
foreach ($leagues as $league) { | ||
$fixtures_url = 'fixtures/' . $league->getUrlKey(); | ||
$table_url = 'table/' . $league->getUrlKey(); | ||
|
||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$fixtures_url, | ||
$fixtures_url | ||
); | ||
|
||
foreach ($league->getTeams() as $team) { | ||
$team_url = 'fixtures/' . $league->getUrlKey() . '/' . $team->getUrlKey(); | ||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$team_url, | ||
$team_url | ||
); | ||
} | ||
|
||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$table_url, | ||
$table_url | ||
); | ||
} | ||
|
||
return "<h1>Available Resources</h1> " . implode("\n", $links); | ||
}); | ||
|
||
$app->run(); | ||
(new \Punkstar\RugbyFeedService\App())->getApp()->run(); |
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,70 @@ | ||
<?php | ||
|
||
namespace Punkstar\RugbyFeedService; | ||
|
||
use League\Fractal\Manager; | ||
use League\Fractal\Resource\Collection; | ||
use League\Fractal\Serializer\JsonApiSerializer; | ||
use Punkstar\RugbyFeed\DataManager; | ||
use Punkstar\RugbyFeed\FixtureSet; | ||
use Punkstar\RugbyFeed\League\Aviva; | ||
use Punkstar\RugbyFeed\League\Pro14; | ||
use Punkstar\RugbyFeedService\Transformer\FixtureTransformer; | ||
use Silex\Application; | ||
use Silex\ControllerProviderInterface; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class App | ||
{ | ||
protected $app; | ||
|
||
public function __construct() | ||
{ | ||
$config = ['debug' => true]; | ||
|
||
$this->app = new Application($config); | ||
|
||
$this->app->mount('/fixtures', new Controller\FixtureController()); | ||
$this->app->mount('/table', new Controller\TableController()); | ||
|
||
$this->app->get('/', function () { | ||
$links = []; | ||
|
||
$data = new DataManager(); | ||
$leagues = $data->getLeagues(); | ||
|
||
foreach ($leagues as $league) { | ||
$fixtures_url = 'fixtures/' . $league->getUrlKey(); | ||
$table_url = 'table/' . $league->getUrlKey(); | ||
|
||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$fixtures_url, | ||
$fixtures_url | ||
); | ||
|
||
foreach ($league->getTeams() as $team) { | ||
$team_url = 'fixtures/' . $league->getUrlKey() . '/' . $team->getUrlKey(); | ||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$team_url, | ||
$team_url | ||
); | ||
} | ||
|
||
$links[] = sprintf( | ||
'<li><a href="%s">%s</a></li>', | ||
$table_url, | ||
$table_url | ||
); | ||
} | ||
|
||
return "<h1>Available Resources</h1> " . implode("\n", $links); | ||
}); | ||
} | ||
|
||
public function getApp() | ||
{ | ||
return $this->app; | ||
} | ||
} |