Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/16f3241c86ab0064c243 to your computer and use it in GitHub Desktop.
Save doctrinebot/16f3241c86ab0064c243 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-76 - https://github.com/doctrine/doctrine2/issues/5273
Index: lib/Doctrine/ORM/Configuration.php
===================================================================
--- lib/Doctrine/ORM/Configuration.php (revision 6579)
+++ lib/Doctrine/ORM/Configuration.php (working copy)
@@ -53,12 +53,6 @@
'autoGenerateProxyClasses' => true,
'proxyNamespace' => null
));
-
- //TODO: Move this to client code to avoid unnecessary work when a different metadata
- // driver is used.
- $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache);
- $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
- $this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
}
/**
@@ -126,10 +120,16 @@
/**
* Gets the cache driver implementation that is used for the mapping metadata.
*
- * @return object
+ * @return \Doctrine\ORM\Mapping\Driver\AbstractFileDriver
*/
public function getMetadataDriverImpl()
{
+ if(!isset($this->_attributes['metadataDriverImpl'])) {
+ $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache);
+ $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
+ $this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
+ }
+
return $this->_attributes['metadataDriverImpl'];
}
Index: lib/Doctrine/ORM/Configuration.php
===================================================================
--- lib/Doctrine/ORM/Configuration.php (revision 6579)
+++ lib/Doctrine/ORM/Configuration.php (working copy)
@@ -53,12 +53,6 @@
'autoGenerateProxyClasses' => true,
'proxyNamespace' => null
));
-
- //TODO: Move this to client code to avoid unnecessary work when a different metadata
- // driver is used.
- $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache);
- $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
- $this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
}
/**
@@ -126,10 +120,16 @@
/**
* Gets the cache driver implementation that is used for the mapping metadata.
*
- * @return object
+ * @return \Doctrine\ORM\Mapping\Driver\AbstractFileDriver
*/
public function getMetadataDriverImpl()
{
+ if(!isset($this->_attributes['metadataDriverImpl'])) {
+ $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache);
+ $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
+ $this->_attributes['metadataDriverImpl'] = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
+ }
+
return $this->_attributes['metadataDriverImpl'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment