Skip to content

Commit

Permalink
fix(symfony/6.4): remove sensio/framework-extra-bundle & annotations (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Jan 2, 2024
1 parent e296d61 commit 77d1ba2
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 390 deletions.
1 change: 0 additions & 1 deletion EMS/common-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"ext-zip": "*",
"aws/aws-sdk-php": "^3.294",
"cebe/markdown": "^1.2",
"doctrine/annotations": "^1.14",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/orm": "^2.17",
"dompdf/dompdf": "^v2.0",
Expand Down
2 changes: 0 additions & 2 deletions EMS/core-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"ext-simplexml": "*",
"ext-soap": "*",
"caxy/php-htmldiff": "^0.1",
"doctrine/annotations": "^1.14",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-migrations-bundle": "^3.2",
"dragonmantank/cron-expression": "^3.3",
Expand All @@ -30,7 +29,6 @@
"maennchen/zipstream-php": "^3.0",
"ocramius/doctrine-batch-utils": "^2.5",
"ramsey/uuid-doctrine": "^1.8",
"sensio/framework-extra-bundle": "^6.2",
"sensiolabs/ansi-to-html": "^1.2",
"symfony/asset": "6.4.*",
"symfony/cache": "6.4.*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ public function ajaxUpdate(int $revisionId, Request $request, PublishService $pu
$request->getSession()->getBag('flashes')->clear();

/**little trick to reorder collection*/
$requestRevision = $request->request->get('revision');
$requestRevision = $request->request->all('revision');
$this->reorderCollection($requestRevision);
$request->request->set('revision', $requestRevision);
/**end little trick to reorder collection*/
Expand Down
8 changes: 4 additions & 4 deletions EMS/core-bundle/src/Controller/ElasticsearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function search(Request $request): Response
$search->setEnvironments($this->environmentService->getEnvironmentNames());

if ('POST' == $request->getMethod()) {
$request->request->set('search_form', $request->query->get('search_form'));
$request->request->set('search_form', $request->query->all('search_form'));

$form = $this->createForm(SearchFormType::class, $search);

Expand Down Expand Up @@ -474,7 +474,7 @@ public function search(Request $request): Response
}

// Form treatment after the "Save" button has been pressed (= ask for a name to save the search preset)
if ($form->isSubmitted() && $form->isValid() && $request->query->get('search_form') && \array_key_exists('save', $request->query->all('search_form'))) {
if ($form->isSubmitted() && $form->isValid() && \array_key_exists('save', $request->query->all('search_form'))) {
$form = $this->createFormBuilder($search)
->add('name', TextType::class)
->add('save_search', SubmitEmsType::class, [
Expand All @@ -489,7 +489,7 @@ public function search(Request $request): Response
return $this->render("@$this->templateNamespace/elasticsearch/save-search.html.twig", [
'form' => $form->createView(),
]);
} elseif ($form->isSubmitted() && $form->isValid() && $request->query->get('search_form') && \array_key_exists('delete', $request->query->all('search_form'))) {
} elseif ($form->isSubmitted() && $form->isValid() && \array_key_exists('delete', $request->query->all('search_form'))) {
// Form treatment after the "Delete" button has been pressed (to delete a previous saved search preset)

$this->logger->notice('log.elasticsearch.search_deleted', [
Expand Down Expand Up @@ -539,7 +539,7 @@ public function search(Request $request): Response
$currentFilters->remove('search_form[_token]');

// Form treatment after the "Export results" button has been pressed (= ask for a "content type" <-> "template" mapping)
if (null !== $response && $form->isSubmitted() && $form->isValid() && $request->query->get('search_form') && \array_key_exists('exportResults', $request->query->all('search_form'))) {
if (null !== $response && $form->isSubmitted() && $form->isValid() && \array_key_exists('exportResults', $request->query->all('search_form'))) {
$exportForms = [];
$contentTypes = $this->getAllContentType($response);
foreach ($contentTypes as $name) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace EMS\CoreBundle\Core\Component\MediaLibrary\Request;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

class MediaLibraryRequestValueResolver implements ValueResolverInterface
{
/**
* @return iterable<MediaLibraryRequest>
*/
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
return MediaLibraryRequest::class === $argument->getType() ? [new MediaLibraryRequest($request)] : [];
}
}
44 changes: 0 additions & 44 deletions EMS/core-bundle/src/Core/Config/ConfigParamConverter.php

This file was deleted.

36 changes: 36 additions & 0 deletions EMS/core-bundle/src/Core/Config/ConfigValueResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace EMS\CoreBundle\Core\Config;

use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

readonly class ConfigValueResolver implements ValueResolverInterface
{
/**
* @param ServiceLocator<ConfigFactoryInterface> $configFactories
*/
public function __construct(
private ServiceLocator $configFactories
) {
}

/**
* @return iterable<ConfigInterface>
*/
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
$argumentType = $argument->getType();
if (!$argumentType || !\is_subclass_of($argumentType, ConfigInterface::class)) {
return [];
}

$hash = $request->attributes->getAlnum('hash');

return [$this->configFactories->get($argumentType)->createFromHash($hash)];
}
}
62 changes: 3 additions & 59 deletions EMS/core-bundle/src/Entity/FieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,78 +445,22 @@ public function giveContentType(): ContentType
return $parent->contentType;
}

// /**
// * Cette focntion clone casse le CollectionFieldType => impossible d'ajouter un record
// */
// public function __clone()
// {
// $this->children = new \Doctrine\Common\Collections\ArrayCollection ();
// $this->deleted = $this->deleted;
// $this->orderKey = $this->orderKey;
// $this->created = null;
// $this->modified = null;
// $this->description = $this->description;
// $this->id = 0;
// $this->name = $this->name ;
// $this->options = $this->options;
// $this->type = $this->type;
// }

/**
* get a child.
*
* @throws \Exception
*
* @deprecated Use FieldType->get($key)
*/
public function __get(string $key): ?FieldType
public function get(string $key): FieldType
{
if (!\str_starts_with($key, 'ems_')) {
throw new \Exception('unprotected ems get with key '.$key);
} else {
$key = \substr($key, 4);
}

/** @var FieldType $fieldType */
foreach ($this->getChildren() as $fieldType) {
if (!$fieldType->getDeleted() && 0 == \strcmp($key, $fieldType->getName())) {
return $fieldType;
}
}

return null;
}

public function get(string $key): FieldType
{
if (null === $fieldType = $this->__get($key)) {
throw new \RuntimeException(\sprintf('Field type for key "%s" not found', $key));
}

return $fieldType;
}

/**
* @throws \Exception
*/
public function __set(string $key, mixed $input): void
{
if (!\str_starts_with($key, 'ems_')) {
throw new \Exception('unprotected ems set with key '.$key);
} else {
$key = \substr($key, 4);
}
$found = false;
/** @var FieldType $child */
foreach ($this->children as &$child) {
if (!$child->getDeleted() && 0 == \strcmp($key, $child->getName())) {
$found = true;
$child = $input;
break;
}
}
if (!$found) {
$this->children->add($input);
}
throw new \RuntimeException(\sprintf('Field type for key "%s" not found', $key));
}

public function setParent(FieldType $parent = null): self
Expand Down
7 changes: 4 additions & 3 deletions EMS/core-bundle/src/Form/FieldType/FieldTypeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
if (!$field->getDeleted() && ($options['editSubfields'] || SubfieldType::class === $field->getType())) {
$childFound = true;
$builder->add('ems_'.$field->getName(), FieldTypeType::class, [
'data' => $field,
'container' => true,
'editSubfields' => $options['editSubfields'],
'data' => $field,
'container' => true,
'mapped' => false,
'editSubfields' => $options['editSubfields'],
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Form/View/CalendarViewType.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getParameters(View $view, FormFactoryInterface $formFactory, Req

return [
'view' => $view,
'field' => $view->getContentType()->getFieldType()->__get('ems_'.$view->getOptions()['dateRangeField']),
'field' => $view->getContentType()->getFieldType()->get('ems_'.$view->getOptions()['dateRangeField']),
'contentType' => $view->getContentType(),
'environment' => $view->getContentType()->getEnvironment(),
'form' => $form->createView(),
Expand Down
4 changes: 2 additions & 2 deletions EMS/core-bundle/src/Form/View/CriteriaViewType.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getParameters(View $view, FormFactoryInterface $formFactory, Req

$categoryField = false;
if ($view->getContentType()->getCategoryField()) {
$categoryField = $view->getContentType()->getFieldType()->__get('ems_'.$view->getContentType()->getCategoryField());
$categoryField = $view->getContentType()->getFieldType()->get('ems_'.$view->getContentType()->getCategoryField());
}

return [
Expand All @@ -94,7 +94,7 @@ public function getParameters(View $view, FormFactoryInterface $formFactory, Req
'view' => $view,
'contentType' => $view->getContentType(),
'environment' => $view->getContentType()->getEnvironment(),
'criterionList' => $view->getContentType()->getFieldType()->__get('ems_'.$view->getOptions()['criteriaField']),
'criterionList' => $view->getContentType()->getFieldType()->get('ems_'.$view->getOptions()['criteriaField']),
'form' => $form->createView(),
];
}
Expand Down
4 changes: 2 additions & 2 deletions EMS/core-bundle/src/Form/View/GalleryViewType.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function getParameters(View $view, FormFactoryInterface $formFactory, Req

return [
'view' => $view,
'field' => $view->getContentType()->getFieldType()->__get('ems_'.$view->getOptions()['imageField']),
'imageAssetConfigIdentifier' => $view->getContentType()->getFieldType()->__get('ems_'.$view->getOptions()['imageAssetConfigIdentifier']),
'field' => $view->getContentType()->getFieldType()->get('ems_'.$view->getOptions()['imageField']),
'imageAssetConfigIdentifier' => $view->getContentType()->getFieldType()->get('ems_'.$view->getOptions()['imageAssetConfigIdentifier']),
'contentType' => $view->getContentType(),
'environment' => $view->getContentType()->getEnvironment(),
'form' => $form->createView(),
Expand Down
8 changes: 4 additions & 4 deletions EMS/core-bundle/src/Resources/config/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<argument type="service" id="ems_common.storage.manager" />
</call>
</service>
<service id="emsco.config.param_converter" class="EMS\CoreBundle\Core\Config\ConfigParamConverter">
<service id="emsco.config.value_resolver" class="EMS\CoreBundle\Core\Config\ConfigValueResolver">
<argument type="tagged_locator" tag="emsco.config.factory" index-by="config"/>
<tag name="request.param_converter" converter="emsco.config" />
<tag name="emsco.config" priority="150">controller.argument_value_resolver</tag>
</service>

<!-- Json Menu Nested -->
Expand All @@ -35,8 +35,8 @@
</service>

<!-- Media Library -->
<service id="emsco.core.media_library.request.param_converter" class="EMS\CoreBundle\Core\Component\MediaLibrary\Request\MediaLibraryParamConverter">
<tag name="request.param_converter" converter="emsco.media_library_request" />
<service id="emsco.core.media_library.request.value_resolver" class="EMS\CoreBundle\Core\Component\MediaLibrary\Request\MediaLibraryRequestValueResolver">
<tag name="emsco.media_library_request" priority="150">controller.argument_value_resolver</tag>
</service>
<service id="emsco.core.media_library" class="EMS\CoreBundle\Core\Component\MediaLibrary\MediaLibraryService">
<argument type="service" id="ems_common.service.elastica" />
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"caxy/php-htmldiff": "^0.1",
"cebe/markdown": "^1.2",
"composer/ca-bundle": "^1.4",
"doctrine/annotations": "^1.14",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.17",
Expand All @@ -52,7 +51,6 @@
"psr/simple-cache": "^2.0",
"ramsey/uuid-doctrine": "^1.8",
"ruflin/elastica": "^7.3",
"sensio/framework-extra-bundle": "^6.2",
"sensiolabs/ansi-to-html": "^1.2",
"symfony-cmf/routing": "^3.0",
"symfony/asset": "6.4.*",
Expand Down
Loading

0 comments on commit 77d1ba2

Please sign in to comment.