TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
BaseScriptClass Class Reference
Inheritance diagram for BaseScriptClass:
PageFunctionsController ImportExportController InfoModuleController ConfigurationView DatabaseIntegrityView SchedulerModuleController TaskModuleController TypoScriptTemplateModuleController VersionModuleController

Public Member Functions

 init ()
 
 menuConfig ()
 
 mergeExternalItems ($modName, $menuKey, $menuArr)
 
 handleExternalFunctionValue ($MM_key= 'function', $MS_value=null)
 
 getExternalItemConfig ($modName, $menuKey, $value= '')
 
 checkExtObj ()
 
 checkSubExtObj ()
 
 extObjHeader ()
 
 getExtObjContent ()
 

Public Attributes

 $MCONF = []
 
 $id
 
 $CMD
 
 $perms_clause
 
 $MOD_MENU
 
 $MOD_SETTINGS = []
 
 $modTSconfig
 
 $modMenu_type = ''
 
 $modMenu_dontValidateList = ''
 
 $modMenu_setDefaultList = ''
 
 $extClassConf
 
 $content = ''
 
 $doc
 
 $extObj
 

Protected Member Functions

 getLanguageService ()
 
 getBackendUser ()
 
 getDatabaseConnection ()
 
 getPageRenderer ()
 

Protected Attributes

 $pageRenderer = null
 

Detailed Description

Parent class for 'ScriptClasses' in backend modules.

EXAMPLE PROTOTYPE

As for examples there are lots of them if you search for classes which extends However you can see a prototype example of how a module might use this class in an index.php file typically hosting a backend module.

NOTICE: This example only outlines the basic structure of how this class is used. You should consult the documentation and other real-world examples for some actual things to do when building modules.

TYPICAL SETUP OF A BACKEND MODULE:

PrototypeController EXTENDS THE CLASS with a main() and printContent() function:

namespace Vendor;

class PrototypeController extends { public function __construct() { $this->getLanguageService()->includeLLFile('EXT:prototype/Resources/Private/Language/locallang.xlf'); $this->getBackendUser()->modAccess($GLOBALS['MCONF'], TRUE); } }

MAIN FUNCTION - HERE YOU CREATE THE MODULE CONTENT IN $this->content public function main() { TYPICALLY THE INTERNAL VAR, $this->doc is instantiated like this: $this->doc = ::makeInstance(::class); ... AND OF COURSE A LOT OF OTHER THINGS GOES ON - LIKE PUTTING CONTENT INTO $this->content $this->content=''; } PRINT CONTENT - DONE AS THE LAST THING public function printContent() { echo $this->content; }

MAKE INSTANCE OF THE SCRIPT CLASS AND CALL init() $GLOBALS['SOBE'] = ::makeInstance(::class); $GLOBALS['SOBE']->init();

THEN WE WILL CHECK IF THERE IS A 'SUBMODULE' REGISTERED TO BE INITIALIZED AS WELL: $GLOBALS['SOBE']->checkExtObj();

THEN WE CALL THE main() METHOD AND THIS SHOULD SPARK THE CREATION OF THE MODULE OUTPUT. $GLOBALS['SOBE']->main(); FINALLY THE printContent() FUNCTION WILL OUTPUT THE ACCUMULATED CONTENT $GLOBALS['SOBE']->printContent();

Definition at line 75 of file BaseScriptClass.php.

Member Function Documentation

checkExtObj ( )

Creates an instance of the class found in $this->extClassConf['name'] in $this->extObj if any (this should hold three keys, "name", "path" and "title" if a "Function menu module" tries to connect...) This value in extClassConf might be set by an extension (in an ext_tables/ext_localconf file) which thus "connects" to a module. The array $this->extClassConf is set in handleExternalFunctionValue() based on the value of MOD_SETTINGS[function] If an instance is created it is initiated with $this passed as value and $this->extClassConf as second argument. Further the $this->MOD_SETTING is cleaned up again after calling the init function.

Returns
void
See also
handleExternalFunctionValue(), ::insertModuleFunction(), $extObj

Definition at line 297 of file BaseScriptClass.php.

References GeneralUtility\_GP(), BackendUtility\getModuleData(), and GeneralUtility\makeInstance().

Referenced by PageFunctionsController\mainAction(), InfoModuleController\mainAction(), and TypoScriptTemplateModuleController\mainAction().

checkSubExtObj ( )

Calls the checkExtObj function in sub module if present.

Returns
void

Definition at line 312 of file BaseScriptClass.php.

Referenced by PageFunctionsController\mainAction(), and InfoModuleController\mainAction().

extObjHeader ( )

Calls the 'header' function inside the "Function menu module" if present. A header function might be needed to add JavaScript or other stuff in the head. This can't be done in the main function because the head is already written.

Returns
void

Definition at line 325 of file BaseScriptClass.php.

getBackendUser ( )
protected

Returns the Backend User

Returns
BackendUserAuthentication

Definition at line 387 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by TypoScriptTemplateModuleController\init(), BaseScriptClass\init(), and BaseScriptClass\mergeExternalItems().

getDatabaseConnection ( )
protected
Returns
DatabaseConnection
Deprecated:
since TYPO3 v8, will be removed in TYPO3 v9, use the Doctrine DBAL layer via the ConnectionPool class

