Skip to content

Commit

Permalink
[SonataImportBundle] Normalize structure of code
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoiriert committed Apr 27, 2024
1 parent 541651f commit d2c1a19
Show file tree
Hide file tree
Showing 43 changed files with 1,739 additions and 876 deletions.
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.

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
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

0 comments on commit d2c1a19

Please sign in to comment.