Complex classes like TemplateOverviewPage 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 TemplateOverviewPage, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 8 | |||
| 9 | class TemplateOverviewPage_Controller extends Page_Controller  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 10 | { | 
            ||
| 11 | private static $allowed_actions = array(  | 
            ||
| 12 | "showmore" => true,  | 
            ||
| 13 | "quicklist" => true,  | 
            ||
| 14 | "listofobjectsused" => true,  | 
            ||
| 15 | "clearalltemplatedescriptions" => "ADMIN"  | 
            ||
| 16 | );  | 
            ||
| 17 | |||
| 18 | public function init()  | 
            ||
| 33 | |||
| 34 | public function showmore($request)  | 
            ||
| 52 | |||
| 53 | |||
| 54 | public function ConfigurationDetails()  | 
            ||
| 71 | |||
| 72 | public function clearalltemplatedescriptions()  | 
            ||
| 81 | |||
| 82 | public function TestTaskLink()  | 
            ||
| 86 | |||
| 87 | public function QuickListLink()  | 
            ||
| 91 | |||
| 92 | public function ImagesListLink()  | 
            ||
| 96 | |||
| 97 | public function quicklist()  | 
            ||
| 104 | |||
| 105 | public function listofobjectsused($request)  | 
            ||
| 127 | }  | 
            ||
| 128 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.