-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da8d193
commit 6f11f65
Showing
28 changed files
with
1,118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/ODM/MongoDB/Tools/Console/Command/DocumentManagerCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command; | ||
|
||
use Doctrine\ODM\MongoDB\DocumentManager; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Helper\HelperSet; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
final class DocumentManagerCommand extends Command | ||
{ | ||
/** | ||
* @var Command | ||
*/ | ||
private $command; | ||
|
||
/** | ||
* @var ContainerInterface | ||
*/ | ||
private $container; | ||
|
||
public function __construct(Command $command, ContainerInterface $container) | ||
{ | ||
$this->command = $command; | ||
$this->container = $container; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->setName($this->command->getName()); | ||
$this->setAliases($this->command->getAliases()); | ||
$this->setDescription($this->command->getDescription()); | ||
$this->setHelp($this->command->getHelp()); | ||
$this->setDefinition($this->command->getDefinition()); | ||
|
||
$this->addOption('dm', null, InputOption::VALUE_OPTIONAL, 'The document manager to use for this command'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
/** @var string $documentManagerName */ | ||
$documentManagerName = $input->getOption('dm'); | ||
|
||
try { | ||
$documentManager = $this->container->get(DocumentManager::class.$documentManagerName); | ||
} catch (NotFoundExceptionInterface $serviceNotFoundException) { | ||
throw new \InvalidArgumentException(sprintf('Missing document manager with name "%s"', $documentManagerName)); | ||
} | ||
|
||
$this->command->setHelperSet(new HelperSet([ | ||
'dm' => new DocumentManagerHelper($documentManager), | ||
])); | ||
|
||
return (int) $this->command->execute($input, $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB; | ||
|
||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Doctrine\ODM\MongoDB\Configuration; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class ConfigurationFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): Configuration | ||
{ | ||
$config = $this->resolveConfig($container->get('config')['doctrine']['mongodbOdm']['configuration'] ?? []); | ||
|
||
$configuration = new Configuration(); | ||
|
||
$this->callAdders($container, $configuration, $config); | ||
$this->callSetters($container, $configuration, $config); | ||
|
||
return $configuration; | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $config | ||
*/ | ||
private function callAdders(ContainerInterface $container, Configuration $configuration, array &$config): void | ||
{ | ||
$filters = $this->resolveValue($container, $config['filters'] ?? []); | ||
|
||
unset($config['filters']); | ||
|
||
foreach ($filters as $filter) { | ||
$configuration->addFilter($filter['name'], $filter['className'], $filter['parameters']); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\Common\EventManagerFactory; | ||
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\MongoDB\ClientFactory; | ||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Doctrine\Common\EventManager; | ||
use Doctrine\ODM\MongoDB\Configuration; | ||
use Doctrine\ODM\MongoDB\DocumentManager; | ||
use MongoDB\Client; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class DocumentManagerFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManager | ||
{ | ||
/** @var Client $client */ | ||
$client = $this->resolveDependency($container, Client::class, ClientFactory::class); | ||
|
||
/** @var Configuration $configuration */ | ||
$configuration = $this->resolveDependency($container, Configuration::class, ConfigurationFactory::class); | ||
|
||
/** @var EventManager $eventManager */ | ||
$eventManager = $this->resolveDependency($container, EventManager::class, EventManagerFactory::class); | ||
|
||
return DocumentManager::create($client, $configuration, $eventManager); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/ClearCache/MetadataCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\ClearCache; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\ClearCache\MetadataCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class MetadataCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new MetadataCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/GenerateHydratorsCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateHydratorsCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class GenerateHydratorsCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new GenerateHydratorsCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Factory/ODM/MongoDB/Tools/Console/Command/GeneratePersistentCollectionsCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\GeneratePersistentCollectionsCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class GeneratePersistentCollectionsCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new GeneratePersistentCollectionsCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/GenerateProxiesCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateProxiesCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class GenerateProxiesCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new GenerateProxiesCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/QueryCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class QueryCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new QueryCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\Schema; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class CreateCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new CreateCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/Schema/DropCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\Schema; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class DropCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new DropCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/Schema/ShardCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\Schema; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\ShardCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class ShardCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new ShardCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/Schema/UpdateCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\Schema; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\UpdateCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class UpdateCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new UpdateCommand(), $container); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/ServiceFactory/ODM/MongoDB/Tools/Console/Command/Schema/ValidateCommandFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ODM\MongoDB\Tools\Console\Command\Schema; | ||
|
||
use Chubbyphp\Laminas\Config\Doctrine\ODM\MongoDB\Tools\Console\Command\DocumentManagerCommand; | ||
use Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\ValidateCommand; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class ValidateCommandFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): DocumentManagerCommand | ||
{ | ||
return new DocumentManagerCommand(new ValidateCommand(), $container); | ||
} | ||
} |
Oops, something went wrong.