1
|
|
|
<?php |
2
|
|
|
namespace PSB\Persistence\Doctrine1; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use PSB\Core\Persistence\PersistenceConfigurator; |
6
|
|
|
|
7
|
|
|
class Doctrine1PersistenceConfigurator extends PersistenceConfigurator |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* A DSN is essential when the bus attempts to automatically recover from disconnects. |
11
|
|
|
* The DNS formats are as described in the Doctrine documentation. |
12
|
|
|
* |
13
|
|
|
* @see http://doctrine.readthedocs.org/en/latest/en/manual/introduction-to-connections.html |
14
|
|
|
* |
15
|
|
|
* @param string $dsn |
16
|
|
|
* |
17
|
|
|
* @return Doctrine1PersistenceConfigurator |
18
|
|
|
*/ |
19
|
1 |
|
public function useDSN($dsn) |
20
|
|
|
{ |
21
|
1 |
|
$this->settings->set(Doctrine1KnownSettingsEnum::DSN, $dsn); |
22
|
1 |
|
return $this; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* You can also specify a Doctrine_Manager instance. |
27
|
|
|
* If not specified, one will be obtained using Doctrine_Manager::getInstance() |
28
|
|
|
* |
29
|
|
|
* @param \Doctrine_Manager $manager |
30
|
|
|
* |
31
|
|
|
* @return Doctrine1PersistenceConfigurator |
32
|
|
|
*/ |
33
|
1 |
|
public function useManager(\Doctrine_Manager $manager) |
34
|
|
|
{ |
35
|
1 |
|
$this->settings->set(Doctrine1KnownSettingsEnum::MANAGER, $manager); |
36
|
1 |
|
return $this; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* If you're using multiple connections in your application, it's imperative that you specify |
41
|
|
|
* which connection name should be used. Not doing so can render your application useless when |
42
|
|
|
* the bus attempts to automatically recover from disconnects. |
43
|
|
|
* |
44
|
|
|
* @param string $name |
45
|
|
|
* |
46
|
|
|
* @return Doctrine1PersistenceConfigurator |
47
|
|
|
*/ |
48
|
1 |
|
public function useConnectionName($name) |
49
|
|
|
{ |
50
|
1 |
|
$this->settings->set(Doctrine1KnownSettingsEnum::CONNECTION_NAME, $name); |
51
|
1 |
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Instead of passing the connection name, dsn and manager one by one, you can do it in a single step |
56
|
|
|
* by passing a LogicalConnection which is a wrapper to the 3 mentioned before. |
57
|
|
|
* |
58
|
|
|
* @param LogicalConnection $connection |
59
|
|
|
* |
60
|
|
|
* @return Doctrine1PersistenceConfigurator |
61
|
|
|
*/ |
62
|
|
|
public function useLogicalConnection(LogicalConnection $connection) |
63
|
|
|
{ |
64
|
|
|
$this->settings->set(Doctrine1KnownSettingsEnum::LOGICAL_CONNECTION, $connection); |
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $tableName |
70
|
|
|
* |
71
|
|
|
* @return Doctrine1PersistenceConfigurator |
72
|
|
|
*/ |
73
|
1 |
|
public function useOutboxMessagesTableName($tableName) |
74
|
|
|
{ |
75
|
1 |
|
$this->settings->set(Doctrine1KnownSettingsEnum::OUTBOX_MESSAGES_TABLE_NAME, $tableName); |
76
|
1 |
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $tableName |
81
|
|
|
* |
82
|
|
|
* @return Doctrine1PersistenceConfigurator |
83
|
|
|
*/ |
84
|
1 |
|
public function useOutboxEndpointsTableName($tableName) |
85
|
|
|
{ |
86
|
1 |
|
$this->settings->set(Doctrine1KnownSettingsEnum::OUTBOX_ENDPOINTS_TABLE_NAME, $tableName); |
87
|
1 |
|
return $this; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|