Commit 22fa0d7c by Alexander Makarov

Added missing phpdoc for gii classes

parent b78ae6d9
......@@ -123,6 +123,11 @@ class CodeFile extends Object
}
}
/**
* Returns preview or false if it cannot be rendered
*
* @return boolean|string
*/
public function preview()
{
if (($pos = strrpos($this->path, '.')) !== false) {
......@@ -140,6 +145,11 @@ class CodeFile extends Object
}
}
/**
* Returns diff or false if it cannot be calculated
*
* @return boolean|string
*/
public function diff()
{
$type = strtolower($this->getType());
......@@ -152,6 +162,13 @@ class CodeFile extends Object
}
}
/**
* Renders diff between two sets of lines
*
* @param mixed $lines1
* @param mixed $lines2
* @return string
*/
private function renderDiff($lines1, $lines2)
{
if (!is_array($lines1)) {
......
......@@ -21,6 +21,9 @@ class ActiveField extends \yii\widgets\ActiveField
*/
public $model;
/**
* @inheritdoc
*/
public function init()
{
$stickyAttributes = $this->model->stickyAttributes();
......
......@@ -107,6 +107,9 @@ class DefaultController extends Controller
}
}
/**
* @inheritdoc
*/
public function createUrl($route, $params = [])
{
if (!isset($params['id']) && $this->generator !== null) {
......@@ -120,6 +123,13 @@ class DefaultController extends Controller
return parent::createUrl($route, $params);
}
/**
* Creates URL for an aciton
*
* @param string $name name of the action
* @param array $params the parameters (name-value pairs) to be included in the generated URL
* @return string the created relative URL
*/
public function createActionUrl($name, $params = [])
{
foreach ($this->module->generators as $id => $generator) {
......
......@@ -33,17 +33,26 @@ class Generator extends \yii\gii\Generator
public $indexWidgetType = 'grid';
public $searchModelClass;
/**
* @inheritdoc
*/
public function getName()
{
return 'CRUD Generator';
}
/**
* @inheritdoc
*/
public function getDescription()
{
return 'This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete)
operations for the specified data model.';
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
......@@ -61,6 +70,9 @@ class Generator extends \yii\gii\Generator
]);
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
......@@ -94,6 +106,9 @@ class Generator extends \yii\gii\Generator
];
}
/**
* @inheritdoc
*/
public function requiredTemplates()
{
return ['controller.php'];
......@@ -107,6 +122,9 @@ class Generator extends \yii\gii\Generator
return ['baseControllerClass', 'moduleID', 'indexWidgetType'];
}
/**
* Checks if model class is valid
*/
public function validateModelClass()
{
/** @var ActiveRecord $class */
......@@ -117,6 +135,9 @@ class Generator extends \yii\gii\Generator
}
}
/**
* Checks if model ID is valid
*/
public function validateModuleID()
{
if (!empty($this->moduleID)) {
......@@ -184,6 +205,7 @@ class Generator extends \yii\gii\Generator
}
/**
* Generates code for active field
* @param string $attribute
* @return string
*/
......@@ -217,6 +239,7 @@ class Generator extends \yii\gii\Generator
}
/**
* Generates code for active search field
* @param string $attribute
* @return string
*/
......@@ -235,6 +258,7 @@ class Generator extends \yii\gii\Generator
}
/**
* Generates column format
* @param \yii\db\ColumnSchema $column
* @return string
*/
......@@ -298,6 +322,9 @@ class Generator extends \yii\gii\Generator
return $rules;
}
/**
* @return array searchable attributes
*/
public function getSearchAttributes()
{
return $this->getColumnNames();
......@@ -309,6 +336,7 @@ class Generator extends \yii\gii\Generator
*/
public function generateSearchLabels()
{
/** @var \yii\base\Model $model */
$model = new $this->modelClass();
$attributeLabels = $model->attributeLabels();
$labels = [];
......@@ -330,11 +358,16 @@ class Generator extends \yii\gii\Generator
return $labels;
}
/**
* Generates search conditions
* @return array
*/
public function generateSearchConditions()
{
$columns = [];
if (($table = $this->getTableSchema()) === false) {
$class = $this->modelClass;
/** @var \yii\base\Model $model */
$model = new $class();
foreach ($model->attributes() as $attribute) {
$columns[$attribute] = 'unknown';
......@@ -369,6 +402,10 @@ class Generator extends \yii\gii\Generator
return $conditions;
}
/**
* Generates URL parameters
* @return string
*/
public function generateUrlParams()
{
/** @var ActiveRecord $class */
......@@ -385,6 +422,10 @@ class Generator extends \yii\gii\Generator
}
}
/**
* Generates action parameters
* @return string
*/
public function generateActionParams()
{
/** @var ActiveRecord $class */
......@@ -397,6 +438,10 @@ class Generator extends \yii\gii\Generator
}
}
/**
* Generates parameter tags for phpdoc
* @return array parameter tags for phpdoc
*/
public function generateActionParamComments()
{
/** @var ActiveRecord $class */
......@@ -420,6 +465,10 @@ class Generator extends \yii\gii\Generator
}
}
/**
* Returns table schema for current model class or false if it is not an active record
* @return boolean|\yii\db\TableSchema
*/
public function getTableSchema()
{
/** @var ActiveRecord $class */
......@@ -431,6 +480,9 @@ class Generator extends \yii\gii\Generator
}
}
/**
* @return array model column names
*/
public function getColumnNames()
{
/** @var ActiveRecord $class */
......@@ -438,6 +490,7 @@ class Generator extends \yii\gii\Generator
if (is_subclass_of($class, 'yii\db\ActiveRecord')) {
return $class::getTableSchema()->getColumnNames();
} else {
/** @var \yii\base\Model $model */
$model = new $class();
return $model->attributes();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment