‪TYPO3CMS  10.4
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 bool getInput ()
 
string getInputFile ($createFile='')
 
 setOutputFile ($absFile)
 
string getOutput ()
 
mixed getOutputFile ($absFile='')
 
bool init ()
 
 reset ()
 
 __destruct ()
 

Public Attributes

const ERROR_GENERAL = -1
 
const ERROR_SERVICE_NOT_AVAILABLE = -2
 
const ERROR_WRONG_SUBTYPE = -3
 
const ERROR_NO_INPUT = -4
 
const ERROR_FILE_NOT_FOUND = -20
 
const ERROR_FILE_NOT_READABLE = -21
 
const ERROR_FILE_NOT_WRITEABLE = -22
 
const ERROR_PROGRAM_NOT_FOUND = -40
 
const ERROR_PROGRAM_FAILED = -41
 
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

Definition at line 29 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 555 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

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

Definition at line 269 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.

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

Definition at line 302 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 286 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 188 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.

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

Definition at line 177 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.

Returns
‪array Error messages

Definition at line 229 of file AbstractService.php.

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

◆ getInput()

string bool 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)

Returns
‪string|bool

Definition at line 445 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.

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

Definition at line 460 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.

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

Definition at line 198 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.

Returns
‪array Error number and message

Definition at line 245 of file AbstractService.php.

◆ getLastErrorMsg()

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

Returns the last message from the error stack.

Returns
‪string Error message

Definition at line 214 of file AbstractService.php.

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

◆ getOutput()

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

Get the output content.

Returns
‪string

Definition at line 490 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

Parameters
string$absFile‪Absolute filename to write to
Returns
‪mixed

Definition at line 504 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

Returns
‪array Service description array

Definition at line 115 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

Returns
‪string Service key

Definition at line 125 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

Parameters
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)
Returns
‪mixed Configuration value for the service

Definition at line 148 of file AbstractService.php.

References $GLOBALS.

◆ getServiceTitle()

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

Returns the title of the service

Returns
‪string Service title

Definition at line 135 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.

Returns
‪bool TRUE if the service is available

Definition at line 525 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.

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

Definition at line 324 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.

Parameters
string$absFile‪File name with absolute path.

Definition at line 388 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 540 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 253 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.

Parameters
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 419 of file AbstractService.php.

◆ setInputFile()

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

Set the input file name for service processing.

Parameters
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 432 of file AbstractService.php.

◆ setOutputFile()

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

Set the output file name.

Parameters
string | bool$absFile‪File name

Definition at line 480 of file AbstractService.php.

◆ tempFile()

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

Create a temporary file.

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

Definition at line 370 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 400 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.

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

Definition at line 343 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 64 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 80 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 76 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 84 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 72 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 88 of file AbstractService.php.

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

◆ $prefixId

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

Prefix for temporary files

Definition at line 103 of file AbstractService.php.

◆ $shutdownRegistry

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

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

Definition at line 99 of file AbstractService.php.

◆ $tempFiles

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

Temporary files which have to be deleted

Definition at line 95 of file AbstractService.php.

◆ ERROR_FILE_NOT_FOUND

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

Definition at line 48 of file AbstractService.php.

◆ ERROR_FILE_NOT_READABLE

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

Definition at line 51 of file AbstractService.php.

◆ ERROR_FILE_NOT_WRITEABLE

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

Definition at line 55 of file AbstractService.php.

◆ ERROR_GENERAL

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

Definition at line 35 of file AbstractService.php.

◆ ERROR_NO_INPUT

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

Definition at line 45 of file AbstractService.php.

◆ ERROR_PROGRAM_FAILED

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

Definition at line 61 of file AbstractService.php.

◆ ERROR_PROGRAM_NOT_FOUND

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

Definition at line 58 of file AbstractService.php.

◆ ERROR_SERVICE_NOT_AVAILABLE

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

Definition at line 39 of file AbstractService.php.

◆ ERROR_WRONG_SUBTYPE

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

Definition at line 42 of file AbstractService.php.