Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
22fa0d7c
Commit
22fa0d7c
authored
Feb 01, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing phpdoc for gii classes
parent
b78ae6d9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
0 deletions
+83
-0
CodeFile.php
extensions/gii/CodeFile.php
+17
-0
ActiveField.php
extensions/gii/components/ActiveField.php
+3
-0
DefaultController.php
extensions/gii/controllers/DefaultController.php
+10
-0
Generator.php
extensions/gii/generators/crud/Generator.php
+53
-0
No files found.
extensions/gii/CodeFile.php
View file @
22fa0d7c
...
...
@@ -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
))
{
...
...
extensions/gii/components/ActiveField.php
View file @
22fa0d7c
...
...
@@ -21,6 +21,9 @@ class ActiveField extends \yii\widgets\ActiveField
*/
public
$model
;
/**
* @inheritdoc
*/
public
function
init
()
{
$stickyAttributes
=
$this
->
model
->
stickyAttributes
();
...
...
extensions/gii/controllers/DefaultController.php
View file @
22fa0d7c
...
...
@@ -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
)
{
...
...
extensions/gii/generators/crud/Generator.php
View file @
22fa0d7c
...
...
@@ -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
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment