forked from sonata-project/SonataGoutteBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManager.php
58 lines (45 loc) · 1.48 KB
/
Manager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* This file is part of the Sonata project.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\GoutteBundle;
use Sonata\GoutteBundle\Goutte\Client;
use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\CookieJar;
class Manager
{
protected $client_configurations = array();
public function getNamedClient($name)
{
$configuration = $this->getClientConfiguration($name);
if(!$configuration) {
return false;
}
return $this->getClient($configuration['config'], $configuration['server']);
}
public function addClientConfiguration($name, $config)
{
$this->client_configurations[$name] = $config;
}
public function getClient(array $zendConfig = array(), array $server = array(), History $history = null, CookieJar $cookieJar = null)
{
return new Client($zendConfig, $server, $history, $cookieJar);
}
public function setClientConfiguration($client_configurations)
{
$this->client_configurations = $client_configurations;
}
public function getClientConfigurations()
{
return $this->client_configurations;
}
public function getClientConfiguration($name)
{
return isset($this->client_configurations[$name]) ? $this->client_configurations[$name] : false;
}
}