Skip to content

Commit

Permalink
fix suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ericges committed Mar 26, 2024
1 parent 8b75271 commit 493874b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Util/FormatterUtil.php
Expand Up @@ -5,15 +5,16 @@
use Codefog\TagsBundle\Model\TagModel;
use Contao\Config;
use Contao\Controller;
use Contao\CoreBundle\Framework\Adapter;
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\InsertTag\InsertTagParser;
use Contao\DataContainer;
use Contao\Date;
use Contao\Environment;
use Contao\Model;
use Contao\StringUtil as Str;
use Contao\System;
use Contao\Validator;
use Contao\Widget;
use HeimrichHannot\UtilsBundle\Util\FormatterUtil\FormatDcaFieldValueOptions;

class FormatterUtil
Expand Down Expand Up @@ -100,8 +101,14 @@ public function formatDcaFieldValue(
return $this->formatArray($value, $settings, $callback);
}

if ($inputType === 'explanation' && isset($data['eval']['text']))
if ($inputType === 'explanation'
&& (!empty($textCallback = $data['eval']['text_callback'] ?? null)
|| isset($data['eval']['text'])))
{
if ($textCallback) {
$attributes = Widget::getAttributesFromDca($data, $field, $value, $field, $table, $dc);
return $this->utils->dca()->executeCallback($textCallback, $attributes);
}
return $data['eval']['text'];
}

Expand Down Expand Up @@ -161,13 +168,6 @@ public function formatDcaFieldValue(
: $reference;
}

if ($data['eval']['encrypt'] ?? false)
{
[$encrypted, $iv] = explode('.', $value);
$key = System::getContainer()->getParameter('secret');
$value = openssl_decrypt($encrypted, 'aes-256-ctr', $key, 0, base64_decode($iv, true));
}

if ($settings->replaceInsertTags)
{
$value = $this->insertTagParser->replace($value);
Expand All @@ -176,7 +176,11 @@ public function formatDcaFieldValue(
return Str::specialchars($value);
}

private function getTagModel(): ?Model
/**
* @return Adapter<TagModel>|TagModel|Model|null
* @noinspection PhpMixedReturnTypeCanBeReducedInspection
*/
private function getTagModel(): mixed

Check failure on line 183 in src/Util/FormatterUtil.php

View workflow job for this annotation

GitHub Actions / phpstan

Method HeimrichHannot\UtilsBundle\Util\FormatterUtil::getTagModel() has invalid return type Codefog\TagsBundle\Model\TagModel.

Check failure on line 183 in src/Util/FormatterUtil.php

View workflow job for this annotation

GitHub Actions / phpstan

Method HeimrichHannot\UtilsBundle\Util\FormatterUtil::getTagModel() has invalid return type Codefog\TagsBundle\Model\TagModel.
{
if (class_exists(TagModel::class)) {
return $this->framework->getAdapter(TagModel::class);
Expand Down

0 comments on commit 493874b

Please sign in to comment.