Skip to content

Commit 8e69257

Browse files
committed
Moved default CacheAdvice from Porter -> ImportSpecification.
1 parent b382023 commit 8e69257

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/Porter.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class Porter
3535
*/
3636
private $providerFactory;
3737

38-
/**
39-
* @var CacheAdvice
40-
*/
41-
private $defaultCacheAdvice;
42-
4338
/**
4439
* @var int
4540
*/
@@ -50,11 +45,6 @@ class Porter
5045
*/
5146
private $fetchExceptionHandler;
5247

53-
public function __construct()
54-
{
55-
$this->defaultCacheAdvice = CacheAdvice::SHOULD_NOT_CACHE();
56-
}
57-
5848
/**
5949
* Imports data according to the design of the specified import specification.
6050
*
@@ -108,7 +98,7 @@ private function fetch(ProviderResource $resource, CacheAdvice $cacheAdvice = nu
10898
{
10999
$provider = $this->getProvider($resource->getProviderClassName(), $resource->getProviderTag());
110100

111-
$this->applyCacheAdvice($provider, $cacheAdvice ?: $this->defaultCacheAdvice);
101+
$this->applyCacheAdvice($provider, $cacheAdvice);
112102

113103
if (($records = \ScriptFUSION\Retry\retry(
114104
$this->getMaxFetchAttempts(),

src/Specification/ImportSpecification.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ class ImportSpecification
2626
private $context;
2727

2828
/**
29-
* @var CacheAdvice
29+
* @var CacheAdvice|null
3030
*/
3131
private $cacheAdvice;
3232

33+
/**
34+
* @var CacheAdvice
35+
*/
36+
private $defaultCacheAdvice;
37+
3338
public function __construct(ProviderResource $resource)
3439
{
3540
$this->resource = $resource;
41+
3642
$this->clearTransformers();
43+
$this->defaultCacheAdvice = CacheAdvice::SHOULD_NOT_CACHE();
3744
}
3845

3946
public function __clone()
@@ -141,7 +148,7 @@ final public function setContext($context)
141148
*/
142149
final public function getCacheAdvice()
143150
{
144-
return $this->cacheAdvice;
151+
return $this->cacheAdvice ?: $this->defaultCacheAdvice;
145152
}
146153

147154
/**

0 commit comments

Comments
 (0)