Skip to content

Instantly share code, notes, and snippets.

@crisu83
Last active December 14, 2015 12:59
Show Gist options
  • Select an option

  • Save crisu83/5090534 to your computer and use it in GitHub Desktop.

Select an option

Save crisu83/5090534 to your computer and use it in GitHub Desktop.
Random thoughts about using namespacing for the HTML helper in Yiistrap.
<?php
/* Core implementation */
// Helper
namespace bootstrap\helpers;
class Html extends \CHtml {
public static function someStaticHelperMethod() {
// core implementation
}
}
// Active form
use bootstrap\helpers\Html;
class TbActiveForm extends CActiveForm {
function someMethod() {
return Html::someStaticHelperMethod(); // calls the core implementation
}
}
/* Custom implementation */
// Helper
namespace app\helpers;
class Html extends \bootstrap\helpers\Html {
public static function someStaticHelperMethod() {
// overridden method
}
}
// Active form
use app\helpers\Html;
class ActiveForm extends TbActiveForm {
function someMethod() {
return Html::someStaticHelperMethod(); // calls the overridden method
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment