私はCMSのJoomlaを使用していますが、パラメーターのセットをフォームJParameterにレンダリングするコアクラスがあります。基本的にrender()
、それは私のサイトの他の部分と一致しないいくつかのテーブルを含むHTMLを出力する機能を持っています。
保守性の問題について、そしてこれが他にどこで使用されているのかわからないので、コアコードを変更したくありません。理想的なのは、JParameterを拡張する新しいクラスを定義してから、$paramsオブジェクトをこの新しいサブクラスにキャストできることです。
// existing code --------------------
class JParameter {
function render() {
// return HTML with tables
}
// of course, there's a lot more functions here
}
// my magical class -----------------
class MyParameter extends JParameter {
function render() {
// return HTML which doesn't suck
}
}
// my code --------------------------
$this->params->render(); // returns tables
$this->params = (MyParameter) $this->params; // miracle occurs here?
$this->params->render(); // returns nice html