Skip to content

Commit

Permalink
Rename DoctrineSetup to ORMSetup (doctrine#9481)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored and n-e-m-a-nj-a committed Mar 29, 2022
1 parent 75bf4d3 commit 5b74483
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ the entity manager.

## Deprecate `Doctrine\ORM\Configuration::newDefaultAnnotationDriver`

This functionality has been moved to the new `DoctrineSetup` class. Call
`Doctrine\ORM\Tools\DoctrineSetup::createDefaultAnnotationDriver()` to create
This functionality has been moved to the new `ORMSetup` class. Call
`Doctrine\ORM\ORMSetup::createDefaultAnnotationDriver()` to create
a new annotation driver.

## Deprecate `Doctrine\ORM\Tools\Setup`

In our effort to migrate from Doctrine Cache to PSR-6, the `Setup` class which
accepted a Doctrine Cache instance in each method has been deprecated.

The replacement is `Doctrine\ORM\Tools\DoctrineSetup` which accepts a PSR-6
The replacement is `Doctrine\ORM\ORMSetup` which accepts a PSR-6
cache instead.

## Deprecate `Doctrine\ORM\Cache\MultiGetRegion`
Expand Down
8 changes: 4 additions & 4 deletions docs/en/reference/advanced-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ steps of configuration.
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\ORMSetup;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
Expand All @@ -28,7 +28,7 @@ steps of configuration.
$config = new Configuration;
$config->setMetadataCache($metadataCache);
$driverImpl = DoctrineSetup::createDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$driverImpl = ORMSetup::createDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCache($queryCache);
$config->setProxyDir('/path/to/myproject/lib/MyProject/Proxies');
Expand Down Expand Up @@ -130,9 +130,9 @@ the ``Doctrine\ORM\Configuration``:
.. code-block:: php
<?php
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\ORMSetup;
$driverImpl = DoctrineSetup::createDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$driverImpl = ORMSetup::createDefaultAnnotationDriver('/path/to/lib/MyProject/Entities');
$config->setMetadataDriverImpl($driverImpl);
The path information to the entities is required for the annotation
Expand Down
14 changes: 7 additions & 7 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ access point to ORM functionality provided by Doctrine.
// bootstrap.php
require_once "vendor/autoload.php";
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
$paths = array("/path/to/entity-files");
$isDevMode = false;
Expand All @@ -55,12 +55,12 @@ access point to ORM functionality provided by Doctrine.
'dbname' => 'foo',
);
$config = DoctrineSetup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$config = ORMSetup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
.. note::

The ``DoctrineSetup`` class has been introduced with ORM 2.12. It's predecessor ``Setup`` is deprecated and will
The ``ORMSetup`` class has been introduced with ORM 2.12. It's predecessor ``Setup`` is deprecated and will
be removed in version 3.0.

Or if you prefer XML:
Expand All @@ -69,7 +69,7 @@ Or if you prefer XML:
<?php
$paths = array("/path/to/xml-mappings");
$config = DoctrineSetup::createXMLMetadataConfiguration($paths, $isDevMode);
$config = ORMSetup::createXMLMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Or if you prefer YAML:
Expand All @@ -78,7 +78,7 @@ Or if you prefer YAML:
<?php
$paths = array("/path/to/yml-mappings");
$config = DoctrineSetup::createYAMLMetadataConfiguration($paths, $isDevMode);
$config = ORMSetup::createYAMLMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
.. note::
Expand All @@ -88,7 +88,7 @@ Or if you prefer YAML:
"symfony/yaml": "*"

Inside the ``DoctrineSetup`` methods several assumptions are made:
Inside the ``ORMSetup`` methods several assumptions are made:

- If ``$isDevMode`` is true caching is done in memory with the ``ArrayAdapter``. Proxy objects are recreated on every request.
- If ``$isDevMode`` is false, check for Caches in the order APCu, Redis (127.0.0.1:6379), Memcache (127.0.0.1:11211) unless `$cache` is passed as fourth argument.
Expand All @@ -97,7 +97,7 @@ Inside the ``DoctrineSetup`` methods several assumptions are made:

.. note::

In order to have ``DoctrineSetup`` configure the cache automatically, the library ``symfony/cache``
In order to have ``ORMSetup`` configure the cache automatically, the library ``symfony/cache``
has to be installed as a dependency.

