2 namespace TYPO3\CMS\Core\Service;
102 return $this->info[
'serviceKey'];
112 return $this->info[
'title'];
123 public function getServiceOption($optionName, $defaultValue =
'', $includeDefaultConfig =
true)
126 $svOptions =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SVCONF'][$this->info[
'serviceType']];
127 if (isset($svOptions[$this->info[
'serviceKey']][$optionName])) {
128 $config = $svOptions[$this->info[
'serviceKey']][$optionName];
129 }
elseif ($includeDefaultConfig && isset($svOptions[
'default'][$optionName])) {
130 $config = $svOptions[
'default'][$optionName];
132 if (!isset($config)) {
133 $config = $defaultValue;
151 public function devLog($msg, $severity = 0, $dataVar =
false)
153 if ($this->writeDevLog) {
154 \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($msg, $this->info[
'serviceKey'], $severity, $dataVar);
165 public function errorPush($errNum = T3_ERR_SV_GENERAL, $errMsg =
'Unspecified error occurred')
167 array_push($this->error, array(
'nr' => $errNum,
'msg' => $errMsg));
169 $GLOBALS[
'TT']->setTSlogMessage($errMsg, 2);
180 array_pop($this->error);
192 if (!empty($this->error)) {
193 $error = end($this->error);
194 $lastError =
$error[
'nr'];
206 $lastErrorMessage =
'';
207 if (!empty($this->error)) {
208 $error = end($this->error);
209 $lastErrorMessage =
$error[
'msg'];
211 return $lastErrorMessage;
222 if (!empty($this->error)) {
223 foreach ($this->error as
$error) {
224 $errArr[] = $error[
'msg'];
237 return end($this->error);
247 $this->error = array();
264 $progList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
',', $progList,
true);
265 foreach ($progList as $prog) {
266 if (!\TYPO3\CMS\Core\Utility\CommandUtility::checkCommand($prog)) {
268 $this->
errorPush(T3_ERR_SV_PROG_NOT_FOUND,
'External program not found: ' . $prog);
282 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::deactivateService($this->info[
'serviceType'], $this->info[
'serviceKey']);
298 $checkResult =
false;
300 if (@is_readable($absFile)) {
301 $checkResult = $absFile;
303 $this->
errorPush(T3_ERR_SV_FILE_READ,
'File is not readable: ' . $absFile);
306 $this->
errorPush(T3_ERR_SV_FILE_NOT_FOUND,
'File not found: ' . $absFile);
322 $out = file_get_contents($absFile);
323 if (
$out ===
false) {
324 $this->
errorPush(T3_ERR_SV_FILE_READ,
'Can not read from file: ' . $absFile);
340 $absFile = $this->
tempFile($this->prefixId);
343 if ($fd = @fopen($absFile,
'wb')) {
344 @fwrite($fd, $content);
347 $this->
errorPush(T3_ERR_SV_FILE_WRITE,
'Can not write to file: ' . $absFile);
362 $absFile = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam($filePrefix);
368 $this->
errorPush(T3_ERR_SV_FILE_WRITE,
'Can not create temp file.');
381 if (!isset($this->shutdownRegistry[__METHOD__])) {
382 register_shutdown_function(array($this,
'unlinkTempFiles'));
383 $this->shutdownRegistry[__METHOD__] =
true;
385 $this->tempFiles[] = $absFile;
395 foreach ($this->tempFiles as $absFile) {
396 \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($absFile);
398 $this->tempFiles = array();
415 $this->inputContent = $content;
416 $this->inputFile =
'';
417 $this->inputType = $type;
429 $this->inputContent =
'';
430 $this->inputFile = $absFile;
431 $this->inputType = $type;
442 if ($this->inputContent ==
'') {
443 $this->inputContent = $this->
readFile($this->inputFile);
457 if ($this->inputFile) {
459 }
elseif ($this->inputContent) {
460 $this->inputFile = $this->
writeFile($this->inputContent, $createFile);
478 $this->outputFile = $absFile;
488 if ($this->outputFile) {
489 $this->out = $this->
readFile($this->outputFile);
502 if (!$this->outputFile) {
503 $this->outputFile = $this->
writeFile($this->out, $absFile);
526 if (trim($this->info[
'exec'])) {
527 if (!$this->
checkExec($this->info[
'exec'])) {
544 $this->inputFile =
'';
545 $this->inputContent =
'';
546 $this->inputType =
'';
547 $this->outputFile =
'';