Skip to content

Commit

Permalink
Merge pull request doctrine#2497 from franmomu/annotation2
Browse files Browse the repository at this point in the history
Allow `doctrine/annotations` 2
  • Loading branch information
malarzm authored Dec 27, 2022
2 parents 0fd338d + 68fb557 commit 4f14307
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-mongodb": "^1.5",
"doctrine/annotations": "^1.12",
"doctrine/annotations": "^1.12 || ^2.0",
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/collections": "^1.5 || ^2.0",
"doctrine/event-manager": "^1.0 || ^2.0",
Expand All @@ -41,7 +41,7 @@
"ext-bcmath": "*",
"doctrine/coding-standard": "^11.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0",
"phpbench/phpbench": "^1.0.0@dev",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5.5",
Expand Down
12 changes: 2 additions & 10 deletions docs/en/reference/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,11 @@ more paths) and register the annotations for the driver:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
// ...
$config->setMetadataDriverImpl(AnnotationDriver::create(__DIR__ . '/Documents'));
$loader = require_once('path/to/vendor/autoload.php');
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
require_once('path/to/vendor/autoload.php');
At this point, we have everything necessary to construct a ``DocumentManager``:

Expand All @@ -453,7 +449,6 @@ The final ``bootstrap.php`` file should look like this:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
Expand All @@ -462,10 +457,7 @@ The final ``bootstrap.php`` file should look like this:
throw new RuntimeException('Install dependencies to run this script.');
}
$loader = require_once $file;
$loader->add('Documents', __DIR__);
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
require_once $file;
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
Expand Down
6 changes: 1 addition & 5 deletions docs/en/tutorials/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,10 @@ instance. Read more about setting up the Doctrine MongoDB ODM in the
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
$loader = require_once('path/to/vendor/autoload.php');
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
require_once('path/to/vendor/autoload.php');
$config = new Configuration();
$config->setProxyDir('/path/to/generate/proxies');
Expand Down
6 changes: 1 addition & 5 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

declare(strict_types=1);

use Doctrine\Common\Annotations\AnnotationRegistry;

$file = __DIR__ . '/../vendor/autoload.php';

if (! file_exists($file)) {
throw new RuntimeException('Install dependencies to run test suite.');
}

$loader = require $file;

AnnotationRegistry::registerLoader([$loader, 'loadClass']);
require $file;
5 changes: 1 addition & 4 deletions tools/sandbox/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
Expand All @@ -14,9 +13,7 @@
throw new RuntimeException('Install dependencies to run this script.');
}

$loader = require_once $file;
$loader->add('Documents', __DIR__);
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
require_once $file;

$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Proxies');
Expand Down

0 comments on commit 4f14307

Please sign in to comment.