If you want to configure Doctrine in more detail, take a look at the :doc:`Advanced Configuration <reference/advanced-configuration>` section.
Expand Down
10 changes: 5 additions & 5 deletions docs/en/tutorials/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ step:
<?php
// bootstrap.php
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
require_once "vendor/autoload.php";
Expand All @@ -147,10 +147,10 @@ step:
$proxyDir = null;
$cache = null;
$useSimpleAnnotationReader = false;
$config = DoctrineSetup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader);
$config = ORMSetup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader);
// or if you prefer YAML or XML
// $config = DoctrineSetup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
// $config = DoctrineSetup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
// $config = ORMSetup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
// $config = ORMSetup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
// database configuration parameters
$conn = array(
Expand All @@ -173,7 +173,7 @@ The ``require_once`` statement sets up the class autoloading for Doctrine and
its dependencies using Composer's autoloader.

The second block consists of the instantiation of the ORM
``Configuration`` object using the ``DoctrineSetup`` helper. It assumes a bunch
``Configuration`` object using the ``ORMSetup`` helper. It assumes a bunch
of defaults that you don't have to bother about for now. You can
read up on the configuration details in the
:doc:`reference chapter on configuration <../reference/configuration>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

declare(strict_types=1);

namespace Doctrine\ORM\Tools;
namespace Doctrine\ORM;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
Expand All @@ -28,7 +27,7 @@
use function sprintf;
use function sys_get_temp_dir;

final class DoctrineSetup
final class ORMSetup
{
/**
* Creates a configuration with an annotation metadata driver.
Expand Down
11 changes: 6 additions & 5 deletions lib/Doctrine/ORM/Tools/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\ORM\Mapping\Driver\YamlDriver;
use Doctrine\ORM\ORMSetup;
use Memcached;
use Redis;
use RuntimeException;
Expand All @@ -34,7 +35,7 @@
/**
* Convenience class for setting up Doctrine from different installations and configurations.
*
* @deprecated Use {@see DoctrineSetup} instead.
* @deprecated Use {@see ORMSetup} instead.
*/
class Setup
{
Expand Down Expand Up @@ -78,7 +79,7 @@ public static function createAnnotationMetadataConfiguration(array $paths, $isDe
'https://github.com/doctrine/orm/pull/9443',
'%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.',
self::class,
DoctrineSetup::class
ORMSetup::class
);

$config = self::createConfiguration($isDevMode, $proxyDir, $cache);
Expand All @@ -105,7 +106,7 @@ public static function createAttributeMetadataConfiguration(
'https://github.com/doctrine/orm/pull/9443',
'%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.',
self::class,
DoctrineSetup::class
ORMSetup::class
);

$config = self::createConfiguration($isDevMode, $proxyDir, $cache);
Expand All @@ -130,7 +131,7 @@ public static function createXMLMetadataConfiguration(array $paths, $isDevMode =
'https://github.com/doctrine/orm/pull/9443',
'%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.',
self::class,
DoctrineSetup::class
ORMSetup::class
);

$config = self::createConfiguration($isDevMode, $proxyDir, $cache);
Expand Down Expand Up @@ -179,7 +180,7 @@ public static function createConfiguration($isDevMode = false, $proxyDir = null,
'https://github.com/doctrine/orm/pull/9443',
'%s is deprecated and will be removed in Doctrine 3.0, please use %s instead.',
self::class,
DoctrineSetup::class
ORMSetup::class
);

$proxyDir = $proxyDir ?: sys_get_temp_dir();
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Performance/EntityManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMSetup;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\Mocks\DriverResultMock;

Expand All @@ -29,7 +29,7 @@ public static function getEntityManager(array $schemaClassNames): EntityManagerI
$config->setProxyDir(__DIR__ . '/../Tests/Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_EVAL);
$config->setMetadataDriverImpl(DoctrineSetup::createDefaultAnnotationDriver([
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([
realpath(__DIR__ . '/Models/Cache'),
realpath(__DIR__ . '/Models/GeoNames'),
]));
Expand All @@ -55,7 +55,7 @@ public static function makeEntityManagerWithNoResultsConnection(): EntityManager
$config->setProxyDir(__DIR__ . '/../Tests/Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_EVAL);
$config->setMetadataDriverImpl(DoctrineSetup::createDefaultAnnotationDriver([
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([
realpath(__DIR__ . '/Models/Cache'),
realpath(__DIR__ . '/Models/Generic'),
realpath(__DIR__ . '/Models/GeoNames'),
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/Mocks/EntityManagerMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Doctrine\Common\EventManager;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\UnitOfWork;

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ public static function create($conn, ?Configuration $config = null, ?EventManage
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/../Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setMetadataDriverImpl(DoctrineSetup::createDefaultAnnotationDriver());
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver());
}

if ($eventManager === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\ORMSetup;
use GearmanWorker;
use InvalidArgumentException;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function createEntityManager(Connection $conn): EntityManagerInterface
$config->setProxyNamespace('MyProject\Proxies');
$config->setAutoGenerateProxyClasses(true);

$annotDriver = DoctrineSetup::createDefaultAnnotationDriver([__DIR__ . '/../../../Models/']);
$annotDriver = ORMSetup::createDefaultAnnotationDriver([__DIR__ . '/../../../Models/']);
$config->setMetadataDriverImpl($annotDriver);
$config->setMetadataCache(new ArrayAdapter());

Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMSetup;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Tools\DoctrineSetup;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\Tests\DbalExtensions\Connection;
use Doctrine\Tests\DbalExtensions\QueryLog;
Expand Down Expand Up @@ -241,7 +241,7 @@ private function createEntityManager(): EntityManagerInterface

$config->setProxyDir(realpath(__DIR__ . '/../../Proxies'));
$config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setMetadataDriverImpl(DoctrineSetup::createDefaultAnnotationDriver(
$config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver(
[realpath(__DIR__ . '/../../Models/Cache')]
));

Expand Down
Loading

0 comments on commit 5b74483

Please sign in to comment.