Complex classes like CKEditorRenderer 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 CKEditorRenderer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 25 | class CKEditorRenderer implements CKEditorRendererInterface |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * @var ContainerInterface |
||
| 29 | */ |
||
| 30 | private $container; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param ContainerInterface $container |
||
| 34 | */ |
||
| 35 | 711 | public function __construct(ContainerInterface $container) |
|
| 36 | { |
||
| 37 | 711 | $this->container = $container; |
|
| 38 | 711 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | 90 | public function renderBasePath($basePath) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | 81 | public function renderJsPath($jsPath) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | 549 | public function renderWidget($id, array $config, array $options = []) |
|
| 91 | |||
| 92 | /** |
||
| 93 | * {@inheritdoc} |
||
| 94 | */ |
||
| 95 | 99 | public function renderDestroy($id) |
|
| 105 | |||
| 106 | /** |
||
| 107 | * {@inheritdoc} |
||
| 108 | */ |
||
| 109 | 36 | public function renderPlugin($name, array $plugin) |
|
| 118 | |||
| 119 | /** |
||
| 120 | * {@inheritdoc} |
||
| 121 | */ |
||
| 122 | 27 | public function renderStylesSet($name, array $stylesSet) |
|
| 132 | |||
| 133 | /** |
||
| 134 | * {@inheritdoc} |
||
| 135 | */ |
||
| 136 | 72 | public function renderTemplate($name, array $template) |
|
| 162 | |||
| 163 | /** |
||
| 164 | * @param array $config |
||
| 165 | * |
||
| 166 | * @return array |
||
| 167 | */ |
||
| 168 | 549 | private function fixConfigLanguage(array $config) |
|
| 180 | |||
| 181 | /** |
||
| 182 | * @param array $config |
||
| 183 | * |
||
| 184 | * @return array |
||
| 185 | */ |
||
| 186 | 549 | private function fixConfigContentsCss(array $config) |
|
| 199 | |||
| 200 | /** |
||
| 201 | * @param array $config |
||
| 202 | * @param array $filebrowsers |
||
| 203 | * |
||
| 204 | * @return array |
||
| 205 | */ |
||
| 206 | 549 | private function fixConfigFilebrowsers(array $config, array $filebrowsers) |
|
| 244 | |||
| 245 | /** |
||
| 246 | * @param JsonBuilder $builder |
||
| 247 | * @param array $config |
||
| 248 | */ |
||
| 249 | 549 | private function fixConfigEscapedValues(JsonBuilder $builder, array $config) |
|
| 268 | |||
| 269 | /** |
||
| 270 | * @param string $json |
||
| 271 | * |
||
| 272 | * @return string |
||
| 273 | */ |
||
| 274 | 549 | private function fixConfigConstants($json) |
|
| 278 | |||
| 279 | /** |
||
| 280 | * @param string $path |
||
| 281 | * |
||
| 282 | * @return string |
||
| 283 | */ |
||
| 284 | 234 | private function fixPath($path) |
|
| 292 | |||
| 293 | /** |
||
| 294 | * @param string $url |
||
| 295 | * |
||
| 296 | * @return string |
||
| 297 | */ |
||
| 298 | 243 | private function fixUrl($url) |
|
| 302 | |||
| 303 | /** |
||
| 304 | * @return JsonBuilder |
||
| 305 | */ |
||
| 306 | 612 | private function getJsonBuilder() |
|
| 310 | |||
| 311 | /** |
||
| 312 | * @return string|null |
||
| 313 | */ |
||
| 314 | 531 | private function getLanguage() |
|
| 324 | |||
| 325 | /** |
||
| 326 | * @return Request|null |
||
| 327 | */ |
||
| 328 | 531 | private function getRequest() |
|
| 332 | |||
| 333 | /** |
||
| 334 | * @return \Twig_Environment|EngineInterface |
||
| 335 | */ |
||
| 336 | 36 | private function getTemplating() |
|
| 342 | |||
| 343 | /** |
||
| 344 | * @return Packages|null |
||
| 345 | */ |
||
| 346 | 243 | private function getAssets() |
|
| 350 | |||
| 351 | /** |
||
| 352 | * @return RouterInterface |
||
| 353 | */ |
||
| 354 | 189 | private function getRouter() |
|
| 358 | } |
||
| 359 |