Skip to content

Commit

Permalink
Mention process database and errorlog (#3606)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitzberger committed Oct 25, 2023
1 parent bd17f27 commit f52dca1
Showing 1 changed file with 73 additions and 62 deletions.
135 changes: 73 additions & 62 deletions Documentation/ApiOverview/Typo3CoreEngine/Database/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,26 @@ Basic Usage

.. code-block:: php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$cmd = [];
$data = [];
$dataHandler->start($data, $cmd);
$cmd = [];
$data = [];
$dataHandler->start($data, $cmd);
After this initialization you usually want to perform the actual operations by
calling one (or both) of these two methods:

.. code-block:: php
$dataHandler->process_datamap();
$dataHandler->process_cmdmap();
.. note::
Any error that might have occured during your DataHandler operations can be
accessed via its public property :php:`$dataHandler->errorLog`.

Commands array
==============
Expand All @@ -61,7 +72,7 @@ Syntax:

.. code-block:: none
$cmd[ tablename ][ uid ][ command ] = value
$cmd[ tablename ][ uid ][ command ] = value
Description of keywords in syntax:

Expand Down Expand Up @@ -316,10 +327,10 @@ Examples of commands:
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$cmd['tt_content'][54]['delete'] = 1; // Deletes tt_content record with uid=54
$cmd['tt_content'][1203]['copy'] = -303; // Copies tt_content uid=1203 to the position after tt_content uid=303 (new record will have the same pid as tt_content uid=1203)
$cmd['tt_content'][1203]['copy'] = 400; // Copies tt_content uid=1203 to first position in page uid=400
$cmd['tt_content'][1203]['move'] = 400; // Moves tt_content uid=1203 to the first position in page uid=400
$cmd['tt_content'][54]['delete'] = 1; // Deletes tt_content record with uid=54
$cmd['tt_content'][1203]['copy'] = -303; // Copies tt_content uid=1203 to the position after tt_content uid=303 (new record will have the same pid as tt_content uid=1203)
$cmd['tt_content'][1203]['copy'] = 400; // Copies tt_content uid=1203 to first position in page uid=400
$cmd['tt_content'][1203]['move'] = 400; // Moves tt_content uid=1203 to the first position in page uid=400
.. index:: DataHandler; Data array
.. _tce-data:
Expand Down Expand Up @@ -358,11 +369,11 @@ of original record UIDs and UIDs of record copies as values.
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$cmd['tt_content'][1203]['copy'] = 400; // Copies tt_content uid=1203 to first position in page uid=400
$dataHandler->start([], $cmd);
$dataHandler->process_cmdmap()
$cmd['tt_content'][1203]['copy'] = 400; // Copies tt_content uid=1203 to first position in page uid=400
$dataHandler->start([], $cmd);
$dataHandler->process_cmdmap()
$uid = $dataHandler->copyMappingArray_merged['tt_content'][1203];
$uid = $dataHandler->copyMappingArray_merged['tt_content'][1203];
Data Array
Expand Down Expand Up @@ -440,38 +451,38 @@ inside page id 45:
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$data['pages']['NEW9823be87'] = [
'title' => 'The page title',
'subtitle' => 'Other title stuff',
'pid' => '45'
];
$data['pages']['NEW9823be87'] = [
'title' => 'The page title',
'subtitle' => 'Other title stuff',
'pid' => '45'
];
This creates a new page titled "The page title" right after page id 45
in the tree:

.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$data['pages']['NEW9823be87'] = [
'title' => 'The page title',
'subtitle' => 'Other title stuff',
'pid' => '-45'
];
$data['pages']['NEW9823be87'] = [
'title' => 'The page title',
'subtitle' => 'Other title stuff',
'pid' => '-45'
];
This creates two new pages right after each other, located right after
the page id 45:

.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$data['pages']['NEW9823be87'] = [
'title' => 'Page 1',
'pid' => '-45'
];
$data['pages']['NEWbe68s587'] = [
'title' => 'Page 2',
'pid' => '-NEW9823be87'
];
$data['pages']['NEW9823be87'] = [
'title' => 'Page 1',
'pid' => '-45'
];
$data['pages']['NEWbe68s587'] = [
'title' => 'Page 2',
'pid' => '-NEW9823be87'
];
Notice how the second "pid" value points to the "NEW..." id
placeholder of the first record. This works because the new id of the
Expand All @@ -485,19 +496,19 @@ one new system category:
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$data['sys_category']['NEW9823be87'] = [
'title' => 'New category',
'pid' => 1,
];
$data['tt_content']['NEWbe68s587'] = [
'header' => 'Look ma, categories!',
'pid' => 45,
'categories' => [
1,
2,
'NEW9823be87', // You can also use placeholders here
],
];
$data['sys_category']['NEW9823be87'] = [
'title' => 'New category',
'pid' => 1,
];
$data['tt_content']['NEWbe68s587'] = [
'header' => 'Look ma, categories!',
'pid' => 45,
'categories' => [
1,
2,
'NEW9823be87', // You can also use placeholders here
],
];
.. note::
To get real uid of the record you have just created use DataHandler's `substNEWwithIDs` property like: :php:`$uid = $dataHandler->substNEWwithIDs['NEW9823be87'];`
Expand All @@ -508,10 +519,10 @@ this page", and no\_cache checked:
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$data['pages'][9834] = [
'title' => 'New title for this page',
'no_cache' => '1'
];
$data['pages'][9834] = [
'title' => 'New title for this page',
'no_cache' => '1'
];
Expand All @@ -528,7 +539,7 @@ Syntax
.. code-block:: php
:caption: EXT:some_extension/Classes/SomeClass.php
$dataHandler->clear_cacheCmd($cacheCmd);
$dataHandler->clear_cacheCmd($cacheCmd);
.. t3-field-list-table::
:header-rows: 1
Expand Down Expand Up @@ -595,19 +606,19 @@ your Extbase plugin (e.g. controller or a custom viewhelper):
.. code-block:: php
:caption: EXT:some_extension/Classes/Controller/SomeController.php
public function __construct(TypoScriptFrontendController $frontendController)
{
$this->frontendController = $frontendController;
}
public function __construct(TypoScriptFrontendController $frontendController)
{
$this->frontendController = $frontendController;
}
public function showAction(ExampleModel $example): ResponseInterface
{
// ...
public function showAction(ExampleModel $example): ResponseInterface
{
// ...
$this->frontendController->addCacheTags([
sprintf('tx_myextension_example_%d', $example->getUid()),
]);
}
$this->frontendController->addCacheTags([
sprintf('tx_myextension_example_%d', $example->getUid()),
]);
}
Hook for Cache Post-processing
------------------------------
Expand Down

0 comments on commit f52dca1

Please sign in to comment.