Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[DCOM-96] Moving proxy generation and autoloading to common #406

Merged
merged 3 commits into from

5 participants

@Ocramius
Owner

This PR is related to doctrine/common#168.

In this PR, the ProxyFactory has been reduced to an object builder and it's public API has been kept intact (While the proxy Autoloader has been moved to doctrine/common). It would be interesting to define what this builder could do with the ProxyFactory to get its own customizations introduced.

Also fixes DDC-1734

@travisbot

This pull request fails (merged a7b18c15 into 93cef61).

@travisbot

This pull request fails (merged 58a03c2b into 93cef61).

@travisbot

This pull request passes (merged 9572e81c into 93cef61).

.gitmodules
@@ -1,6 +1,6 @@
[submodule "lib/vendor/doctrine-common"]
path = lib/vendor/doctrine-common
- url = git://github.com/doctrine/common.git
+ url = git://github.com/Ocramius/common.git
@Ocramius Owner

To be changed before merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@travisbot

This pull request passes (merged 44556a00 into 93cef61).

@travisbot

This pull request passes (merged 43a125dd into 93cef61).

lib/Doctrine/ORM/Proxy/ProxyFactory.php
@@ -19,36 +19,30 @@
namespace Doctrine\ORM\Proxy;
-use Doctrine\ORM\EntityManager,
- Doctrine\ORM\Mapping\ClassMetadata,
- Doctrine\ORM\Mapping\AssociationMapping,
- Doctrine\Common\Util\ClassUtils;
+use Doctrine\ORM\EntityManager;
@guilhermeblanco Owner

Reorder these uses. Less dependent ones should be at the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/ORM/Proxy/ProxyFactory.php
((120 lines not shown))
-
- $className = ltrim($class->name, '\\');
- $proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->_proxyNamespace);
- $parts = explode('\\', strrev($proxyClassName), 2);
- $proxyClassNamespace = strrev($parts[1]);
- $proxyClassName = strrev($parts[0]);
-
- $replacements = array(
- $proxyClassNamespace,
- $proxyClassName,
- $className,
- $methods,
- $sleepImpl,
- $cloneImpl
- );
+ $fqn = $this->getGenerator()->getProxyClass($this->em->getClassMetadata($className));
@guilhermeblanco Owner

Rename the variable. FQN is not obvious. Rule #5: Do not abbreviate.
I'd recommend: $proxyClassName.
Also, align the = signs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...rine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Functional;
+require_once __DIR__ . '/../../TestInit.php';
@stof
stof added a note

Do we really need this ? I thought it was useless since the switch to the XML config for phpunit (it is used as the phpunit bootstrap file).

Check that you don't have an outdate phpunit.xml file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/Doctrine/Tests/ORM/Proxy/ProxtFactoryTest.php
((6 lines not shown))
+use Doctrine\Common\Proxy\ProxyGenerator;
+use Doctrine\Tests\Mocks\ConnectionMock;
+use Doctrine\Tests\Mocks\EntityManagerMock;
+use Doctrine\Tests\Mocks\UnitOfWorkMock;
+
+require_once __DIR__ . '/../../TestInit.php';
+
+/**
+ * Test the proxy generator. Its work is generating on-the-fly subclasses of a given model, which implement the Proxy pattern.
+ * @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
+ */
+class ProxtFactoryTest extends \Doctrine\Tests\OrmTestCase
+{
+ private $_connectionMock;
+ private $_uowMock;
+ private $_emMock;
@stof
stof added a note

you should remove the underscores for these private properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ocramius
Owner

Mergeable (freezed at last commit before giant composer BC break)

@beberlei beberlei commented on the diff
lib/Doctrine/ORM/Proxy/ProxyFactory.php
((99 lines not shown))
*/
public function __construct(EntityManager $em, $proxyDir, $proxyNs, $autoGenerate = false)
{
- if ( ! $proxyDir) {
@beberlei Owner

Where did these exceptions go?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ocramius
Owner

Rebased on #570

@stof stof commented on the diff
lib/vendor/doctrine-common
@@ -1 +1 @@
-Subproject commit d514e3920656921ba1148f16a4089222c58bc83a
+Subproject commit d5843a462a4dfe4a42daf4645fc867c431a4170e
@stof
stof added a note

you are not removing the submodules

@Ocramius Owner

That must be first handled in #570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
.../Doctrine/Tests/ORM/Functional/Ticket/DDC1734Test.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace Doctrine\Tests\ORM\Functional\Ticket;
+
+use Doctrine\Tests\Models\DDC1734\DDC1734Article;
+
+require_once __DIR__ . '/../../../TestInit.php';
@stof
stof added a note

this line should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/Doctrine/Tests/ORM/Proxy/ProxtFactoryTest.php
@@ -0,0 +1,89 @@
+<?php
+
+namespace Doctrine\Tests\ORM\Proxy;
+
+use Doctrine\ORM\Proxy\ProxyFactory;
+use Doctrine\Common\Proxy\ProxyGenerator;
+use Doctrine\Tests\Mocks\ConnectionMock;
+use Doctrine\Tests\Mocks\EntityManagerMock;
+use Doctrine\Tests\Mocks\UnitOfWorkMock;
+use Doctrine\Tests\Mocks\DriverMock;
+
+require_once __DIR__ . '/../../TestInit.php';
@stof
stof added a note

this should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei beberlei merged commit afee16e into from
@Ocramius Ocramius deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.