Commit 302c647e authored by Thomas Löffler's avatar Thomas Löffler
Browse files

[TASK] Improve documentation

parent 6c0d393e
......@@ -17,6 +17,45 @@ For example:
## Usage
### General usage
1. Instantiiate the `TcaBuilder` class
1. Set the table and type to configure (may also be a not existing type yet)
1. Use the methods to manipulate
1. Save to the TCA
1. Flush caches
1. See result
### Methods
#### Main methods
| Method name | Description | Parameters |
| ----------- | ----------- | ---------- |
| `setTable` | Sets the table to load configuration from | `string` $tableName |
| `setType` | Sets the type to load configuration from | `string` $typeName |
| `load` | Loads configuration if it's an existing type | |
| `loadConfiguration` | Shorter method to run `setTable`, `setType` and `load` at once | `string` $tableName <br> `string` $typeName |
| `saveToTca` | Saves the manipulated configuration to TCA | |
| `addField` | Adds a field to selected type | `string` $typeName <br> `string` $position (optional) <br> `string` $alternativeLabel (optional) |
| `addPalette` | Adds an existing palette to selected type | `string` $paletteName <br> `string` $position (optional)<br> `string` $alternativeLabel (optional) |
| `addDiv` | Adds a div (tab) to selected type | `string` $divName <br> `string` $label |
| `removeField` | Removes a field from selected type | `string` $fieldName |
| `removePalette` | Removes a palette from selected type | `string` $paletteName |
| `removeDiv` | Removes a div (tab) from selected type, either by position (index, beginning with 0) or by label | `string`&#124;`int` $positionOrLabel |
| `moveField` | Moves a field to a new position (alternatively with a new label) | `string` $fieldName <br> `string` $newPosition <br> `string` $newLabel (optional) |
| `movePalette` | Moves a palette to a new position (alternatively with a new label) | `string` $paletteName <br> `string` $newPosition <br> `string` $newLabel (optional) |
| `addOverride` | Adds a custom override of a field | `string` $fieldName <br> `array` $configuration |
#### Helper methods
| Method name | Description | Parameters | Returns |
| ----------- | ----------- | ---------- | ------- |
| `getPaletteString` | Finds the complete palette string which is used in list (for using it in position strings) | `string` $paletteName | `string` The complete palette string with `--palette--` and the possible label config |
| `getDivString` | Finds the complete div string which is used in list (for using it in position strings), either by position (index, beginning with 0) or by label | `string`&#124;`int` $positionOrLabel | `string` The complete palette string with `--div--` and the div's label |
## Examples
### Add an own content element
```php
......@@ -50,6 +89,24 @@ $tcaBuilder
->saveToTca(); // save back to TCA
```
```php
$tcaBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\SpoonerWeb\TcaBuilder\TcaBuilder::class);
$tcaBuilder
->loadConfiguration('pages', 7)
->removeDiv('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata')
->movePalette('title', 'after:' . $tcaBuilder->getPaletteString('abstract'), 'New title')
->addOverride(
'title',
[
'label' => 'New title',
'config' => [
'renderType' => 'inputLink'
]
]
)
->saveToTca();
```
### Do minimal changes
```php
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment