PHP Classes

File: default_bootstrap.php

Recommend this page to a friend!
  Classes of Jelle Sebreghts   PHP TheSportsDb   default_bootstrap.php   Download  
File: default_bootstrap.php
Role: Configuration script
Content type: text/plain
Description: Configuration script
Class: PHP TheSportsDb
Get game information from the Sports DB site API
Author: By
Last change: Merge branch 'master' of github.com:Jelle-S/TheSportsDb

* 'master' of github.com:Jelle-S/TheSportsDb:
Update README.md
Scrutinizer Auto-Fixes
Date: 7 years ago
Size: 2,319 bytes
 

Contents

Class file image Download
<?php

include_once __DIR__ . '/vendor/autoload.php';

if (!
defined('THESPORTSDB_API_KEY')) {
 
define('THESPORTSDB_API_KEY', '1');
}
if (
 
class_exists('\Symfony\Component\DependencyInjection\ContainerBuilder')
  &&
class_exists('\Symfony\Component\Config\Resource\FileResource')
  &&
class_exists('Symfony\Component\DependencyInjection\Loader\YamlFileLoader')
  &&
class_exists('\HendrichA\TagPassLibrary\TagPass')
) {
 
// Use the dependency injection container if available.
 
include_once __DIR__ . '/default_bootstrap_dic.php';
  return;
}

// Http client.
$httpClient = new GuzzleHttp\Client();

// Factory container.
$factoryContainer = new TheSportsDb\Entity\Factory\FactoryContainer();

// Repository container.
$repositoryContainer = new TheSportsDb\Entity\Repository\RepositoryContainer();

// Property mapper.
$propertyMapper = new FastNorth\PropertyMapper\Mapper();

// Entity manager.
$entityManager = new TheSportsDb\Entity\EntityManager($propertyMapper, $factoryContainer, $repositoryContainer);
$entityManager->registerClass('league');
$entityManager->registerClass('sport');
$entityManager->registerClass('team');
$entityManager->registerClass('event');
$entityManager->registerClass('player');
$entityManager->registerClass('season');

// The sports db client.
$sportsDbClient = new TheSportsDb\Http\TheSportsDbClient(THESPORTSDB_API_KEY, $httpClient);

// Repositories.
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\SportRepository($sportsDbClient, $entityManager));
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\LeagueRepository($sportsDbClient, $entityManager));
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\SeasonRepository($sportsDbClient, $entityManager));
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\EventRepository($sportsDbClient, $entityManager));
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\PlayerRepository($sportsDbClient, $entityManager));
$repositoryContainer->addRepository(new TheSportsDb\Entity\Repository\TeamRepository($sportsDbClient, $entityManager));

// Factory.
$factory = new \TheSportsDb\Entity\Factory\Factory($sportsDbClient, $entityManager);

$factoryContainer->setDefaultFactory($factory);

$db = new TheSportsDb\TheSportsDb($entityManager);