Definition at line 396 of file BaseScriptClass.php.

References $GLOBALS, and GeneralUtility\logDeprecatedFunction().

getExternalItemConfig (   $modName,
  $menuKey,
  $value = '' 
)

Returns configuration values from the global variable $TBE_MODULES_EXT for the module given. For example if the module is named "web_info" and the "function" key ($menuKey) of MOD_SETTINGS is "stat" ($value) then you will have the values of $TBE_MODULES_EXT['webinfo']['MOD_MENU']['function']['stat'] returned.

Parameters
string$modNameModule name
string$menuKeyMenu key, eg. "function" for the function menu. See $this->MOD_MENU
string$valueOptionally the value-key to fetch from the array that would otherwise have been returned if this value was not set. Look source...
Returns
mixed The value from the TBE_MODULES_EXT array.
See also
handleExternalFunctionValue()

Definition at line 280 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by BaseScriptClass\handleExternalFunctionValue().

getExtObjContent ( )

Return the content of the 'main' function inside the "Function menu module" if present

Returns
string

Definition at line 364 of file BaseScriptClass.php.

References BaseScriptClass\$content.

Referenced by InfoModuleController\main(), PageFunctionsController\main(), and TypoScriptTemplateModuleController\main().

getPageRenderer ( )
protected
handleExternalFunctionValue (   $MM_key = 'function',
  $MS_value = null 
)

Loads $this->extClassConf with the configuration for the CURRENT function of the menu.

Parameters
string$MM_keyThe key to MOD_MENU for which to fetch configuration. 'function' is default since it is first and foremost used to get information per "extension object" (I think that is what its called)
string$MS_valueThe value-key to fetch from the config array. If NULL (default) MOD_SETTINGS[$MM_key] will be used. This is useful if you want to force another function than the one defined in MOD_SETTINGS[function]. Call this in init() function of your Script Class: handleExternalFunctionValue('function', $forcedSubModKey)
Returns
void
See also
getExternalItemConfig(), init()

Definition at line 262 of file BaseScriptClass.php.

References BaseScriptClass\getExternalItemConfig().

Referenced by BaseScriptClass\init().

init ( )

Initializes the backend module by setting internal variables, initializing the menu.

Returns
void
See also
menuConfig()

Definition at line 201 of file BaseScriptClass.php.

References $GLOBALS, GeneralUtility\_GP(), BaseScriptClass\getBackendUser(), BaseScriptClass\handleExternalFunctionValue(), and BaseScriptClass\menuConfig().

Referenced by PageFunctionsController\mainAction(), InfoModuleController\mainAction(), and VersionModuleController\mainAction().

menuConfig ( )

Initializes the internal MOD_MENU array setting and unsetting items based on various conditions. It also merges in external menu items from the global array TBE_MODULES_EXT (see mergeExternalItems()) Then MOD_SETTINGS array is cleaned up (see ::getModuleData()) so it contains only valid values. It's also updated with any SET[] values submitted. Also loads the modTSconfig internal variable.

Returns
void
See also
init(), $MOD_MENU, $MOD_SETTINGS, ::getModuleData(), mergeExternalItems()

Definition at line 222 of file BaseScriptClass.php.

References GeneralUtility\_GP(), BackendUtility\getModTSconfig(), BackendUtility\getModuleData(), BaseScriptClass\mergeExternalItems(), and BackendUtility\unsetMenuItems().

Referenced by BaseScriptClass\init().

mergeExternalItems (   $modName,
  $menuKey,
  $menuArr 
)

Merges menu items from global array $TBE_MODULES_EXT

Parameters
string$modNameModule name for which to find value
string$menuKeyMenu key, eg. 'function' for the function menu.
array$menuArrThe part of a MOD_MENU array to work on.
Returns
array Modified array part. private
See also
::insertModuleFunction(), menuConfig()

Definition at line 241 of file BaseScriptClass.php.

References $GLOBALS, BaseScriptClass\getBackendUser(), BaseScriptClass\getLanguageService(), and GeneralUtility\inList().

Referenced by TaskModuleController\menuConfig(), and BaseScriptClass\menuConfig().

Member Data Documentation

$CMD

Definition at line 99 of file BaseScriptClass.php.

$doc

Definition at line 180 of file BaseScriptClass.php.

$extClassConf

Definition at line 168 of file BaseScriptClass.php.

$extObj

Definition at line 188 of file BaseScriptClass.php.

$MCONF = []

Definition at line 83 of file BaseScriptClass.php.

$MOD_MENU
Initial value:
= [
'function' => []
]

Definition at line 115 of file BaseScriptClass.php.

$MOD_SETTINGS = []

Definition at line 125 of file BaseScriptClass.php.

$modMenu_dontValidateList = ''

Definition at line 151 of file BaseScriptClass.php.

$modMenu_setDefaultList = ''

Definition at line 160 of file BaseScriptClass.php.

$modMenu_type = ''

Definition at line 142 of file BaseScriptClass.php.

$modTSconfig

Definition at line 133 of file BaseScriptClass.php.

$pageRenderer = null
protected
$perms_clause

Definition at line 107 of file BaseScriptClass.php.