Complex classes like NonProxyLoadingEntityManager often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use NonProxyLoadingEntityManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | class NonProxyLoadingEntityManager implements EntityManagerInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var EntityManagerInterface |
||
| 19 | */ |
||
| 20 | private $realEntityManager; |
||
| 21 | |||
| 22 | public function __construct(EntityManagerInterface $realEntityManager) |
||
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritDoc} |
||
| 29 | */ |
||
| 30 | public function getProxyFactory() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritDoc} |
||
| 37 | */ |
||
| 38 | public function getMetadataFactory() : \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritDoc} |
||
| 45 | */ |
||
| 46 | public function getClassMetadata($className) : ClassMetadata |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritDoc} |
||
| 53 | */ |
||
| 54 | public function getUnitOfWork() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritDoc} |
||
| 61 | */ |
||
| 62 | public function getCache() : ?\Doctrine\ORM\Cache |
||
| 66 | |||
| 67 | /** |
||
| 68 | * {@inheritDoc} |
||
| 69 | */ |
||
| 70 | public function getConnection() : \Doctrine\DBAL\Connection |
||
| 74 | |||
| 75 | /** |
||
| 76 | * {@inheritDoc} |
||
| 77 | */ |
||
| 78 | public function getExpressionBuilder() : \Doctrine\ORM\Query\Expr |
||
| 82 | |||
| 83 | /** |
||
| 84 | * {@inheritDoc} |
||
| 85 | */ |
||
| 86 | public function beginTransaction() : void |
||
| 90 | |||
| 91 | /** |
||
| 92 | * {@inheritDoc} |
||
| 93 | */ |
||
| 94 | public function transactional(callable $func) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * {@inheritDoc} |
||
| 101 | */ |
||
| 102 | public function commit() : void |
||
| 106 | |||
| 107 | /** |
||
| 108 | * {@inheritDoc} |
||
| 109 | */ |
||
| 110 | public function rollback() : void |
||
| 114 | |||
| 115 | /** |
||
| 116 | * {@inheritDoc} |
||
| 117 | */ |
||
| 118 | public function createQuery($dql = '') : \Doctrine\ORM\Query |
||
| 122 | |||
| 123 | /** |
||
| 124 | * {@inheritDoc} |
||
| 125 | */ |
||
| 126 | public function createNamedQuery($name) : \Doctrine\ORM\Query |
||
| 130 | |||
| 131 | /** |
||
| 132 | * {@inheritDoc} |
||
| 133 | */ |
||
| 134 | public function createNativeQuery($sql, ResultSetMapping $rsm) : \Doctrine\ORM\NativeQuery |
||
| 138 | |||
| 139 | /** |
||
| 140 | * {@inheritDoc} |
||
| 141 | */ |
||
| 142 | public function createNamedNativeQuery($name) : \Doctrine\ORM\NativeQuery |
||
| 146 | |||
| 147 | /** |
||
| 148 | * {@inheritDoc} |
||
| 149 | */ |
||
| 150 | public function createQueryBuilder() : \Doctrine\ORM\QueryBuilder |
||
| 154 | |||
| 155 | /** |
||
| 156 | * {@inheritDoc} |
||
| 157 | */ |
||
| 158 | public function getReference($entityName, $id) |
||
| 162 | |||
| 163 | /** |
||
| 164 | * {@inheritDoc} |
||
| 165 | */ |
||
| 166 | public function getPartialReference($entityName, $identifier) |
||
| 170 | |||
| 171 | /** |
||
| 172 | * {@inheritDoc} |
||
| 173 | */ |
||
| 174 | public function close() : void |
||
| 178 | |||
| 179 | /** |
||
| 180 | * {@inheritDoc} |
||
| 181 | */ |
||
| 182 | public function lock($entity, $lockMode, $lockVersion = null) : void |
||
| 186 | |||
| 187 | /** |
||
| 188 | * {@inheritDoc} |
||
| 189 | */ |
||
| 190 | public function getEventManager() : \Doctrine\Common\EventManager |
||
| 194 | |||
| 195 | /** |
||
| 196 | * {@inheritDoc} |
||
| 197 | */ |
||
| 198 | public function getConfiguration() : \Doctrine\ORM\Configuration |
||
| 202 | |||
| 203 | /** |
||
| 204 | * {@inheritDoc} |
||
| 205 | */ |
||
| 206 | public function isOpen() : bool |
||
| 210 | |||
| 211 | /** |
||
| 212 | * {@inheritDoc} |
||
| 213 | */ |
||
| 214 | public function getHydrator($hydrationMode) : \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
||
| 218 | |||
| 219 | /** |
||
| 220 | * {@inheritDoc} |
||
| 221 | */ |
||
| 222 | public function newHydrator($hydrationMode) : \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
||
| 226 | |||
| 227 | /** |
||
| 228 | * {@inheritDoc} |
||
| 229 | */ |
||
| 230 | public function getFilters() : \Doctrine\ORM\Query\FilterCollection |
||
| 234 | |||
| 235 | /** |
||
| 236 | * {@inheritDoc} |
||
| 237 | */ |
||
| 238 | public function isFiltersStateClean() : bool |
||
| 242 | |||
| 243 | /** |
||
| 244 | * {@inheritDoc} |
||
| 245 | */ |
||
| 246 | public function hasFilters() : bool |
||
| 250 | |||
| 251 | /** |
||
| 252 | * {@inheritDoc} |
||
| 253 | */ |
||
| 254 | public function find($className, $id) |
||
| 258 | |||
| 259 | /** |
||
| 260 | * {@inheritDoc} |
||
| 261 | */ |
||
| 262 | public function persist($object) : void |
||
| 266 | |||
| 267 | /** |
||
| 268 | * {@inheritDoc} |
||
| 269 | */ |
||
| 270 | public function remove($object) : void |
||
| 274 | |||
| 275 | /** |
||
| 276 | * {@inheritDoc} |
||
| 277 | */ |
||
| 278 | public function clear($objectName = null) : void |
||
| 282 | |||
| 283 | /** |
||
| 284 | * {@inheritDoc} |
||
| 285 | * |
||
| 286 | * @deprecated |
||
| 287 | */ |
||
| 288 | public function merge($object) |
||
| 292 | |||
| 293 | /** |
||
| 294 | * {@inheritDoc} |
||
| 295 | * |
||
| 296 | * @deprecated |
||
| 297 | */ |
||
| 298 | public function detach($object) : void |
||
| 302 | |||
| 303 | /** |
||
| 304 | * {@inheritDoc} |
||
| 305 | */ |
||
| 306 | public function refresh($object) : void |
||
| 310 | |||
| 311 | /** |
||
| 312 | * {@inheritDoc} |
||
| 313 | */ |
||
| 314 | public function flush() : void |
||
| 318 | |||
| 319 | /** |
||
| 320 | * {@inheritDoc} |
||
| 321 | */ |
||
| 322 | public function getRepository($className) : \Doctrine\Common\Persistence\ObjectRepository |
||
| 326 | |||
| 327 | /** |
||
| 328 | * {@inheritDoc} |
||
| 329 | */ |
||
| 330 | public function initializeObject($obj) : void |
||
| 334 | |||
| 335 | /** |
||
| 336 | * {@inheritDoc} |
||
| 337 | */ |
||
| 338 | public function contains($object) : bool |
||
| 342 | |||
| 343 | /** |
||
| 344 | * {@inheritDoc} |
||
| 345 | */ |
||
| 346 | public function getIdentifierFlattener() : \Doctrine\ORM\Utility\IdentifierFlattener |
||
| 350 | } |
||
| 351 |
This method has been deprecated.