diff --git a/CHANGELOG.md b/CHANGELOG.md index 343cde9..155dd13 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Document Search Changelog +## 1.0.3 - 2020-10-27 +### Fixed +- Fix environment variable for pdftotext path not working (#5) + ## 1.0.2 - 2019-11-09 ### Changed - Loosen version constraints on dependencies diff --git a/composer.json b/composer.json index eac5178..5bae682 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "venveo/craft-documentsearch", "description": "Extract the contents of text documents and add to Craft's search index", "type": "craft-plugin", - "version": "1.0.2", + "version": "1.0.3", "keywords": [ "craft", "cms", diff --git a/src/DocumentSearch.php b/src/DocumentSearch.php index a3c368e..d598d70 100755 --- a/src/DocumentSearch.php +++ b/src/DocumentSearch.php @@ -85,7 +85,7 @@ protected function settingsHtml(): string [ 'settings' => $this->getSettings(), 'binaries' => [ - 'pdftotext' => is_file($this->getSettings()->pdfToTextExecutable) + 'pdftotext' => is_file(Craft::parseEnv($this->getSettings()->pdfToTextExecutable)) ] ] ); diff --git a/src/models/Settings.php b/src/models/Settings.php index 67f4b50..11bdf5b 100755 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -11,6 +11,7 @@ namespace venveo\documentsearch\models; use craft\base\Model; +use craft\behaviors\EnvAttributeParserBehavior; /** * @author Venveo @@ -23,8 +24,18 @@ class Settings extends Model public $maximumDocumentSize = 1024 * 4; public $indexVolumes = []; - // Public Methods - // ========================================================================= + + public function behaviors() + { + $behaviors = parent::behaviors(); + $behaviors['parser'] = [ + 'class' => EnvAttributeParserBehavior::class, + 'attributes' => [ + 'pdfToTextExecutable' + ], + ]; + return $behaviors; + } /** * @inheritdoc diff --git a/src/services/DocumentContentService.php b/src/services/DocumentContentService.php index 5f43380..47cebc2 100755 --- a/src/services/DocumentContentService.php +++ b/src/services/DocumentContentService.php @@ -110,6 +110,6 @@ public function extractContentFromPDF($filepath): string Craft::info('Extracting PDF content from: '.$filepath, __METHOD__); // change directory to guarantee writable directory chdir(Craft::$app->path->getAssetsPath().DIRECTORY_SEPARATOR); - return Pdf::getText($filepath, Plugin::$plugin->getSettings()->pdfToTextExecutable); + return Pdf::getText($filepath, Craft::parseEnv(Plugin::$plugin->getSettings()->pdfToTextExecutable)); } }