mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-07-03 18:47:59 +02:00
Initial commit
Functional, without SSO
This commit is contained in:
33
sources/lib/AdService/SiteConfigFactory.php
Normal file
33
sources/lib/AdService/SiteConfigFactory.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace AdService;
|
||||
|
||||
class SiteConfigFactory
|
||||
{
|
||||
protected static $instances;
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param bool $singleton en général, c'est la même config pour tous.
|
||||
* @return \AdService\SiteConfig\AbstractSiteConfig
|
||||
*/
|
||||
public static function factory($url, $singleton=true)
|
||||
{
|
||||
if (false !== strpos($url, "leboncoin.fr")) {
|
||||
$className = 'AdService\SiteConfig\Lbc';
|
||||
} elseif (false !== strpos($url, "olx.ua")) {
|
||||
$className = 'AdService\SiteConfig\Olx';
|
||||
} elseif (false !== strpos($url, "www.seloger.com")) {
|
||||
$className = 'AdService\SiteConfig\Seloger';
|
||||
} else {
|
||||
throw new Exception("No config found");
|
||||
}
|
||||
if ($singleton) {
|
||||
if (!isset(self::$instances[$className])) {
|
||||
self::$instances[$className] = new $className;
|
||||
}
|
||||
return self::$instances[$className];
|
||||
}
|
||||
return new $className;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user