JavaService.php in Search File Attachments 8
File
src/JavaService.php
View source
<?php
namespace Drupal\search_file_attachments;
class JavaService {
protected $javaPath;
public function __construct() {
$this
->setJavaPath('java');
}
public function getJavaPath() {
return $this->javaPath;
}
public function setJavaPath($path) {
if (strpos(ini_get('extension_dir'), 'MAMP/')) {
$path = 'export DYLD_LIBRARY_PATH=""; ' . $path;
}
$this->javaPath = $path;
return $this;
}
public function checkJava() {
$path = $this
->getJavaPath();
$temp = tempnam(file_directory_temp(), 'asa');
exec($path . ' -version > ' . $temp . ' 2>&1');
$stderror = file_get_contents($temp);
$found = preg_match('/Runtime Environment/', $stderror);
return $found ? TRUE : FALSE;
}
}
Classes
Name |
Description |
JavaService |
Service class to define and check the java binary for the tika library. |