Skip to content

Commit

Permalink
Code generation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent FOULLOY committed Apr 11, 2023
1 parent 3fcd71a commit f57b0b0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
12 changes: 6 additions & 6 deletions Classes/CodeGenerator/CodeGeneratorForSavLibraryBasic.php
Expand Up @@ -136,16 +136,16 @@ protected function buildConfigurationTypoScript()
{
GeneralUtility::mkdir_deep($this->extensionDirectory . 'Configuration/TypoScript/');

// Generates constants.txt file if it does not exist
if (! file_exists($this->extensionDirectory . 'Configuration/TypoScript/constants.txt')) {
// Generates constants.typoscript file if it does not exist
if (! file_exists($this->extensionDirectory . 'Configuration/TypoScript/constants.typoscript')) {
$fileContents = $this->generateFile('Configuration/TypoScript/constants.txtt');
GeneralUtility::writeFile($this->extensionDirectory . 'Configuration/TypoScript/constants.txt', $fileContents);
GeneralUtility::writeFile($this->extensionDirectory . 'Configuration/TypoScript/constants.typoscript', $fileContents);
}

// Generates setup.txt file if it does not exist
if (! file_exists($this->extensionDirectory . 'Configuration/TypoScript/setup.txt')) {
// Generates setup.typoscript file if it does not exist
if (! file_exists($this->extensionDirectory . 'Configuration/TypoScript/setup.typoscript')) {
$fileContents = $this->generateFile('Configuration/TypoScript/setup.txtt');
GeneralUtility::writeFile($this->extensionDirectory . 'Configuration/TypoScript/setup.txt', $fileContents);
GeneralUtility::writeFile($this->extensionDirectory . 'Configuration/TypoScript/setup.typoscript', $fileContents);
}
}

Expand Down
1 change: 0 additions & 1 deletion Classes/Managers/ConfigurationManager.php
Expand Up @@ -15,7 +15,6 @@

namespace YolfTypo3\SavLibraryKickstarter\Managers;

use Symfony\Component\Yaml\Yaml;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down
9 changes: 7 additions & 2 deletions Classes/Parser/WhereClauseParser.php
Expand Up @@ -131,6 +131,8 @@ protected function analyzeWhereClause(string $clause): string
// Processes the right hand side operand
if ($rightHandSideOperand == '###user###') {
$rightHandSideOperand = '$this->getUserId()';
} elseif ($rightHandSideOperand == '###userGroupIds###') {
$rightHandSideOperand = '$this->getUserGroupIds()';
} elseif (strtolower($operator) == 'between') {
$betweenOperand[0] = $this->processRightHandSideOperand($leftHandSideOperand, $matchesExpression['leftBetweenOperand'][0]);
$betweenOperand[1] = $this->processRightHandSideOperand($leftHandSideOperand, $matchesExpression['rightBetweenOperand'][0]);
Expand Down Expand Up @@ -164,15 +166,18 @@ protected function analyzeWhereClause(string $clause): string
break;
case 'in':
case 'IN':
array_push($operands, '$query->in(\'' . $leftHandSideOperand . '\', [' . $rightHandSideOperand . '])');
if ($rightHandSideOperand != '$this->getUserGroupIds()') {
$rightHandSideOperand = '[' . $rightHandSideOperand . ']';
}
array_push($operands, '$query->in(\'' . $leftHandSideOperand . '\', ' . $rightHandSideOperand . ')');
break;
case 'contains':
case 'CONTAINS':
array_push($operands, '$query->contains(\'' . $leftHandSideOperand . '\', ' . $rightHandSideOperand . ')');
break;
case 'between':
case 'BETWEEN':
array_push($operands, $query->between($leftHandSideOperand, $betweenOperand[0], $betweenOperand[1]));
array_push($operands, '$query->between(\'' . $leftHandSideOperand . '\', ' . $betweenOperand[0] . ', ' . $betweenOperand[1]. ')');
break;
case '@':
// Marker is found, call recursively with the pattern
Expand Down
Expand Up @@ -64,7 +64,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$existingTable = $arguments['isExistingTable'];

if (! $existingTable) {
$domain = ($mvc ? '_domain_model_' : $tableName ? '_' : '');
$domain = ($mvc ? '_domain_model_' : ($tableName ? '_' : ''));
$prefix = 'tx_'. str_replace('_', '', $extensionKey);
$fieldName = ($fieldName ? '.' . $fieldName : '');
$result = $prefix . $domain . $tableName . $fieldName;
Expand Down
Expand Up @@ -15,4 +15,4 @@ services:
resource: '../Classes/*'
exclude: '../Classes/Domain/Model/*'
</f:alias>
</sav:function>
</sav:utility.removeEmptyLines>
Expand Up @@ -12,11 +12,11 @@
</f:if>
</f:then>
<f:else>
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension)}
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension, tableType:tableType)}
</f:else>
</f:if>
</f:then>
<f:else>
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension)}
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension, tableType:tableType)}
</f:else>
</f:if>
@@ -1 +1 @@
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension)}
{field.conf_rel_table->sav:builder.mvc.modelName(extension:extension, tableType:tableType)}

0 comments on commit f57b0b0

Please sign in to comment.