Skip to content

Commit 5441be7

Browse files
committed
Merge branch '1.5' into 1.6
2 parents 3902b4a + ed08f53 commit 5441be7

File tree

11 files changed

+296
-14
lines changed

11 files changed

+296
-14
lines changed

config/doctrine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
| Configure meta-data, query and result caching here.
157157
| Optionally you can enable second level caching.
158158
|
159-
| Available: apc|array|file|memcached|php_file|redis|void
159+
| Available: apc|array|file|illuminate|memcached|php_file|redis|void
160160
|
161161
*/
162162
'cache' => [

src/Configuration/Cache/FileCacheProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Doctrine\Common\Cache\FilesystemCache;
66
use Illuminate\Contracts\Config\Repository;
77
use LaravelDoctrine\ORM\Configuration\Driver;
8+
use function storage_path;
89

910
class FileCacheProvider implements Driver
1011
{
@@ -28,8 +29,10 @@ public function __construct(Repository $config)
2829
*/
2930
public function resolve(array $settings = [])
3031
{
32+
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
33+
3134
return new FilesystemCache(
32-
$this->config->get('cache.stores.file.path', storage_path('framework/cache'))
35+
$path
3336
);
3437
}
3538
}

src/Configuration/Cache/IlluminateCacheProvider.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace LaravelDoctrine\ORM\Configuration\Cache;
44

5+
use const E_USER_DEPRECATED;
56
use Illuminate\Contracts\Cache\Factory;
7+
use InvalidArgumentException;
68
use LaravelDoctrine\ORM\Configuration\Driver;
79

8-
abstract class IlluminateCacheProvider implements Driver
10+
class IlluminateCacheProvider implements Driver
911
{
1012
/**
1113
* @var Factory
@@ -32,8 +34,18 @@ public function __construct(Factory $cache)
3234
*/
3335
public function resolve(array $settings = [])
3436
{
37+
$store = $this->store ?? $settings['store'] ?? null;
38+
39+
if ($store === null) {
40+
throw new InvalidArgumentException('Please specify the `store` when using the "illuminate" cache driver.');
41+
}
42+
43+
if ($this->store && isset($settings['store'])) {
44+
trigger_error('Using driver "' . $this->store . '" with a custom store is deprecated. Please use the "illuminate" driver.', E_USER_DEPRECATED);
45+
}
46+
3547
return new IlluminateCacheAdapter(
36-
$this->cache->store($this->store)
48+
$this->cache->store($store)
3749
);
3850
}
3951
}

src/Configuration/Cache/PhpFileCacheProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public function __construct(Repository $config)
2929
*/
3030
public function resolve(array $settings = [])
3131
{
32+
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
33+
3234
return new PhpFileCache(
33-
$this->config->get('cache.stores.file.path', storage_path('framework/cache'))
35+
$path
3436
);
3537
}
3638
}

src/Configuration/Connections/MasterSlaveConnection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public function resolve(array $settings = [])
5151
$resolvedSettings['serverVersion'] = $settings['serverVersion'];
5252
}
5353

54+
if (!empty($settings['defaultTableOptions'])) {
55+
$resolvedSettings['defaultTableOptions'] = $settings['defaultTableOptions'];
56+
}
57+
5458
return $resolvedSettings;
5559
}
5660

src/EntityManagerFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,10 @@ private function applyNamedCacheConfiguration($cacheName)
360360
$defaultDriver = $this->config->get('doctrine.cache.default', 'array');
361361
$defaultNamespace = $this->config->get('doctrine.cache.namespace');
362362

363-
$driver = $this->config->get('doctrine.cache.' . $cacheName . '.driver', $defaultDriver);
363+
$settings = $this->config->get('doctrine.cache.' . $cacheName, []);
364+
$driver = $settings['driver'] ?? $defaultDriver;
364365

365-
$cache = $this->cache->driver($driver);
366+
$cache = $this->cache->driver($driver, $settings);
366367

