diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..e31efa2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +/.github/ export-ignore +/tests/ export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3f0e413..7c066c4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,7 +10,7 @@ jobs: php-versions: ['8.1', '8.2', '8.3'] fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} @@ -26,7 +26,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -58,13 +58,13 @@ jobs: - name: Archive logs if: ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: logs + name: logs-php-${{ matrix.php-versions }} path: vendor/endroid/quality/application/var/log - name: Archive code coverage results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: coverage + name: coverage-php-${{ matrix.php-versions }} path: tests/coverage diff --git a/src/Controller/TeamCalendarController.php b/src/Controller/TeamCalendarController.php index 4f166cc..f313de6 100644 --- a/src/Controller/TeamCalendarController.php +++ b/src/Controller/TeamCalendarController.php @@ -6,29 +6,21 @@ use Endroid\Calendar\Writer\IcalWriter; use Endroid\SoccerCalendar\Factory\CalendarFactory; -use Endroid\SoccerData\Loader\CompetitionLoaderInterface; -use Endroid\SoccerData\Loader\GameLoaderInterface; use Endroid\SoccerData\Loader\TeamLoaderInterface; use Symfony\Component\HttpFoundation\Response; final class TeamCalendarController { public function __construct( - private readonly CompetitionLoaderInterface $competitionLoader, private readonly TeamLoaderInterface $teamLoader, - private readonly GameLoaderInterface $gameLoader, private readonly CalendarFactory $calendarFactory, private readonly IcalWriter $calendarWriter ) { } - public function __invoke(string $competitionName, string $teamName): Response + public function __invoke(string $identifier): Response { - $competition = $this->competitionLoader->loadByName($competitionName); - $this->teamLoader->loadByCompetition($competition); - $team = $competition->getTeamByName($teamName); - $this->gameLoader->loadByTeam($team); - + $team = $this->teamLoader->load($identifier); $calendar = $this->calendarFactory->createTeamCalendar($team); return new Response($this->calendarWriter->writeToString($calendar, new \DateTimeImmutable(), new \DateTimeImmutable('+1 year')), Response::HTTP_OK, [ diff --git a/src/Controller/TeamListController.php b/src/Controller/TeamListController.php deleted file mode 100644 index c29decb..0000000 --- a/src/Controller/TeamListController.php +++ /dev/null @@ -1,36 +0,0 @@ - */ - private readonly array $competitionNames, - private readonly Environment $templating, - private readonly CompetitionLoaderInterface $competitionLoader, - private readonly TeamLoaderInterface $teamLoader - ) { - } - - public function __invoke(): Response - { - $competitions = []; - foreach ($this->competitionNames as $name) { - $competition = $this->competitionLoader->loadByName($name); - $this->teamLoader->loadByCompetition($competition); - $competitions[] = $competition; - } - - return new Response($this->templating->render('@EndroidSoccerCalendar/team/list.html.twig', [ - 'competitions' => $competitions, - ])); - } -} diff --git a/src/DependencyInjection/EndroidSoccerCalendarExtension.php b/src/DependencyInjection/EndroidSoccerCalendarExtension.php index f903242..6b7ac8b 100644 --- a/src/DependencyInjection/EndroidSoccerCalendarExtension.php +++ b/src/DependencyInjection/EndroidSoccerCalendarExtension.php @@ -4,7 +4,6 @@ namespace Endroid\SoccerCalendarBundle\DependencyInjection; -use Endroid\SoccerCalendarBundle\Controller\TeamListController; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -17,12 +16,9 @@ final class EndroidSoccerCalendarExtension extends Extension public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), $configs); + $processor->processConfiguration(new Configuration(), $configs); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); - - $teamLoaderControllerDefinition = $container->getDefinition(TeamListController::class); - $teamLoaderControllerDefinition->setArgument(0, $config['competition_names']); } } diff --git a/src/Resources/config/routes.yaml b/src/Resources/config/routes.yaml index 0a8fa42..cf85f16 100644 --- a/src/Resources/config/routes.yaml +++ b/src/Resources/config/routes.yaml @@ -1,7 +1,3 @@ soccer_calendar_team_calendar: - path: /{competitionName}/team/{teamName}.ics + path: /team/{identifier}.ics controller: Endroid\SoccerCalendarBundle\Controller\TeamCalendarController - -soccer_calendar_team_list: - path: / - controller: Endroid\SoccerCalendarBundle\Controller\TeamListController diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 214b14c..7194bc3 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -11,12 +11,7 @@ services: Endroid\SoccerCalendar\Factory\CalendarFactory: public: true - Endroid\SoccerData\Vi\Client: ~ - Endroid\SoccerData\Vi\Loader\CompetitionLoader: ~ - Endroid\SoccerData\Vi\Loader\TeamLoader: ~ - Endroid\SoccerData\Vi\Loader\GameLoader: ~ - Endroid\SoccerData\Loader\CompetitionLoaderInterface: '@Endroid\SoccerData\Vi\Loader\CompetitionLoader' - Endroid\SoccerData\Loader\TeamLoaderInterface: '@Endroid\SoccerData\Vi\Loader\TeamLoader' - Endroid\SoccerData\Loader\GameLoaderInterface: '@Endroid\SoccerData\Vi\Loader\GameLoader' + Endroid\SoccerData\Sofascore\Loader\TeamLoader: ~ + Endroid\SoccerData\Loader\TeamLoaderInterface: '@Endroid\SoccerData\Sofascore\Loader\TeamLoader' Endroid\Calendar\Writer\IcalWriter: ~ diff --git a/tests/application/.gitkeep b/tests/application/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/application/tests/Controller/TeamListControllerTest.php b/tests/application/tests/Controller/TeamListControllerTest.php deleted file mode 100644 index 323765e..0000000 --- a/tests/application/tests/Controller/TeamListControllerTest.php +++ /dev/null @@ -1,19 +0,0 @@ -request('GET', '/soccer-calendar/'); - - $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $this->assertStringContainsString('Soccer Calendars', $client->getResponse()->getContent()); - } -}