File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1515namespace Doctrine \Bundle \MongoDBBundle \CacheWarmer ;
1616
1717use Doctrine \Common \Proxy \AbstractProxyFactory ;
18+ use Doctrine \ODM \MongoDB \DocumentManager ;
19+ use Doctrine \ODM \MongoDB \Mapping \ClassMetadata ;
1820use Symfony \Component \DependencyInjection \ContainerInterface ;
1921use Symfony \Component \HttpKernel \CacheWarmer \CacheWarmerInterface ;
2022
@@ -72,8 +74,20 @@ public function warmUp($cacheDir)
7274 $ registry = $ this ->container ->get ('doctrine_mongodb ' );
7375 foreach ($ registry ->getManagers () as $ dm ) {
7476 /* @var $dm \Doctrine\ODM\MongoDB\DocumentManager */
75- $ classes = $ dm -> getMetadataFactory ()-> getAllMetadata ( );
77+ $ classes = $ this -> getClassesForProxyGeneration ( $ dm );
7678 $ dm ->getProxyFactory ()->generateProxyClasses ($ classes );
7779 }
7880 }
81+
82+ /**
83+ * @param DocumentManager $dm
84+ *
85+ * @return ClassMetadata[]
86+ */
87+ private function getClassesForProxyGeneration (DocumentManager $ dm )
88+ {
89+ return array_filter ($ dm ->getMetadataFactory ()->getAllMetadata (), function (ClassMetadata $ metadata ) {
90+ return !$ metadata ->isEmbeddedDocument && !$ metadata ->isMappedSuperclass ;
91+ });
92+ }
7993}
Original file line number Diff line number Diff line change @@ -60,7 +60,11 @@ public function testWarmerNotOptional()
6060
6161 public function testWarmerExecuted ()
6262 {
63- $ this ->proxyMock ->expects ($ this ->once ())->method ('generateProxyClasses ' );
63+ $ this ->proxyMock
64+ ->expects ($ this ->once ())
65+ ->method ('generateProxyClasses ' )
66+ ->with ($ this ->countOf (1 ))
67+ ;
6468 $ this ->warmer ->warmUp ('meh ' );
6569 }
6670
@@ -82,4 +86,4 @@ public function provideWarmerNotExecuted()
8286 [ Configuration::AUTOGENERATE_FILE_NOT_EXISTS ],
8387 ];
8488 }
85- }
89+ }
You can’t perform that action at this time.
0 commit comments