Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SonataImportBundle] Normalize structure of code #256

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"nesbot/carbon": "^2.0",
"doctrine/mongodb-odm-bundle": "*",
"fidry/cpu-core-counter": "^1.1",
"knplabs/doctrine-behaviors": "*"
"knplabs/doctrine-behaviors": "*",
"symfony/notifier": "^6.4.0"
},
"require-dev": {
"ext-pcntl": "*",
Expand Down Expand Up @@ -121,7 +122,6 @@
"scheb/2fa-email": "^6.0",
"colinodell/psr-testlogger": "^1.1",
"cweagans/composer-patches": "^1.7",
"symfony/notifier": "^6.4.0",
"symfony/maker-bundle": "^1.58"
},
"replace": {
Expand Down
158 changes: 79 additions & 79 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/packages/draw_sonata_extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ draw_sonata_extra:
default_field_priorities:
createdAt: 0

notifier: true

prevent_delete_extension:
restrict_to_role: 'ROLE_SUPER_ADMIN'

Expand Down
10 changes: 10 additions & 0 deletions config/services_test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

scheb_two_factor.security.totp_authenticator: '@App\Security\TotpAuthenticatorMock'

Draw\Bundle\TesterBundle\PHPUnit\Extension\DeleteTemporaryEntity\TemporaryEntityCleanerInterface: '@Draw\Bundle\TesterBundle\PHPUnit\Extension\DeleteTemporaryEntity\BaseTemporaryEntityCleaner'

Draw\Bundle\TesterBundle\PHPUnit\Extension\DeleteTemporaryEntity\BaseTemporaryEntityCleaner:
class: Draw\Bundle\TesterBundle\PHPUnit\Extension\DeleteTemporaryEntity\BaseTemporaryEntityCleaner
public: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Persistence\ManagerRegistry;
use Draw\Component\Application\Configuration\DoctrineConfigurationRegistry;
use Draw\Component\Application\Configuration\Entity\Config;
use Draw\Component\Core\Reflection\ReflectionAccessor;
Expand Down Expand Up @@ -41,73 +40,7 @@ public static function setUpBeforeClass(): void

protected function setUp(): void
{
$managerRegistry = new class(self::$entityManager) implements ManagerRegistry {
public function __construct(private EntityManagerInterface $entityManager)
{
}

public function getDefaultConnectionName()
{
return 'default';
}

public function getConnection($name = null)
{
return $this->entityManager->getConnection();
}

public function getConnections()
{
return ['default' => $this->getConnection()];
}

public function getConnectionNames()
{
return ['default' => 'default'];
}

public function getDefaultManagerName()
{
return 'default';
}

public function getManager($name = null)
{
return $this->entityManager;
}

public function getManagers()
{
return ['default' => $this->entityManager];
}

public function resetManager($name = null)
{
return $this->entityManager;
}

public function getAliasNamespace($alias)
{
return $alias;
}

public function getManagerNames()
{
return ['default' => 'manager.default'];
}

public function getRepository($persistentObject, $persistentManagerName = null)
{
return $this->entityManager->getRepository($persistentObject);
}

public function getManagerForClass($class)
{
return $this->entityManager;
}
};

$this->object = new DoctrineConfigurationRegistry($managerRegistry);
$this->object = new DoctrineConfigurationRegistry(static::createRegistry(self::$entityManager));
}

public function testConstruct(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Notifier\NotifierInterface;

class Configuration implements ConfigurationInterface
{
Expand Down Expand Up @@ -53,13 +51,8 @@ class_exists(PreObjectDeleteBatchEvent::class)

private function createNotifierNode(): ArrayNodeDefinition
{
$node = new ArrayNodeDefinition('notifier');

ContainerBuilder::willBeAvailable('symfony/notifier', NotifierInterface::class, [])
? $node->canBeDisabled()
: $node->canBeEnabled();

return $node;
return (new ArrayNodeDefinition('notifier'))
->canBeEnabled();
}

private function createPreventDeleteExtensionNode(): ArrayNodeDefinition
Expand Down
6 changes: 3 additions & 3 deletions packages/sonata-import-bundle/Admin/ColumnAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Draw\Bundle\SonataImportBundle\Admin;

use Draw\Bundle\SonataImportBundle\Column\MappedToOptionBuilderAggregator;
use Draw\Bundle\SonataImportBundle\Entity\Column;
use Draw\Bundle\SonataImportBundle\Import\Importer;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
Expand All @@ -25,7 +25,7 @@
class ColumnAdmin extends AbstractAdmin
{
public function __construct(
private MappedToOptionBuilderAggregator $mappedToOptionBuilderAggregator
private Importer $importer
) {
parent::__construct();
}
Expand Down Expand Up @@ -64,7 +64,7 @@ protected function configureFormFields(FormMapper $form): void

private function loadMappedToOptions(Column $column): array
{
$options = $this->mappedToOptionBuilderAggregator->getOptions($column);
$options = $this->importer->getOptions($column);

$result = [];
// Iterate over each element in the original array
Expand Down
Loading
Loading