本文整理汇总了PHP中CCodeModel::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CCodeModel::init方法的具体用法?PHP CCodeModel::init怎么用?PHP CCodeModel::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodeModel
的用法示例。
在下文中一共展示了CCodeModel::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if (Yii::app()->db === null) {
throw new CHttpException(500, 'An active "db" connection is required to run this generator.');
}
parent::init();
}
示例2: init
public function init()
{
if (Yii::app()->{$this->connectionId} === null) {
throw new CHttpException(500, 'A valid database connection is required to run this generator.');
}
$this->tablePrefix = Yii::app()->{$this->connectionId}->tablePrefix;
parent::init();
}
示例3: init
/**
* Runs on object initiation
*/
public function init()
{
// Check database connection
if (Yii::app()->db === null) {
throw new CHttpException(500, 'An active "db" connection is required to run this generator.');
}
// Check that reset button has been pressed
if (isset($_POST['reset'])) {
$this->resetGenerator();
}
// Refresh element name from session variable if on second pass
if (isset(Yii::app()->session['elementName'])) {
$this->elementName = Yii::app()->session['elementName'];
} else {
$this->elementName = "";
}
// Refresh table name from session variable if on second pass
if (isset(Yii::app()->session['tableName'])) {
$this->tableName = Yii::app()->session['tableName'];
$this->modelClass = $this->generateClassName($this->tableName);
} else {
$this->tableName = "";
}
// Set default variables
$this->elementFields = "'value' => 'string',";
$this->controllerClass = $this->generateControllerName($this->modelClass);
$this->baseControllerClass = 'Controller';
$this->modelPath = 'application.models.elements';
$this->baseClass = 'BaseElement';
$this->ignore = array('id', 'event_id', 'created_user_id', 'created_date', 'last_modified_user_id', 'last_modified_date');
$this->migrationPath = 'application.migrations';
$this->authorName = Yii::app()->params['authorName'];
$this->authorEmail = Yii::app()->params['authorEmail'];
// Set progress level
if (isset(Yii::app()->session['level'])) {
$this->level = Yii::app()->session['level'];
} else {
$this->level = self::CREATE_MIGRATION;
}
parent::init();
}