-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Reflect codeEditor langauge based on selection
- Loading branch information
1 parent
5924324
commit 879107d
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
Classes/Form/DataProvider/CodeEditorFormatDataProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the package bk2k/syntax. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace BK2K\Syntax\Form\DataProvider; | ||
|
||
use TYPO3\CMS\Backend\Form\FormDataProviderInterface; | ||
|
||
class CodeEditorFormatDataProvider implements FormDataProviderInterface | ||
{ | ||
public function addData(array $result): array | ||
{ | ||
if ($result['tableName'] !== 'tt_content' || $result['recordTypeValue'] !== 'syntax') { | ||
return $result; | ||
} | ||
|
||
// @todo refactor when core provides api to retrieve registered packages or gracefully fallbacks | ||
$syntaxLanguage = $result['databaseRow']['syntax_language'][0] ?? ''; | ||
if (in_array($syntaxLanguage, ['css', 'html', 'javascript', 'json', 'php', 'sql', 'typoscript', 'xml'])) { | ||
$result['processedTca']['columns']['bodytext']['config']['format'] = $syntaxLanguage; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters