From b320054757cec1e1e5d668d052dda11a315a47c6 Mon Sep 17 00:00:00 2001 From: Alexander Menshchikov Date: Thu, 13 Jun 2024 00:32:32 +0300 Subject: [PATCH] Bump php + auditor --- .github/workflows/audit.yml | 2 +- docker/app/Dockerfile | 4 ++-- docker/local/php/Dockerfile | 2 +- shared/homeless/src/Admin/ClientAdmin.php | 16 +++++++++----- shared/homeless/src/Entity/Client.php | 26 ----------------------- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index cbcb38e..9fa1e71 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -51,6 +51,6 @@ jobs: echo "::endgroup::" - name: Auditor - uses: docker://nbgrp/auditor:0.20.0 + uses: docker://nbgrp/auditor:0.26.0 with: working-directory: shared/homeless diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 31d3a66..947fd1e 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3.2-fpm-alpine +FROM php:8.3.8-fpm-alpine # # Setup Moscow time @@ -36,7 +36,7 @@ RUN apk update \ nodejs \ yarn \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \ - && composer self-update 2.5.1 \ + && composer self-update 2.7.1 \ && docker-php-ext-install \ bcmath \ gd \ diff --git a/docker/local/php/Dockerfile b/docker/local/php/Dockerfile index 3d4e5dd..d39b05b 100644 --- a/docker/local/php/Dockerfile +++ b/docker/local/php/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3.2-fpm-alpine +FROM php:8.3.8-fpm-alpine USER root diff --git a/shared/homeless/src/Admin/ClientAdmin.php b/shared/homeless/src/Admin/ClientAdmin.php index bd62cf9..1e380b2 100644 --- a/shared/homeless/src/Admin/ClientAdmin.php +++ b/shared/homeless/src/Admin/ClientAdmin.php @@ -221,8 +221,12 @@ public function configureShowFields(ShowMapper $show): void } $field = $fieldValue->getField(); + $fieldCode = $field->getCode(); - $options = ['label' => $field->getName()]; + $options = [ + 'label' => $field->getName(), + 'accessor' => static fn (Client $client): mixed => $client->getAdditionalFieldValue($fieldCode), + ]; switch ($field->getType()) { case ClientField::TYPE_OPTION: @@ -242,12 +246,12 @@ public function configureShowFields(ShowMapper $show): void break; } - if ($field->getCode() === 'homelessFrom') { + if ($fieldCode === 'homelessFrom') { $options['pattern'] = 'MMM y'; } $showMapperAdditionalInfo[\count($showMapperAdditionalInfo) - 1]['add'] = [ - self::getAdditionalFieldName($field->getCode()), + self::getAdditionalFieldName($fieldCode), $field->getShowFieldType(), $options, ]; @@ -262,8 +266,7 @@ public function configureShowFields(ShowMapper $show): void foreach ($showMapperAdditionalInfoSort as $showMapperAdditionalInfoSortItems) { foreach ($showMapperAdditionalInfoSortItems as $item) { if (isset($item['add'])) { - $reflectionMethod = new \ReflectionMethod(ShowMapper::class, 'add'); - $reflectionMethod->invokeArgs($show, $item['add']); + $show->add(...$item['add']); } } } @@ -545,6 +548,8 @@ protected function configureFormFields(FormMapper $form): void 'label' => 'Не бездомный', 'label_attr' => ['class' => 'changeSelectinsData'], 'required' => false, + 'getter' => static fn (Client $client): bool => !$client->isHomeless(), + 'setter' => static fn (Client $client, bool $value): Client => $client->setIsHomeless(!$value), ]) ; } @@ -676,6 +681,7 @@ protected function configureListFields(ListMapper $list): void ->add('lastContractDuration', null, [ 'template' => '/admin/fields/client_contract_duration_list.html.twig', 'label' => ' ', + 'virtual_field' => true, ]) ->addIdentifier('id', 'number', [ 'route' => ['name' => 'show'], diff --git a/shared/homeless/src/Entity/Client.php b/shared/homeless/src/Entity/Client.php index d8fba49..3afc4fb 100644 --- a/shared/homeless/src/Entity/Client.php +++ b/shared/homeless/src/Entity/Client.php @@ -154,20 +154,6 @@ public function __toString(): string return $this->getFullname(); } - public function __call($name, $args): mixed - { - $property = lcfirst(substr($name, 3)); - if (str_starts_with($name, 'get') && str_starts_with($property, 'additionalField')) { - return $this->getAdditionalFieldValue(substr($property, 15)); - } - - if (str_starts_with($name, 'set') && str_starts_with($property, 'additionalField')) { - $this->setAdditionalFieldValue(substr($name, 15), \count($args) === 1 ? $args[0] : null); - } - - return null; - } - public function getPhoto(): ?File { return $this->photo; @@ -623,18 +609,6 @@ public function setIsHomeless(bool $isHomeless): self return $this; } - public function notIsHomeless(): bool - { - return !$this->isHomeless; - } - - public function setNotIsHomeless(bool $notIsHomeless): self - { - $this->isHomeless = !$notIsHomeless; - - return $this; - } - public function getClientViews(): Collection { return $this->clientViews;