TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Service\AbstractService Class Reference
Inheritance diagram for TYPO3\CMS\Core\Service\AbstractService:
TYPO3\CMS\Sv\AbstractAuthenticationService TYPO3\CMS\Saltedpasswords\SaltedPasswordService TYPO3\CMS\Sv\AuthenticationService TYPO3\CMS\Rsaauth\RsaAuthService

Public Member Functions

 getServiceInfo ()
 
 getServiceKey ()
 
 getServiceTitle ()
 
 getServiceOption ($optionName, $defaultValue='', $includeDefaultConfig=true)
 
 devLog ($msg, $severity=0, $dataVar=false)
 
 errorPush ($errNum=T3_ERR_SV_GENERAL, $errMsg='Unspecified error occurred')
 
 errorPull ()
 
 getLastError ()
 
 getLastErrorMsg ()
 
 getErrorMsgArray ()
 
 getLastErrorArray ()
 
 resetErrors ()
 
 checkExec ($progList)
 
 deactivateService ()
 
 checkInputFile ($absFile)
 
 readFile ($absFile, $length=0)
 
 writeFile ($content, $absFile='')
 
 tempFile ($filePrefix)
 
 registerTempFile ($absFile)
 
 unlinkTempFiles ()
 
 setInput ($content, $type='')
 
 setInputFile ($absFile, $type='')
 
 getInput ()
 
 getInputFile ($createFile='')
 
 setOutputFile ($absFile)
 
 getOutput ()
 
 getOutputFile ($absFile='')
 
 init ()
 
 reset ()
 
 __destruct ()
 

Public Attributes

 $info = []
 
 $error = []
 
 $writeDevLog = false
 
 $out = ''
 
 $inputFile = ''
 
 $inputContent = ''
 
 $inputType = ''
 
 $outputFile = ''
 
 $tempFiles = []
 

Protected Attributes

 $shutdownRegistry = []
 
 $prefixId = ''
 

Detailed Description

Parent class for "Services" classes

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

Returns
void

Definition at line 556 of file AbstractService.php.

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

Member Function Documentation

◆ checkExec()

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

check the availability of external programs

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

Definition at line 261 of file AbstractService.php.

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

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

◆ checkInputFile()

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

Check if a file exists and is readable.

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

Definition at line 296 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\errorPush(), and TYPO3\CMS\Core\Utility\GeneralUtility\isAllowedAbsPath().

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.

Returns
void

Definition at line 280 of file AbstractService.php.

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

◆ devLog()

TYPO3\CMS\Core\Service\AbstractService::devLog (   $msg,
  $severity = 0,
  $dataVar = false 
)

Logs debug messages to ::devLog()

Parameters
string$msgDebug message
int$severitySeverity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
array | bool$dataVardditional data you want to pass to the logger.
Returns
void

Definition at line 151 of file AbstractService.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\devLog().

◆ errorPull()

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

Removes the last error from the error stack.

Returns
void

Definition at line 178 of file AbstractService.php.

◆ errorPush()

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

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

Parameters
int$errNumError number (see T3_ERR_SV_* constants)
string$errMsgError message
Returns
void

Definition at line 165 of file AbstractService.php.

References $GLOBALS.

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()

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

Returns all error messages as array.

Returns
array Error messages

Definition at line 219 of file AbstractService.php.

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

◆ getInput()

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
mixed

Definition at line 440 of file AbstractService.php.

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

◆ getInputFile()

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$createFileFile name. If empty a temp file will be created.
Returns
string File name or FALSE if no input or file error.

Definition at line 455 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()

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

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

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

◆ getLastErrorArray()

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

Returns the last array from the error stack.

Returns
array Error number and message

Definition at line 235 of file AbstractService.php.

◆ getLastErrorMsg()

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

Returns the last message from the error stack.

Returns
string Error message

Definition at line 204 of file AbstractService.php.

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

◆ getOutput()

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

Get the output content.

Returns
mixed

Definition at line 486 of file AbstractService.php.

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

◆ getOutputFile()

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$absFileAbsolute filename to write to
Returns
mixed

Definition at line 500 of file AbstractService.php.

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

◆ getServiceInfo()

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

Returns internal information array for service

Returns
array Service description array

Definition at line 90 of file AbstractService.php.

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

◆ getServiceKey()

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

Returns the service key of the service

Returns
string Service key

Definition at line 100 of file AbstractService.php.

◆ getServiceOption()

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

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

Parameters
string$optionNameName of the config option
mixed$defaultValueDefault configuration if no special config is available
bool$includeDefaultConfigIf 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 123 of file AbstractService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Sv\AbstractAuthenticationService\initAuth().

◆ getServiceTitle()

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

Returns the title of the service

Returns
string Service title

Definition at line 110 of file AbstractService.php.

◆ init()

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 extern perl script.

Returns
bool TRUE if the service is available

Definition at line 521 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()

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

Read content from a file a file.

Parameters
string$absFileFile name to read from.
int$lengthMaximum length to read. If empty the whole file will be read.
Returns
string|bool $content or FALSE

Definition at line 318 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
stringFile name with absolute path.
Returns
void

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

Returns
void

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

Returns
void

Definition at line 245 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$contentInput content (going into ->inputContent)
string$typeThe type of the input content (or file). Might be the same as the service subtypes.
Returns
void

Definition at line 413 of file AbstractService.php.

◆ setInputFile()

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

Set the input file name for service processing.

Parameters
string$absFileFile name
string$typeThe type of the input content (or file). Might be the same as the service subtypes.
Returns
void

Definition at line 427 of file AbstractService.php.

◆ setOutputFile()

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

Set the output file name.

Parameters
string$absFileFile name
Returns
void

Definition at line 476 of file AbstractService.php.

◆ tempFile()

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

Create a temporary file.

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

Definition at line 360 of file AbstractService.php.

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

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

◆ unlinkTempFiles()

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

◆ writeFile()

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

Write content to a file.

Parameters
string$contentContent to write to the file
string$absFileFile name to write into. If empty a temp file will be created.
Returns
string|bool File name or FALSE

Definition at line 337 of file AbstractService.php.

References TYPO3\CMS\Core\Service\AbstractService\errorPush(), TYPO3\CMS\Core\Utility\GeneralUtility\isAllowedAbsPath(), 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

◆ $info

TYPO3\CMS\Core\Service\AbstractService::$info = []

◆ $inputContent

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

Definition at line 50 of file AbstractService.php.

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

◆ $inputFile

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

◆ $inputType

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

Definition at line 55 of file AbstractService.php.

◆ $out

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

◆ $outputFile

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

◆ $prefixId

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

Definition at line 78 of file AbstractService.php.

◆ $shutdownRegistry

TYPO3\CMS\Core\Service\AbstractService::$shutdownRegistry = []
protected

Definition at line 73 of file AbstractService.php.

◆ $tempFiles

TYPO3\CMS\Core\Service\AbstractService::$tempFiles = []

Definition at line 68 of file AbstractService.php.

◆ $writeDevLog

TYPO3\CMS\Core\Service\AbstractService::$writeDevLog = false

Definition at line 35 of file AbstractService.php.