public function init() { if (Yii::app()->db === null) { throw new CHttpException(500, 'An active "db" connection is required to run this generator.'); } parent::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(); }
/** * 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(); }