Complex classes like Pool 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 Pool, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 24 | class Pool | ||
| 25 | { | ||
| 26 | /** | ||
| 27 | * @var ContainerInterface | ||
| 28 | */ | ||
| 29 | protected $container; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @var string[] | ||
| 33 | */ | ||
| 34 | protected $adminServiceIds = []; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * @var array | ||
| 38 | */ | ||
| 39 | protected $adminGroups = []; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * @var array | ||
| 43 | */ | ||
| 44 | protected $adminClasses = []; | ||
| 45 | |||
| 46 | /** | ||
| 47 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry "sonata.admin.global_template_registry" instead | ||
| 48 | * | ||
| 49 | * @var array | ||
| 50 | */ | ||
| 51 | protected $templates = []; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * @var array | ||
| 55 | */ | ||
| 56 | protected $assets = []; | ||
| 57 | |||
| 58 | /** | ||
| 59 | * @var string | ||
| 60 | */ | ||
| 61 | protected $title; | ||
| 62 | |||
| 63 | /** | ||
| 64 | * @var string | ||
| 65 | */ | ||
| 66 | protected $titleLogo; | ||
| 67 | |||
| 68 | /** | ||
| 69 | * @var array | ||
| 70 | */ | ||
| 71 | protected $options; | ||
| 72 | |||
| 73 | /** | ||
| 74 | * @var PropertyAccessorInterface | ||
| 75 | */ | ||
| 76 | protected $propertyAccessor; | ||
| 77 | |||
| 78 | /** | ||
| 79 | * @var MutableTemplateRegistryInterface | ||
| 80 | */ | ||
| 81 | private $templateRegistry; | ||
| 82 | |||
| 83 | /** | ||
| 84 | * @param string $title | ||
| 85 | * @param string $logoTitle | ||
| 86 | * @param array $options | ||
| 87 | */ | ||
| 88 | public function __construct( | ||
| 101 | |||
| 102 | /** | ||
| 103 | * @return array | ||
| 104 | */ | ||
| 105 | public function getGroups() | ||
| 117 | |||
| 118 | /** | ||
| 119 | * Returns whether an admin group exists or not. | ||
| 120 | * | ||
| 121 | * @param string $group | ||
| 122 | * | ||
| 123 | * @return bool | ||
| 124 | */ | ||
| 125 | public function hasGroup($group) | ||
| 129 | |||
| 130 | /** | ||
| 131 | * @return array | ||
| 132 | */ | ||
| 133 | public function getDashboardGroups() | ||
| 162 | |||
| 163 | /** | ||
| 164 | * Returns all admins related to the given $group. | ||
| 165 | * | ||
| 166 | * @param string $group | ||
| 167 | * | ||
| 168 | * @throws \InvalidArgumentException | ||
| 169 | * | ||
| 170 | * @return array | ||
| 171 | */ | ||
| 172 | public function getAdminsByGroup($group) | ||
| 190 | |||
| 191 | /** | ||
| 192 | * Return the admin related to the given $class. | ||
| 193 | * | ||
| 194 | * @param string $class | ||
| 195 | * | ||
| 196 | * @return \Sonata\AdminBundle\Admin\AdminInterface|null | ||
| 197 | */ | ||
| 198 | public function getAdminByClass($class) | ||
| 218 | |||
| 219 | /** | ||
| 220 | * @param string $class | ||
| 221 | * | ||
| 222 | * @return bool | ||
| 223 | */ | ||
| 224 | public function hasAdminByClass($class) | ||
| 228 | |||
| 229 | /** | ||
| 230 | * Returns an admin class by its Admin code | ||
| 231 | * ie : sonata.news.admin.post|sonata.news.admin.comment => return the child class of post. | ||
| 232 | * | ||
| 233 | * @param string $adminCode | ||
| 234 | * | ||
| 235 | * @return \Sonata\AdminBundle\Admin\AdminInterface|false|null | ||
| 236 | */ | ||
| 237 | public function getAdminByAdminCode($adminCode) | ||
| 262 | |||
| 263 | /** | ||
| 264 | * Returns a new admin instance depends on the given code. | ||
| 265 | * | ||
| 266 | * @param string $id | ||
| 267 | * | ||
| 268 | * @throws \InvalidArgumentException | ||
| 269 | * | ||
| 270 | * @return AdminInterface | ||
| 271 | */ | ||
| 272 | public function getInstance($id) | ||
| 304 | |||
| 305 | /** | ||
| 306 | * @return ContainerInterface|null | ||
| 307 | */ | ||
| 308 | public function getContainer() | ||
| 312 | |||
| 313 | public function setAdminGroups(array $adminGroups): void | ||
| 317 | |||
| 318 | /** | ||
| 319 | * @return array | ||
| 320 | */ | ||
| 321 | public function getAdminGroups() | ||
| 325 | |||
| 326 | public function setAdminServiceIds(array $adminServiceIds): void | ||
| 330 | |||
| 331 | /** | ||
| 332 | * @return array | ||
| 333 | */ | ||
| 334 | public function getAdminServiceIds() | ||
| 338 | |||
| 339 | public function setAdminClasses(array $adminClasses): void | ||
| 343 | |||
| 344 | /** | ||
| 345 | * @return array | ||
| 346 | */ | ||
| 347 | public function getAdminClasses() | ||
| 351 | |||
| 352 | final public function setTemplateRegistry(MutableTemplateRegistryInterface $templateRegistry): void | ||
| 356 | |||
| 357 | /** | ||
| 358 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry "sonata.admin.global_template_registry" instead | ||
| 359 | */ | ||
| 360 | public function setTemplates(array $templates): void | ||
| 367 | |||
| 368 | /** | ||
| 369 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry "sonata.admin.global_template_registry" instead | ||
| 370 | * | ||
| 371 | * @return array | ||
| 372 | */ | ||
| 373 | public function getTemplates() | ||
| 377 | |||
| 378 | /** | ||
| 379 | * @deprecated since 3.34, will be dropped in 4.0. Use TemplateRegistry "sonata.admin.global_template_registry" instead | ||
| 380 | * | ||
| 381 | * @param string $name | ||
| 382 | * | ||
| 383 | * @return null|string | ||
| 384 | */ | ||
| 385 | public function getTemplate($name) | ||
| 389 | |||
| 390 | /** | ||
| 391 | * @return string | ||
| 392 | */ | ||
| 393 | public function getTitleLogo() | ||
| 397 | |||
| 398 | /** | ||
| 399 | * @return string | ||
| 400 | */ | ||
| 401 | public function getTitle() | ||
| 405 | |||
| 406 | /** | ||
| 407 | * @param string $name | ||
| 408 | * @param mixed $default | ||
| 409 | * | ||
| 410 | * @return mixed | ||
| 411 | */ | ||
| 412 | public function getOption($name, $default = null) | ||
| 420 | |||
| 421 | public function getPropertyAccessor() | ||
| 429 | } | ||
| 430 | 
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.