-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add necessary factories and tests to create a DocumentManager * allow PHP 8 * add LICENSE
- Loading branch information
Showing
26 changed files
with
1,085 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/.github/ export-ignore | ||
/features/ export-ignore | ||
/tests/ export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/composer-require-checker.json export-ignore | ||
/infection.json export-ignore | ||
/phpcs.xml export-ignore | ||
/phpstan.neon export-ignore | ||
/phpstan-baseline.neon export-ignore | ||
/phpunit.xml export-ignore | ||
/psalm.xml export-ignore |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file, in reverse chronological order by release. | ||
|
||
File automatically generated with [phly/keep-a-changelog](https://github.com/phly/keep-a-changelog) | ||
|
||
## 0.1.0 - 2021-08-01 | ||
|
||
This first release is actually considered stable, but it uses common factories from `roave/psr-container-doctrine` | ||
which requires `doctrine/orm`. If you use Doctrine ORM anyway or if you don't mind having an unnecessary dependency, | ||
go ahead :) | ||
|
||
### Added | ||
|
||
- [#1](https://github.com/eventjet/eventjet-psr-container-doctrine-odm/pull/1) adds all factories to create a DocumentManager | ||
|
||
### Changed | ||
|
||
- Nothing. | ||
|
||
### Deprecated | ||
|
||
- Nothing. | ||
|
||
### Removed | ||
|
||
- Nothing. | ||
|
||
### Fixed | ||
|
||
- Nothing. |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Eventjet | ||
|
||
Parts of the code are derived from roave/psr-container-doctrine and are subject to the BSD 2-Clause license | ||
(https://github.com/Roave/psr-container-doctrine/blob/master/LICENSE). | ||
Copyright 2016-2020 Ben Scholzen | ||
Copyright 2020 Roave | ||
|
||
Parts of the code are derived from roave/psr-container-doctrine and are subject to the MIT License | ||
(https://github.com/doctrine/DoctrineMongoODMModule/blob/master/LICENSE). | ||
Copyright (c) 2006-2012 Doctrine Project | ||
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,35 @@ | ||
# psr-container-doctrine-odm: Doctrine MongoDB ODM factories for PSR-11 containers | ||
|
||
This package provides additional factories for Doctrine MongoDB ODM on top of | ||
[`roave/psr-container-doctrine`](https://github.com/Roave/psr-container-doctrine) to be used with containers | ||
using the PSR-11 standard. | ||
|
||
## Installation | ||
|
||
```bash | ||
$ composer require eventjet/psr-container-doctrine-odm | ||
``` | ||
|
||
## Configuration | ||
|
||
The most basic way is just defining the factory for the `DocumentManager`. Everything else is taken from the | ||
configuration. | ||
|
||
```php | ||
return [ | ||
'dependencies' => [ | ||
'factories' => [ | ||
DocumentManager::class => DocumentManagerFactory::class, | ||
], | ||
], | ||
]; | ||
``` | ||
|
||
### Example Configuration | ||
|
||
A full example of the configuration can be found in the [examples](example/full-config.php) folder. | ||
|
||
The configuration style is heavily based | ||
on [`roave/psr-container-doctrine`](https://github.com/Roave/psr-container-doctrine/blob/3.1.x/example/full-config.php) | ||
to retain the familiarity. Also, the configuration _should_ be compatible with the | ||
['DoctrineMongoODMModule for Laminas](https://github.com/doctrine/DoctrineMongoODMModule). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* This configuration is based on the config of roave/psr-container-doctrine to retain familiarity with its style. | ||
* Factories which are used from roave/psr-container-doctrine | ||
* (namely the \Roave\PsrContainerDoctrine\EventManagerFactory) have the same configuration except that the default | ||
* 'odm_default' is used. | ||
* | ||
* @see https://github.com/Roave/psr-container-doctrine/blob/3.1.x/example/full-config.php | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Doctrine\ODM\MongoDB\Configuration; | ||
use Doctrine\ODM\MongoDB\Repository\DocumentRepository as DefaultDocumentRepository; | ||
|
||
return [ | ||
'doctrine' => [ | ||
'configuration' => [ | ||
'odm_default' => [ | ||
'metadata_cache' => 'array', | ||
'generate_proxies' => Configuration::AUTOGENERATE_EVAL, | ||
'proxy_dir' => 'data', | ||
'proxy_namespace' => 'DoctrineMongoODMModule\Proxy', | ||
'generate_hydrators' => Configuration::AUTOGENERATE_ALWAYS, | ||
'hydrator_dir' => 'data', | ||
'hydrator_namespace' => 'DoctrineMongoODMModule\Hydrator', | ||
'generate_persistent_collections' => Configuration::AUTOGENERATE_ALWAYS, | ||
'persistent_collection_dir' => 'data', | ||
'persistent_collection_namespace' => 'DoctrineMongoODMModule\PersistentCollection', | ||
'persistent_collection_factory' => null, | ||
'persistent_collection_generator' => null, | ||
'default_db' => null, | ||
'filters' => [], | ||
'class_metadata_factory_name' => null, | ||
'repository_factory' => null, | ||
'types' => [], | ||
'driver' => 'odm_default', // Actually defaults to the configuration config key, not hard-coded | ||
'default_document_repository_class_name' => DefaultDocumentRepository::class, | ||
], | ||
], | ||
'connection' => [ | ||
'odm_default' => [ | ||
'server' => 'localhost', | ||
'port' => '27017', | ||
'user' => null, | ||
'password' => null, | ||
'dbname' => null, | ||
'connection_string' => null, | ||
'uri_options' => [], | ||
'configuration' => 'odm_default', // Actually defaults to the configuration config key, not hard-coded | ||
], | ||
], | ||
], | ||
]; |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Eventjet coding standard"> | ||
<rule ref="EventjetStrict"/> | ||
<rule ref="EventjetStrict"> | ||
<exclude-pattern>tests/functional/TestDouble/DummyRepository.php</exclude-pattern> | ||
</rule> | ||
<file>example</file> | ||
<file>src</file> | ||
<file>tests</file> | ||
</ruleset> |
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
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,29 @@ | ||
<?php | ||
|
||
/** | ||
* The following class was derived from roave/psr-container-doctrine | ||
* | ||
* https://github.com/Roave/psr-container-doctrine/blob/master/src/AbstractFactory.php | ||
* | ||
* Code subject to the BSD 2-Clause license (https://github.com/Roave/psr-container-doctrine/blob/master/LICENSE). | ||
* | ||
* Copyright 2016-2020 Ben Scholzen | ||
* Copyright 2020 Roave | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Eventjet\PsrContainerDoctrineOdm\Service; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Roave\PsrContainerDoctrine\AbstractFactory; | ||
|
||
abstract class AbstractOdmFactory extends AbstractFactory | ||
{ | ||
private string $configKey = 'odm_default'; | ||
|
||
public function __invoke(ContainerInterface $container): object | ||
{ | ||
return $this->createWithConfig($container, $this->configKey); | ||
} | ||
} |
Oops, something went wrong.