1: <?php
2:
3: namespace PHPixie\Auth;
4:
5: class Providers
6: {
7: protected $builders;
8:
9: public function __construct($builders = array())
10: {
11: foreach($builders as $builder) {
12: $this->builders[$builder->name()] = $builder;
13: }
14: }
15:
16: public function buildFromConfig($domain, $name, $configData)
17: {
18: $type = $configData->getRequired('type');
19:
20: $split = explode('.', $type, 2);
21: if(count($split) === 2) {
22: $builder = $this->builders[$split[0]];
23: return $builder->buildProvider(
24: $split[1],
25: $domain,
26: $name,
27: $configData
28: );
29: }
30:
31: throw new \PHPixie\Auth\Exception("Provider '$type' does not exist");
32: }
33: }