```
--------------------------------
### Run Fill Translation Source Field Migration (Shell)
Source: https://github.com/gernott/mask/blob/main/Documentation/Upgrade/Index.rst
Executes the 'fillTranslationSourceField' upgrade task for Mask, used when upgrading from TYPO3 v7 / Mask v2 or lower to update custom tables with the new 'l10n_source' language field introduced in TYPO3 v8.
```shell
// composer mode
vendor/bin/typo3 upgrade:run fillTranslationSourceField
// classic mode
typo3/sysext/core/bin/typo3 upgrade:run fillTranslationSourceField
```
--------------------------------
### Target RTE Config Presets in TsConfig
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/RTEConfig.rst
This TsConfig snippet shows how to assign a specific RTE preset to a content element's field. It sets the default preset to 'custom' and then targets a specific mask element's richtext field ('tx_mask_content.types.mask_teaser') to use the 'simple' preset.
```ts
RTE.default.preset = custom
RTE.config.tt_content.tx_mask_content.types.mask_teaser.preset = simple
```
--------------------------------
### Restructure Override Fields using TYPO3 CLI
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/8.2/Index.rst
These shell commands are used to restructure existing content element configurations to utilize the new 'overrideSharedFields' feature in Mask. Two variations are provided: one for composer-based TYPO3 installations and another for classic mode installations. Execute the appropriate command based on your TYPO3 setup.
```shell
// composer mode
vendor/bin/typo3 mask:restructureOverrideFields
```
```shell
// classic mode
typo3/sysext/core/bin/typo3 mask:restructureOverrideFields
```
--------------------------------
### PHP: Loading TableDefinitionCollection via LoaderRegistry
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.1/Index.rst
Illustrates how to retrieve the TableDefinitionCollection using the LoaderRegistry service in PHP, a common pattern for accessing configuration.
```php
$loaderRegistry = GeneralUtility::makeInstance(LoaderRegistry::class);
$tableDefinitionCollection = $loaderRegistry->loadActiveDefinition();
```
--------------------------------
### StorageRepository: Add, Hide, Activate, and Load Content Elements (PHP)
Source: https://context7.com/gernott/mask/llms.txt
Demonstrates CRUD operations for content elements using StorageRepository. It covers adding new elements with fields, hiding and activating elements by their identifier, and loading raw JSON configuration. This class handles persistence and definition management.
```php
'myteaser',
'label' => 'Teaser Element',
'shortLabel' => 'Teaser',
'description' => 'A simple teaser block',
'icon' => 'fa-bullhorn',
'color' => '#ff5500'
];
// Define fields for the element
$fields = [
[
'key' => 'tx_mask_headline',
'name' => 'string', // FieldType value
'label' => 'Headline',
'description' => 'Main headline',
'tca' => [
'config.max' => 100
]
],
[
'key' => 'tx_mask_bodytext',
'name' => 'richtext',
'label' => 'Content',
'description' => 'Main content area'
],
[
'key' => 'tx_mask_link',
'name' => 'link',
'label' => 'Link',
'description' => 'CTA link'
]
];
// Add and persist the element
$json = $this->storageRepository->add($element, $fields, 'tt_content', true);
$tableDefinitionCollection = $this->storageRepository->persist($json);
}
public function hideElement(): void
{
// Hide element (keeps in JSON but not usable)
$this->storageRepository->hide('tt_content', 'myteaser');
}
public function activateElement(): void
{
// Reactivate hidden element
$this->storageRepository->activate('tt_content', 'myteaser');
}
public function loadConfiguration(): array
{
// Load raw JSON configuration
return $this->storageRepository->load();
}
}
```
--------------------------------
### Git Diff Statistics for Version Comparison
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.2/Index.rst
Provides a summary of changes between two versions of the Mask project, indicating the number of files changed and the total insertions and deletions. This is useful for understanding the scope of updates.
```shell
git diff v7.1.0 main --shortstat
```
--------------------------------
### PHP: Injecting TableDefinitionCollection
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.1/Index.rst
Demonstrates how to inject the TableDefinitionCollection class directly into a PHP class constructor for accessing Mask's configuration.
```php
public function __construct(TableDefinitionCollection $tableDefinitionCollection) {
}
```
--------------------------------
### Fluid Template Usage of Processed Data
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/DataProcessors.rst
Example of how to access processed data within a Fluid template. It displays the product title, net price, and the calculated gross price, demonstrating the use of the 'priceGross' field added by the VatProcessor.
```html
Title: {data.tx_mask_title}
Price net: {data.tx_mask_price -> f:format.number(decimals: '2')}€
Price gross: {data.priceGross -> f:format.number(decimals: '2')}€
```
--------------------------------
### Shell Command for Mask Definition Persistence
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.2/Index.rst
This command allows for the persistence of the current Mask definition without requiring arguments. It's a utility for managing Mask configurations within the TYPO3 environment.
```shell
mask:convert
```
--------------------------------
### Define Crop Variants for Specific Content Element (PHP)
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/CropVariants.rst
This snippet demonstrates how to define and apply crop variants to a specific content element type (cType) in TYPO3. It targets the 'imageManipulation' configuration within the TCA for a given column. This method is suitable for images not placed in repeater fields.
```php
$teaserCropVariants = [
'teaser' => [
'title' => 'Teaser',
'allowedAspectRatios' => [
'portrait' => [
'title' => 'Portrait',
'value' => 3 / 4
],
'landscape' => [
'title' => 'Landscape',
'value' => 4 / 3
],
],
],
];
$table = 'tt_content';
$cType = 'mask_teaser';
$column = 'tx_mask_teaser_image';
$GLOBALS['TCA'][$table]['types'][$cType]['columnsOverrides'][$column]['config']['overrideChildTca']['columns']['crop']['config']['cropVariants'] = $teaserCropVariants;
```
--------------------------------
### Configure Mask Extension Settings (PHP)
Source: https://context7.com/gernott/mask/llms.txt
This PHP code snippet demonstrates how to configure the Mask extension's behavior by setting global variables. It specifies the loader type, the path to the main JSON configuration file, and directories for split JSON configurations (content elements, backend layouts). It also defines paths for frontend and backend templates, layouts, and partials.
```php
// Configure in ext_localconf.php or via Settings module
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['mask'] = [
// Loader configuration
'loader_identifier' => 'json', // 'json' or 'json-split'
'json' => 'EXT:sitepackage/Configuration/Mask/mask.json',
// JsonSplitLoader paths
'content_elements_folder' => 'EXT:sitepackage/Configuration/Mask/ContentElements/',
'backend_layouts_folder' => 'EXT:sitepackage/Configuration/Mask/BackendLayouts/',
// Template paths
'frontend' => 'EXT:sitepackage/Resources/Private/Mask/Frontend/Templates/',
'layouts' => 'EXT:sitepackage/Resources/Private/Mask/Frontend/Layouts/',
'partials' => 'EXT:sitepackage/Resources/Private/Mask/Frontend/Partials/',
'backend' => 'EXT:sitepackage/Resources/Private/Mask/Backend/Templates/',
'layouts_backend' => 'EXT:sitepackage/Resources/Private/Mask/Backend/Layouts/',
'partials_backend' => 'EXT:sitepackage/Resources/Private/Mask/Backend/Partials/',
'preview' => 'EXT:sitepackage/Resources/Private/Mask/Backend/Preview/',
];
```
--------------------------------
### Convert Mask Definitions via CLI
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.2/Index.rst
This command-line interface command allows users to convert old Mask definitions to an up-to-date version. It's useful for updating definitions without manual intervention and ensuring compatibility with newer Mask and TYPO3 versions. This command is part of the Mask CLI tools.
```shell
vendor/bin/typo3 mask:convert
```
--------------------------------
### Configure Link Input Field (PHP)
Source: https://github.com/gernott/mask/blob/main/Documentation/Fieldtypes/Type/Link.rst
This snippet shows the basic configuration for a link input field using the 'inputLink' render type in PHP. It's a common setup for defining input fields in TYPO3's Table Configuration Array (TCA). No external dependencies are required for this basic configuration.
```php
'type' => 'input',
'renderType' => 'inputLink'
```
--------------------------------
### Override Custom Table Field Configuration in PHP
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/OverrideTCA.rst
This example shows how to override TCA for fields within a custom table generated by Mask, typically for repeating fields. It targets the 'tx_mask_custom_table' and modifies the 'tx_mask_your_field' column's configuration. This allows for specific adjustments to fields used in repeating content element structures.
```php
$GLOBALS['TCA']['tx_mask_custom_table']['columns']['tx_mask_your_field']['config']['some_option'] = 'some_value';
```
--------------------------------
### Run Mask Content Fields Migration Upgrade Wizard via TYPO3 CLI
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/8.1/Index.rst
This command executes the necessary upgrade wizard to migrate Mask content fields, addressing changes in persistence and matching for TYPO3 v12. It is essential for ensuring data integrity after the upgrade.
```shell
// composer mode
vendor/bin/typo3 upgrade:run migrateContentFields
// classic mode
typo3/sysext/core/bin/typo3 upgrade:run migrateContentFields
```
--------------------------------
### Edit Icon for Child Elements using TYPO3 Backend ViewHelpers (HTML)
Source: https://github.com/gernott/mask/blob/main/Documentation/BackendPreview/Index.rst
Demonstrates how to use TYPO3's core Backend ViewHelpers to display an edit icon for each child element within a content element. It iterates through child data and wraps an edit link around a core icon.
```html
Edit record
```
--------------------------------
### Override tt_content TCA for Mask Fields (PHP)
Source: https://context7.com/gernott/mask/llms.txt
This PHP snippet demonstrates how to override the Table Configuration Array (TCA) for the 'tt_content' table to customize Mask-generated fields. It includes examples for setting maximum lengths, placeholders, evaluation rules, default values for child records, and render types.
```php
// EXT:sitepackage/Configuration/TCA/Overrides/tt_content.php
// Override field configuration for tt_content fields
$GLOBALS['TCA']['tt_content']['columns']['tx_mask_headline']['config']['max'] = 80;
$GLOBALS['TCA']['tt_content']['columns']['tx_mask_headline']['config']['placeholder'] = 'Enter headline...';
// Add eval options
$GLOBALS['TCA']['tt_content']['columns']['tx_mask_email']['config']['eval'] = 'trim,email';
// Override inline child TCA defaults
$GLOBALS['TCA']['tt_content']['columns']['tx_mask_content_field']['config']['overrideChildTca']['columns']['space_before_class']['config']['default'] = 'medium';
// Add custom renderType
$GLOBALS['TCA']['tt_content']['columns']['tx_mask_select']['config']['renderType'] = 'selectTree';
```
--------------------------------
### Enable Override Shared Fields in PHP Configuration
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/8.2/Index.rst
This PHP code snippet demonstrates how to enable the 'overrideSharedFields' feature in the TYPO3 global configuration. This allows for overriding field configurations across different content elements in Mask. Ensure this setting is correctly placed within your TYPO3 installation's configuration.
```php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['overrideSharedFields'] = true;
```
--------------------------------
### MaskProcessor Integration with TypoScript
Source: https://context7.com/gernott/mask/llms.txt
This TypoScript configuration shows how to integrate the MaskProcessor and add custom DataProcessors. The MaskProcessor is automatically registered at key 100, allowing custom processors to be added at higher keys.
```typoscript
# MaskProcessor is automatically registered at key 100
# Add custom DataProcessor after Mask's processor
tt_content {
mask_myproduct {
dataProcessing {
# 100 is reserved for MaskProcessor
110 = YourVendor\YourExtension\DataProcessing\VatProcessor
110 {
vat = 19
}
}
}
}
```
--------------------------------
### Folder Field Type Configuration (PHP)
Source: https://github.com/gernott/mask/blob/main/Documentation/Fieldtypes/Type/Folder.rst
This code snippet shows the basic configuration for a 'folder' field type in PHP. It is used to define a field that allows users to select one or more folders.
```php
'type' => 'folder'
```
--------------------------------
### InlineHelper Data Resolution in PHP
Source: https://context7.com/gernott/mask/llms.txt
The InlineHelper class in PHP is used to resolve file references and inline records for frontend output. It provides methods to add file references and inline elements to data arrays, enabling recursive resolution of nested inline fields.
```php
inlineHelper->addFilesToData($data, $table);
// Add inline/IRRE elements to data array
// Recursively resolves inline fields with their own files and nested inlines
$this->inlineHelper->addIrreToData($data, $table);
}
public function getInlineElements(
array $parentData,
string $inlineFieldKey,
string $cType
): array {
// Manually retrieve inline elements for custom processing
return $this->inlineHelper->getInlineElements(
$parentData,
$inlineFieldKey,
$cType,
'parentid',
'tt_content'
);
}
}
```
--------------------------------
### Loader Configuration - YAML
Source: https://context7.com/gernott/mask/llms.txt
This YAML snippet demonstrates how to register custom or built-in Mask loaders within a Services.yaml file. It shows registering JsonSplitLoader with an 'json-split' identifier and provides a placeholder for registering a custom loader.
```yaml
# Register custom loader in Services.yaml
# EXT:your_extension/Configuration/Services.yaml
services:
MASK\Mask\Loader\JsonSplitLoader:
tags:
- name: mask.loader
identifier: json-split
# Or register your own custom loader
YourVendor\YourExtension\Loader\CustomLoader:
tags:
- name: mask.loader
identifier: custom
```
--------------------------------
### TypoScript Configuration for Data Processor
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/DataProcessors.rst
TypoScript configuration to register and set up the VatProcessor for a specific Mask content element type ('mask_product'). It specifies the processor class and passes a VAT percentage (19) as a configuration option.
```typoscript
tt_content {
mask_product {
dataProcessing {
110 = VENDOR\Extension\DataProcessing\VatProcessor
110 {
vat = 19
}
}
}
}
```
--------------------------------
### Register MASK EventListeners in YAML
Source: https://github.com/gernott/mask/blob/main/Documentation/API/Events.rst
This YAML configuration demonstrates how to register EventListeners for MASK events within a TYPO3 extension. It shows the service definition, tag, identifier, and the specific event each listener should subscribe to, enabling custom code execution on element save and delete.
```yaml
services:
VENDOR\Extension\EventListener\MaskAfterElementSavedEventListener:
tags:
- name: event.listener
identifier: 'executeCodeAfterChange'
event: MASK\Mask\Event\MaskAfterElementSavedEvent
VENDOR\Extension\EventListener\MaskAfterElementDeletedEventListener:
tags:
- name: event.listener
identifier: 'executeCodeAfterDeletion'
event: MASK\Mask\Event\MaskAfterElementDeletedEvent
```
--------------------------------
### Convert Mask JSON to Split JSON Files (Shell)
Source: https://github.com/gernott/mask/blob/main/Documentation/ChangeLog/7.1/Index.rst
This command-line utility converts a single mask.json file into multiple split JSON files. It can be executed using the TYPO3 console or the vendor/bin/typo3 script. This is useful for migrating existing configurations or persisting the current format.
```shell
> vendor/bin/typo3 mask:convert json json-split
// or with typo3 console
> vendor/bin/typo3cms mask:convert json json-split
// Persist your current format (E.g. for updating after TYPO3 upgrade)
> vendor/bin/typo3 mask:convert json
```
--------------------------------
### PHP Data Processor for VAT Calculation
Source: https://github.com/gernott/mask/blob/main/Documentation/Guides/DataProcessors.rst
A PHP class implementing the DataProcessorInterface to calculate gross price from a net price and a VAT percentage. It takes VAT as a configuration parameter and adds a 'priceGross' field to the processed data. This processor is intended to be placed in `Classes/DataProcessing/`.
```php
'radio'
```