‪TYPO3CMS  11.5
TYPO3\CMS\Core\Service\AbstractService Class Reference
Inheritance diagram for TYPO3\CMS\Core\Service\AbstractService:

Public Member Functions

array getServiceInfo ()
string getServiceKey ()
string getServiceTitle ()
mixed getServiceOption ($optionName, $defaultValue='', $includeDefaultConfig=true)
 errorPush ($errNum=self::ERROR_GENERAL, $errMsg='Unspecified error occurred')
 errorPull ()
int bool getLastError ()
string getLastErrorMsg ()
array getErrorMsgArray ()
array getLastErrorArray ()
 resetErrors ()
bool checkExec ($progList)
 deactivateService ()
string bool checkInputFile ($absFile)
string bool readFile ($absFile, $length=0)
string bool writeFile ($content, $absFile='')
string bool tempFile ($filePrefix)
 registerTempFile ($absFile)
 unlinkTempFiles ()
 setInput ($content, $type='')
 setInputFile ($absFile, $type='')
string getInput ()
string getInputFile ($createFile='')
 setOutputFile ($absFile)
string getOutput ()
mixed getOutputFile ($absFile='')
bool init ()
 reset ()
 __destruct ()

Public Attributes

const ERROR_GENERAL = -1
const ERROR_NO_INPUT = -4
array $info = array( )
array $error = array( )
string $out = ''
string $inputFile = ''
string $inputContent = ''
string $inputType = ''
string $outputFile = ''
array $tempFiles = array( )

Protected Attributes

array $shutdownRegistry = array( )
string $prefixId = ''

Detailed Description

Parent class for "Services" classes

‪since v11, will be removed in v12.

Definition at line 32 of file AbstractService.php.

Constructor & Destructor Documentation

◆ __destruct()

TYPO3\CMS\Core\Service\AbstractService::__destruct ( )

Clean up the service. Child classes should explicitly call parent::__destruct() in their destructors for this to work

Definition at line 557 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\unlinkTempFiles().

Member Function Documentation

◆ checkExec()

bool TYPO3\CMS\Core\Service\AbstractService::checkExec (   $progList)

check the availability of external programs

string$progList‪Comma list of programs 'perl,python,pdftotext'
‪bool Return FALSE if one program was not found

Definition at line 271 of file AbstractService.php.

