class JavaService in Search File Attachments 8
Service class to define and check the java binary for the tika library.
Hierarchy
- class \Drupal\search_file_attachments\JavaService
Expanded class hierarchy of JavaService
1 string reference to 'JavaService'
1 service uses JavaService
File
- src/
JavaService.php, line 8
Namespace
Drupal\search_file_attachmentsView source
class JavaService {
protected $javaPath;
/**
* Constructor.
*/
public function __construct() {
$this
->setJavaPath('java');
}
/**
* Returns the java path.
*
* @return string
* The java path.
*/
public function getJavaPath() {
return $this->javaPath;
}
/**
* Set the java path.
*
* @param string $path
* The path to the java binary.
*
* @return \Drupal\search_file_attachments\JavaService
* This class itself.
*/
public function setJavaPath($path) {
if (strpos(ini_get('extension_dir'), 'MAMP/')) {
$path = 'export DYLD_LIBRARY_PATH=""; ' . $path;
}
$this->javaPath = $path;
return $this;
}
/**
* Checks the java path that the java binary can be executed.
*
* @return bool
* TRUE or FALSE if the java binary can be executed.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JavaService:: |
protected | property | ||
JavaService:: |
public | function | Checks the java path that the java binary can be executed. | |
JavaService:: |
public | function | Returns the java path. | |
JavaService:: |
public | function | Set the java path. | |
JavaService:: |
public | function | Constructor. |