Skip to content

Commit

Permalink
Any fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
e-spin committed Jan 10, 2024
2 parents 852ee83 + 9b3f06e commit 576ed96
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -12,4 +12,4 @@
<directory name="src/Resources"/>
</ignoreFiles>
</projectFiles>
</psalm>
</psalm>
15 changes: 8 additions & 7 deletions src/View/EditMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Event\HandleSubmitEvent;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetEditMaskSubHeadlineEvent;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetEditModeButtonsEvent;
use ContaoCommunityAlliance\DcGeneral\Controller\ControllerInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\PropertiesDefinitionInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\PaletteInterface;
Expand Down Expand Up @@ -180,7 +181,7 @@ public function execute()

// Update the model - the model might add some more errors to the propertyValueBag via exceptions.
$controller = $this->environment->getController();
assert($controller instanceof ContainerInterface);
assert($controller instanceof ControllerInterface);
$controller->updateModelFromPropertyBag($this->model, $propertyValues);
}

Expand Down Expand Up @@ -235,7 +236,7 @@ private function processInput($widgetManager): ?PropertyValueBag

if ($input->getValue('FORM_SUBMIT') === $this->definition->getName()) {
$propertyValues = new PropertyValueBag();
$propertyNames = array_intersect(
$propertyNames = \array_intersect(
$this->definition->getPropertiesDefinition()->getPropertyNames(),
(array) $input->getValue('FORM_INPUTS')
);
Expand Down Expand Up @@ -330,7 +331,7 @@ private function getEditButtons(): array
$button = '<button type="submit" name="%s" id="%s" class="submit %s" accesskey="%s">%s</button>';
$buttons = [];

$buttons['save'] = sprintf(
$buttons['save'] = \sprintf(
$button,
'save',
'save',
Expand All @@ -340,7 +341,7 @@ private function getEditButtons(): array
);

if ($this->definition->getBasicDefinition()->isCreatable()) {
$buttons['saveNcreate'] = sprintf(
$buttons['saveNcreate'] = \sprintf(
$button,
'saveNcreate',
'saveNcreate',
Expand Down Expand Up @@ -469,9 +470,9 @@ private function storeVersion(ModelInterface $model): void
return;
}

$environment = $this->environment;
$modelId = $model->getId();
$dataProvider = $environment->getDataProvider($this->model->getProviderName());
$environment = $this->environment;
$modelId = $model->getId();
$dataProvider = $environment->getDataProvider($this->model->getProviderName());
assert($dataProvider instanceof DataProviderInterface);

$currentVersion = $dataProvider->getActiveVersion($modelId);
Expand Down
7 changes: 5 additions & 2 deletions src/View/WidgetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Contao\FormTextArea;
use Contao\Input;
use Contao\Widget;
use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Event\BuildWidgetEvent;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\EncodePropertyValueFromWidgetEvent;
use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Event\DcGeneralFrontendEvents;
Expand Down Expand Up @@ -114,7 +115,7 @@ public function getWidget($property, PropertyValueBag $valueBag = null)
$dispatcher->dispatch($event, DcGeneralFrontendEvents::BUILD_WIDGET);
if (!$event->getWidget()) {
throw new DcGeneralRuntimeException(
sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property)
\sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property)
);
}

Expand Down Expand Up @@ -174,7 +175,7 @@ public function processInput(PropertyValueBag $valueBag): void
$post = $this->hijackPost($valueBag);

// Now get and validate the widgets.
foreach (array_keys($valueBag->getArrayCopy()) as $property) {
foreach (\array_keys($valueBag->getArrayCopy()) as $property) {
$this->processProperty($valueBag, $property);
}

Expand All @@ -198,6 +199,7 @@ private function processProperty(PropertyValueBag $valueBag, string $property):
// native data as in the model.
// Therefore, we do not need to decode them but MUST encode them.
$widget = $this->getWidget($property, $valueBag);
assert($widget instanceof Widget);
$widget->validate();

if ($widget->hasErrors()) {
Expand All @@ -217,6 +219,7 @@ private function processProperty(PropertyValueBag $valueBag, string $property):
try {
// See https://github.com/contao/contao/blob/7e6bacd4e/core-bundle/src/Resources/contao/forms/FormTextArea.php#L147
if ($widget instanceof FormTextArea) {
/** @psalm-suppress UndefinedMagicPropertyFetch */
$valueBag->setPropertyValue($property, $this->encodeValue($property, $widget->rawValue, $valueBag));
return;
}
Expand Down
11 changes: 6 additions & 5 deletions src/Widgets/UploadOnSteroids.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Contao\Input;
use Contao\StringUtil;
use Contao\System;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
Expand Down Expand Up @@ -447,7 +448,7 @@ private function preOrPostFixFilename(string $filename): string
return $filename;
}

// We save the default delimeter '-' at prefix and postfix
// We save the default delimiter '-' at prefix and postfix
// see https://github.com/ausi/slug-generator/issues/34.
$prefix = $this->prefixFilename;
if ($this->prefixFilename && $this->normalizeFilename) {
Expand Down Expand Up @@ -530,7 +531,7 @@ private function addFiles($sortBy): void
)
->from($platform->quoteIdentifier('tl_files'))
->where($builder->expr()->in($platform->quoteIdentifier('uuid'), ':uuids'))
->setParameter('uuids', (array) $this->value, Connection::PARAM_STR_ARRAY);
->setParameter('uuids', (array) $this->value, ArrayParameterType::STRING );

$statement = $builder->executeQuery();
if (!$statement->rowCount()) {
Expand Down Expand Up @@ -705,11 +706,11 @@ protected function getSlugOptions(): array
*/
private function translator(): TranslatorInterface
{
if (!$this->filesystem) {
$this->filesystem = self::getContainer()->get('translator');
if (!$this->translator) {
$this->translator = self::getContainer()->get('translator');
}

return $this->filesystem;
return $this->translator;
}

/**
Expand Down

0 comments on commit 576ed96

Please sign in to comment.