References TYPO3\CMS\Core\Utility\CommandUtility\checkCommand(), TYPO3\CMS\Core\Service\AbstractService\errorPush(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Service\AbstractService\init().

◆ checkInputFile()

string bool TYPO3\CMS\Core\Service\AbstractService::checkInputFile (   $absFile)

Check if a file exists and is readable.

string$absFile‪File name with absolute path.
‪string|bool File name or FALSE.

Definition at line 304 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\errorPush().

Referenced by TYPO3\CMS\Core\Service\AbstractService\getInputFile(), and TYPO3\CMS\Core\Service\AbstractService\readFile().

◆ deactivateService()

TYPO3\CMS\Core\Service\AbstractService::deactivateService ( )

Deactivate the service. Use this if the service fails at runtime and will not be available.

Definition at line 288 of file AbstractService.php.

References TYPO3\CMS\Core\Utility\ExtensionManagementUtility\deactivateService().

◆ errorPull()

TYPO3\CMS\Core\Service\AbstractService::errorPull ( )

Removes the last error from the error stack.

Definition at line 190 of file AbstractService.php.

◆ errorPush()

TYPO3\CMS\Core\Service\AbstractService::errorPush (   $errNum = self::ERROR_GENERAL,
  $errMsg = 'Unspecified error occurred' 

Puts an error on the error stack. Calling without parameter adds a general error.

int$errNumError number (see class constants)
string$errMsgError message

Definition at line 180 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\checkExec(), TYPO3\CMS\Core\Service\AbstractService\checkInputFile(), TYPO3\CMS\Core\Service\AbstractService\readFile(), TYPO3\CMS\Core\Service\AbstractService\tempFile(), and TYPO3\CMS\Core\Service\AbstractService\writeFile().

◆ getErrorMsgArray()

array TYPO3\CMS\Core\Service\AbstractService::getErrorMsgArray ( )

Returns all error messages as array.

‪array Error messages

Definition at line 231 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$error.

◆ getInput()

string TYPO3\CMS\Core\Service\AbstractService::getInput ( )

Get the input content. Will be read from input file if needed. (That is if ->inputContent is empty and ->inputFile is not)


Definition at line 447 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$inputContent, and TYPO3\CMS\Core\Service\AbstractService\readFile().

◆ getInputFile()

string TYPO3\CMS\Core\Service\AbstractService::getInputFile (   $createFile = '')

Get the input file name. If the content was set by setContent a file will be created.

string$createFile‪File name. If empty a temp file will be created.
‪string File name or FALSE if no input or file error.

Definition at line 462 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$inputFile, TYPO3\CMS\Core\Service\AbstractService\checkInputFile(), and TYPO3\CMS\Core\Service\AbstractService\writeFile().

◆ getLastError()

int bool TYPO3\CMS\Core\Service\AbstractService::getLastError ( )

Returns the last error number from the error stack.

‪int|bool Error number (or TRUE if no error)

Definition at line 200 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$error.

Referenced by TYPO3\CMS\Core\Service\AbstractService\init().

◆ getLastErrorArray()

array TYPO3\CMS\Core\Service\AbstractService::getLastErrorArray ( )

Returns the last array from the error stack.

‪array Error number and message

Definition at line 247 of file AbstractService.php.

◆ getLastErrorMsg()

string TYPO3\CMS\Core\Service\AbstractService::getLastErrorMsg ( )

Returns the last message from the error stack.

‪string Error message

Definition at line 216 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$error.

◆ getOutput()

string TYPO3\CMS\Core\Service\AbstractService::getOutput ( )

Get the output content.


Definition at line 492 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$out, and TYPO3\CMS\Core\Service\AbstractService\readFile().

◆ getOutputFile()

mixed TYPO3\CMS\Core\Service\AbstractService::getOutputFile (   $absFile = '')

Get the output file name. If no output file is set, the ->out buffer is written to the file given by input parameter filename

string$absFile‪Absolute filename to write to

Definition at line 506 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$outputFile, and TYPO3\CMS\Core\Service\AbstractService\writeFile().

◆ getServiceInfo()

array TYPO3\CMS\Core\Service\AbstractService::getServiceInfo ( )

Returns internal information array for service

‪array Service description array

Definition at line 118 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$info.

◆ getServiceKey()

string TYPO3\CMS\Core\Service\AbstractService::getServiceKey ( )

Returns the service key of the service

‪string Service key

Definition at line 128 of file AbstractService.php.

◆ getServiceOption()

mixed TYPO3\CMS\Core\Service\AbstractService::getServiceOption (   $optionName,
  $defaultValue = '',
  $includeDefaultConfig = true 

Returns service configuration values from the $TYPO3_CONF_VARS['SVCONF'] array

string$optionName‪Name of the config option
mixed$defaultValue‪Default configuration if no special config is available
bool$includeDefaultConfig‪If set the 'default' config will be returned if no special config for this service is available (default: TRUE)
‪mixed Configuration value for the service

Definition at line 151 of file AbstractService.php.

References $GLOBALS.

◆ getServiceTitle()

string TYPO3\CMS\Core\Service\AbstractService::getServiceTitle ( )

Returns the title of the service

‪string Service title

Definition at line 138 of file AbstractService.php.

◆ init()

bool TYPO3\CMS\Core\Service\AbstractService::init ( )

Initialization of the service.

The class have to do a strict check if the service is available. example: check if the perl interpreter is available which is needed to run an external perl script.

‪bool TRUE if the service is available

Definition at line 527 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\checkExec(), TYPO3\CMS\Core\Service\AbstractService\getLastError(), and TYPO3\CMS\Core\Service\AbstractService\reset().

◆ readFile()

string bool TYPO3\CMS\Core\Service\AbstractService::readFile (   $absFile,
  $length = 0 

Read content from a file a file.

string$absFile‪File name to read from.
int$length‪Maximum length to read. If empty the whole file will be read.
‪string|bool file content or false

Definition at line 326 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\$out, TYPO3\CMS\Core\Service\AbstractService\checkInputFile(), and TYPO3\CMS\Core\Service\AbstractService\errorPush().

Referenced by TYPO3\CMS\Core\Service\AbstractService\getInput(), and TYPO3\CMS\Core\Service\AbstractService\getOutput().

◆ registerTempFile()

TYPO3\CMS\Core\Service\AbstractService::registerTempFile (   $absFile)

Register file which should be deleted afterwards.

string$absFile‪File name with absolute path.

Definition at line 390 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\tempFile().

◆ reset()

TYPO3\CMS\Core\Service\AbstractService::reset ( )

Resets the service. Will be called by init(). Should be used before every use if a service instance is used multiple times.

Definition at line 542 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\resetErrors(), and TYPO3\CMS\Core\Service\AbstractService\unlinkTempFiles().

Referenced by TYPO3\CMS\Core\Service\AbstractService\init().

◆ resetErrors()

TYPO3\CMS\Core\Service\AbstractService::resetErrors ( )

Reset the error stack.

Definition at line 255 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\reset().

◆ setInput()

TYPO3\CMS\Core\Service\AbstractService::setInput (   $content,
  $type = '' 

Set the input content for service processing.

mixed$content‪Input content (going into ->inputContent)
string$type‪The type of the input content (or file). Might be the same as the service subtypes.

Definition at line 421 of file AbstractService.php.

◆ setInputFile()

TYPO3\CMS\Core\Service\AbstractService::setInputFile (   $absFile,
  $type = '' 

Set the input file name for service processing.

string$absFile‪File name
string$type‪The type of the input content (or file). Might be the same as the service subtypes.

Definition at line 434 of file AbstractService.php.

◆ setOutputFile()

TYPO3\CMS\Core\Service\AbstractService::setOutputFile (   $absFile)

Set the output file name.

string$absFile‪File name

Definition at line 482 of file AbstractService.php.

◆ tempFile()

string bool TYPO3\CMS\Core\Service\AbstractService::tempFile (   $filePrefix)

Create a temporary file.

string$filePrefix‪File prefix.
‪string|bool File name or FALSE

Definition at line 372 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\errorPush(), and TYPO3\CMS\Core\Service\AbstractService\registerTempFile().

Referenced by TYPO3\CMS\Core\Service\AbstractService\writeFile().

◆ unlinkTempFiles()

TYPO3\CMS\Core\Service\AbstractService::unlinkTempFiles ( )

Delete registered temporary files.

Definition at line 402 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\__destruct(), and TYPO3\CMS\Core\Service\AbstractService\reset().

◆ writeFile()

string bool TYPO3\CMS\Core\Service\AbstractService::writeFile (   $content,
  $absFile = '' 

Write content to a file.

string$content‪Content to write to the file
string$absFile‪File name to write into. If empty a temp file will be created.
‪string|bool File name or FALSE

Definition at line 345 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\errorPush(), and TYPO3\CMS\Core\Service\AbstractService\tempFile().

Referenced by TYPO3\CMS\Core\Service\AbstractService\getInputFile(), and TYPO3\CMS\Core\Service\AbstractService\getOutputFile().

Member Data Documentation

◆ $error

array TYPO3\CMS\Core\Service\AbstractService::$error = array( )

◆ $info

array TYPO3\CMS\Core\Service\AbstractService::$info = array( )

service description array

Definition at line 67 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\getServiceInfo().

◆ $inputContent

string TYPO3\CMS\Core\Service\AbstractService::$inputContent = ''

The content that should be processed.

Definition at line 83 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\getInput().

◆ $inputFile

string TYPO3\CMS\Core\Service\AbstractService::$inputFile = ''

The file that should be processed.

Definition at line 79 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\getInputFile().

◆ $inputType

string TYPO3\CMS\Core\Service\AbstractService::$inputType = ''

The type of the input content (or file). Might be the same as the service subtypes.

Definition at line 87 of file AbstractService.php.

◆ $out

string TYPO3\CMS\Core\Service\AbstractService::$out = ''

The output content. That's what the services produced as result.

Definition at line 75 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\getOutput(), and TYPO3\CMS\Core\Service\AbstractService\readFile().

◆ $outputFile

string TYPO3\CMS\Core\Service\AbstractService::$outputFile = ''

The file where the output should be written to.

Definition at line 91 of file AbstractService.php.

Referenced by TYPO3\CMS\Core\Service\AbstractService\getOutputFile().

◆ $prefixId

string TYPO3\CMS\Core\Service\AbstractService::$prefixId = ''

Prefix for temporary files

Definition at line 106 of file AbstractService.php.

◆ $shutdownRegistry

array TYPO3\CMS\Core\Service\AbstractService::$shutdownRegistry = array( )

list of registered shutdown functions; should be used to prevent registering the same function multiple times

Definition at line 102 of file AbstractService.php.

◆ $tempFiles

array TYPO3\CMS\Core\Service\AbstractService::$tempFiles = array( )

Temporary files which have to be deleted

Definition at line 98 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_FILE_NOT_FOUND = -20

Definition at line 51 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_FILE_NOT_READABLE = -21

Definition at line 54 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_FILE_NOT_WRITEABLE = -22

Definition at line 58 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_GENERAL = -1

Definition at line 38 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_NO_INPUT = -4

Definition at line 48 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_PROGRAM_FAILED = -41

Definition at line 64 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_PROGRAM_NOT_FOUND = -40

Definition at line 61 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_SERVICE_NOT_AVAILABLE = -2

Definition at line 42 of file AbstractService.php.


const TYPO3\CMS\Core\Service\AbstractService::ERROR_WRONG_SUBTYPE = -3

Definition at line 45 of file AbstractService.php.