Skip to content

Commit 1799dd9

Browse files
author
Cédric Girard
committedJul 31, 2015
Merge pull request #39 from lexik/update_2.7
Update 2.7
2 parents 835bff5 + b6b7875 commit 1799dd9

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed
 

‎.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ php:
77
- 5.6
88

99
env:
10-
- SYMFONY_VERSION=2.3.* DOCTRINE_ORM_VERSION=2.2.* DOCTRINE_BUNDLE_VERSION=1.2.*
11-
- SYMFONY_VERSION=2.6.* DOCTRINE_ORM_VERSION=2.4.* DOCTRINE_BUNDLE_VERSION=1.4.*
12-
- SYMFONY_VERSION=2.7.* DOCTRINE_ORM_VERSION=2.4.* DOCTRINE_BUNDLE_VERSION=1.5.*
10+
- SYMFONY_VERSION=2.7.* DOCTRINE_ORM_VERSION=2.4.* DOCTRINE_BUNDLE_VERSION=1.4.*
1311

1412
before_script:
1513
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update

‎Adapter/DoctrineCurrencyAdapter.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Lexik\Bundle\CurrencyBundle\Adapter;
44

55
use Doctrine\ORM\EntityManager;
6-
use Exception;
76

87
/**
98
* @author Yoann Aparici <y.aparici@lexik.fr>
@@ -47,14 +46,21 @@ public function setManager(EntityManager $manager)
4746
$this->manager = $manager;
4847
}
4948

49+
/**
50+
* {@inheritdoc}
51+
*/
5052
public function offsetExists($index)
5153
{
5254
if (!$this->isInitialized()) {
5355
$this->initialize();
5456
}
57+
5558
return parent::offsetExists($index);
5659
}
5760

61+
/**
62+
* {@inheritdoc}
63+
*/
5864
public function offsetGet($index)
5965
{
6066
if (!$this->isInitialized()) {
@@ -72,10 +78,13 @@ private function isInitialized()
7278
return $this->initialized;
7379
}
7480

81+
/**
82+
* @throws Exception
83+
*/
7584
private function initialize()
7685
{
7786
if (!isset($this->manager)) {
78-
throw new Exception('No ObjectManager set');
87+
throw new \RuntimeException('No ObjectManager set on DoctrineCurrencyAdapter.');
7988
}
8089

8190
$currencies = $this->manager

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add the bunde to your `composer.json` file:
1616
```javascript
1717
require: {
1818
// ...
19-
"lexik/currency-bundle": "1.1.*"
19+
"lexik/currency-bundle": "~2.0"
2020
// ...
2121
}
2222
```

‎Resources/config/adapters.xml

+7-19
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,23 @@
2929
<!-- Adapters -->
3030
<service id="lexik_currency.abstract_adapter" class="%lexik_currency.abstract_adapter.class%" abstract="true" />
3131

32-
<service id="lexik_currency.doctrine_adapter"
33-
class="%lexik_currency.doctrine_adapter.class%"
34-
parent="lexik_currency.abstract_adapter"
35-
factory-service="lexik_currency.adapter_factory"
36-
factory-method="createDoctrineAdapter"
37-
>
32+
<service id="lexik_currency.doctrine_adapter" class="%lexik_currency.doctrine_adapter.class%" parent="lexik_currency.abstract_adapter">
33+
<factory service="lexik_currency.adapter_factory" method="createDoctrineAdapter" />
3834
<argument>%lexik_currency.doctrine_adapter.class%</argument>
3935
<argument>%lexik_currency.doctrine.orm.entity_manager%</argument>
4036
<tag name="lexik_currency.adapter" alias="doctrine_currency_adapter" />
4137
</service>
4238

43-
<service id="lexik_currency.ecb_adapter"
44-
class="%lexik_currency.ecb_adapter.class%"
45-
parent="lexik_currency.abstract_adapter"
46-
factory-service="lexik_currency.adapter_factory"
47-
factory-method="createEcbAdapter"
48-
>
39+
<service id="lexik_currency.ecb_adapter" class="%lexik_currency.ecb_adapter.class%" parent="lexik_currency.abstract_adapter">
40+
<factory service="lexik_currency.adapter_factory" method="createEcbAdapter" />
4941
<call method="setEcbUrl">
5042
<argument>%lexik_currency.ecb_url%</argument>
5143
</call>
5244
<tag name="lexik_currency.adapter" alias="ecb_currency_adapter" />
5345
</service>
5446

55-
<service id="lexik_currency.oer_adapter"
56-
class="%lexik_currency.oer_adapter.class%"
57-
parent="lexik_currency.abstract_adapter"
58-
factory-service="lexik_currency.adapter_factory"
59-
factory-method="createOerAdapter"
60-
>
47+
<service id="lexik_currency.oer_adapter" class="%lexik_currency.oer_adapter.class%" parent="lexik_currency.abstract_adapter">
48+
<factory service="lexik_currency.adapter_factory" method="createOerAdapter" />
6149
<call method="setOerUrl">
6250
<argument>%lexik_currency.oer_url%</argument>
6351
</call>
@@ -68,4 +56,4 @@
6856
</service>
6957
</services>
7058

71-
</container>
59+
</container>

‎Tests/Unit/Adapter/AdapterFactoryTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function testCreateDoctrineAdapter()
4040
$this->assertInstanceOf('Lexik\Bundle\CurrencyBundle\Adapter\DoctrineCurrencyAdapter', $adapter);
4141
$this->assertEquals('USD', $adapter->getDefaultCurrency());
4242
$this->assertEquals(array('EUR'), $adapter->getManagedCurrencies());
43+
$this->assertEquals(0, count($adapter));
44+
45+
$adapter['USD']; // force initialization
4346
$this->assertEquals(2, count($adapter));
4447
}
4548
}

‎composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.2",
20-
"symfony/framework-bundle": "~2.3"
20+
"symfony/framework-bundle": "~2.7"
2121
},
2222
"autoload": {
23-
"psr-0": { "Lexik\\Bundle\\CurrencyBundle": "" }
24-
},
25-
"target-dir": "Lexik/Bundle/CurrencyBundle"
23+
"psr-4": { "Lexik\\Bundle\\CurrencyBundle\\": "" }
24+
}
2625
}

0 commit comments

Comments
 (0)
Please sign in to comment.