Skip to content

Commit

Permalink
GH-38 - GH-38 - creating BrowserDetector fails when located in vendor
Browse files Browse the repository at this point in the history
- fix copy paste
- fix duplicates
  • Loading branch information
serhiime committed Jul 15, 2019
1 parent a12b7cb commit 884893c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,11 @@ public function getPatternList($list, $type)
protected function init()
{
$dataProvider = $this->options['dataProvider'];
$dataDirectory = $this->findDataDirectory();
$cacheDirectory = $this->findCacheDirectory();

/** @var StorageInterface $dataProvider */
$dataProvider = new $dataProvider();
$dataProvider->setDataDirectory($dataDirectory);
$dataProvider->setCacheDirectory($cacheDirectory);
$dataProvider->setDataDirectory($this->findDataDirectory());
$dataProvider->setCacheDirectory($this->findCacheDirectory());
$dataProvider->setCacheEnabled(true);
$this->setDataProvider($dataProvider);
}
Expand Down Expand Up @@ -184,8 +182,8 @@ private function findDataDirectory(): string
*/
private function findCacheDirectory(): string
{
$cacheDirectory = $this->options['dataDirectory'];
if($this->options['dataDirectory'] === 'auto') {
$cacheDirectory = $this->options['cacheDirectory'];
if($this->options['cacheDirectory'] === 'auto') {
$reflection = new \ReflectionClass(AbstractData::class);
$cacheDirectory = sprintf('%s/var/cache', dirname($reflection->getFileName(),3));
}
Expand Down

0 comments on commit 884893c

Please sign in to comment.