367368
if ($namespace = $this->config->get('doctrine.cache.' . $cacheName . '.namespace', $defaultNamespace)) {
368369
$cache->setNamespace($namespace);

src/Facades/EntityManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @method static \Doctrine\ORM\Cache|null getCache()
2222
* @method static \Doctrine\DBAL\Connection getConnection()
2323
* @method static \Doctrine\ORM\Query\Expr getExpressionBuilder()
24-
* @method statuc \Doctrine\ORM\Utility\IdentifierFlattener getIdentifierFlattener()
24+
* @method static \Doctrine\ORM\Utility\IdentifierFlattener getIdentifierFlattener()
2525
* @method static void beginTransaction()
2626
* @method static mixed transactional(callable $func)
2727
* @method static void commit()

src/Testing/ConfigRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace LaravelDoctrine\ORM\Testing;
44

55
use Illuminate\Contracts\Config\Repository;
6+
use Illuminate\Support\Arr;
67

78
class ConfigRepository implements Repository
89
{
@@ -23,7 +24,7 @@ public function all()
2324

2425
public function get($key, $default = null)
2526
{
26-
return $this->items[$key] ?? $default;
27+
return Arr::get($this->items, $key, $default);
2728
}
2829

2930
public function set($key, $value = null)

src/Testing/FactoryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function create(array $attributes = [])
115115

116116
if ($this->amount === 1) {
117117
$manager->persist($results);
118-
$this->callAfterCreating(collect($results));
118+
$this->callAfterCreating(collect([$results]));
119119
} else {
120120
foreach ($results as $result) {
121121
$manager->persist($result);

tests/Configuration/Connections/MasterSlaveConnectionTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ private function getInputConfig()
8989
'port' => 3309
9090
],
9191
],
92-
'serverVersion' => '5.8',
92+
'serverVersion' => '5.8',
93+
'defaultTableOptions' => [
94+
'charset' => 'utf8mb4',
95+
'collate' => 'utf8mb4_unicode_ci',
96+
]
9397
];
9498
}
9599

@@ -136,6 +140,10 @@ private function getExpectedConfig()
136140
'unix_socket' => 'unix_socket',
137141
'prefix' => 'prefix'
138142
],
143+
'defaultTableOptions' => [
144+
'charset' => 'utf8mb4',
145+
'collate' => 'utf8mb4_unicode_ci',
146+
],
139147
];
140148
}
141149

@@ -221,6 +229,11 @@ private function getOracleExpectedConfig()
221229
$expectedConfigOracle['master']['user'] = 'homestead1';
222230
$expectedConfigOracle['serverVersion'] = '5.8';
223231

232+
$expectedConfigOracle['defaultTableOptions'] = [
233+
'charset' => 'utf8mb4',
234+
'collate' => 'utf8mb4_unicode_ci',
235+
];
236+
224237
return $expectedConfigOracle;
225238
}
226239

@@ -239,6 +252,11 @@ private function getPgsqlExpectedConfig()
239252
$expectedConfigPgsql['slaves'][1]['sslmode'] = 'sslmode';
240253
$expectedConfigPgsql['serverVersion'] = '5.8';
241254

255+
$expectedConfigPgsql['defaultTableOptions'] = [
256+
'charset' => 'utf8mb4',
257+
'collate' => 'utf8mb4_unicode_ci',
258+
];
259+
242260
return $expectedConfigPgsql;
243261
}
244262

@@ -276,7 +294,11 @@ private function getSqliteExpectedConfig()
276294
'memory' => true,
277295
'path' => ':memory',
278296
],
279-
'serverVersion' => '5.8',
297+
'serverVersion' => '5.8',
298+
'defaultTableOptions' => [
299+
'charset' => 'utf8mb4',
300+
'collate' => 'utf8mb4_unicode_ci',
301+
]
280302
];
281303
}
282304

0 commit comments

Comments
 (0)