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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
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
...
@@ -123,6 +123,11 @@ class CodeFile extends Object
}
}
}
}
/**
* Returns preview or false if it cannot be rendered
*
* @return boolean|string
*/
public
function
preview
()
public
function
preview
()
{
{
if
((
$pos
=
strrpos
(
$this
->
path
,
'.'
))
!==
false
)
{
if
((
$pos
=
strrpos
(
$this
->
path
,
'.'
))
!==
false
)
{
...
@@ -140,6 +145,11 @@ class CodeFile extends Object
...
@@ -140,6 +145,11 @@ class CodeFile extends Object
}
}
}
}
/**
* Returns diff or false if it cannot be calculated
*
* @return boolean|string
*/
public
function
diff
()
public
function
diff
()
{
{
$type
=
strtolower
(
$this
->
getType
());
$type
=
strtolower
(
$this
->
getType
());
...
@@ -152,6 +162,13 @@ class CodeFile extends Object
...
@@ -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
)
private
function
renderDiff
(
$lines1
,
$lines2
)
{
{
if
(
!
is_array
(
$lines1
))
{
if
(
!
is_array
(
$lines1
))
{
...
...
extensions/gii/components/ActiveField.php
View file @
22fa0d7c
...
@@ -21,6 +21,9 @@ class ActiveField extends \yii\widgets\ActiveField
...
@@ -21,6 +21,9 @@ class ActiveField extends \yii\widgets\ActiveField
*/
*/
public
$model
;
public
$model
;
/**
* @inheritdoc
*/
public
function
init
()
public
function
init
()
{
{
$stickyAttributes
=
$this
->
model
->
stickyAttributes
();
$stickyAttributes
=
$this
->
model
->
stickyAttributes
();
...
...
extensions/gii/controllers/DefaultController.php
View file @
22fa0d7c
...
@@ -107,6 +107,9 @@ class DefaultController extends Controller
...
@@ -107,6 +107,9 @@ class DefaultController extends Controller
}
}
}
}
/**
* @inheritdoc
*/
public
function
createUrl
(
$route
,
$params
=
[])
public
function
createUrl
(
$route
,
$params
=
[])
{
{
if
(
!
isset
(
$params
[
'id'
])
&&
$this
->
generator
!==
null
)
{
if
(
!
isset
(
$params
[
'id'
])
&&
$this
->
generator
!==
null
)
{
...
@@ -120,6 +123,13 @@ class DefaultController extends Controller
...
@@ -120,6 +123,13 @@ class DefaultController extends Controller
return
parent
::
createUrl
(
$route
,
$params
);
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
=
[])
public
function
createActionUrl
(
$name
,
$params
=
[])
{
{
foreach
(
$this
->
module
->
generators
as
$id
=>
$generator
)
{
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
...
@@ -33,17 +33,26 @@ class Generator extends \yii\gii\Generator
public
$indexWidgetType
=
'grid'
;
public
$indexWidgetType
=
'grid'
;
public
$searchModelClass
;
public
$searchModelClass
;
/**
* @inheritdoc
*/
public
function
getName
()
public
function
getName
()
{
{
return
'CRUD Generator'
;
return
'CRUD Generator'
;
}
}
/**
* @inheritdoc
*/
public
function
getDescription
()
public
function
getDescription
()
{
{
return
'This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete)
return
'This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete)
operations for the specified data model.'
;
operations for the specified data model.'
;
}
}
/**
* @inheritdoc
*/
public
function
rules
()
public
function
rules
()
{
{
return
array_merge
(
parent
::
rules
(),
[
return
array_merge
(
parent
::
rules
(),
[
...
@@ -61,6 +70,9 @@ class Generator extends \yii\gii\Generator
...
@@ -61,6 +70,9 @@ class Generator extends \yii\gii\Generator
]);
]);
}
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
public
function
attributeLabels
()
{
{
return
array_merge
(
parent
::
attributeLabels
(),
[
return
array_merge
(
parent
::
attributeLabels
(),
[
...
@@ -94,6 +106,9 @@ class Generator extends \yii\gii\Generator
...
@@ -94,6 +106,9 @@ class Generator extends \yii\gii\Generator
];
];
}
}
/**
* @inheritdoc
*/
public
function
requiredTemplates
()
public
function
requiredTemplates
()
{
{
return
[
'controller.php'
];
return
[
'controller.php'
];
...
@@ -107,6 +122,9 @@ class Generator extends \yii\gii\Generator
...
@@ -107,6 +122,9 @@ class Generator extends \yii\gii\Generator
return
[
'baseControllerClass'
,
'moduleID'
,
'indexWidgetType'
];
return
[
'baseControllerClass'
,
'moduleID'
,
'indexWidgetType'
];
}
}
/**
* Checks if model class is valid
*/
public
function
validateModelClass
()
public
function
validateModelClass
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -117,6 +135,9 @@ class Generator extends \yii\gii\Generator
...
@@ -117,6 +135,9 @@ class Generator extends \yii\gii\Generator
}
}
}
}
/**
* Checks if model ID is valid
*/
public
function
validateModuleID
()
public
function
validateModuleID
()
{
{
if
(
!
empty
(
$this
->
moduleID
))
{
if
(
!
empty
(
$this
->
moduleID
))
{
...
@@ -184,6 +205,7 @@ class Generator extends \yii\gii\Generator
...
@@ -184,6 +205,7 @@ class Generator extends \yii\gii\Generator
}
}
/**
/**
* Generates code for active field
* @param string $attribute
* @param string $attribute
* @return string
* @return string
*/
*/
...
@@ -217,6 +239,7 @@ class Generator extends \yii\gii\Generator
...
@@ -217,6 +239,7 @@ class Generator extends \yii\gii\Generator
}
}
/**
/**
* Generates code for active search field
* @param string $attribute
* @param string $attribute
* @return string
* @return string
*/
*/
...
@@ -235,6 +258,7 @@ class Generator extends \yii\gii\Generator
...
@@ -235,6 +258,7 @@ class Generator extends \yii\gii\Generator
}
}
/**
/**
* Generates column format
* @param \yii\db\ColumnSchema $column
* @param \yii\db\ColumnSchema $column
* @return string
* @return string
*/
*/
...
@@ -298,6 +322,9 @@ class Generator extends \yii\gii\Generator
...
@@ -298,6 +322,9 @@ class Generator extends \yii\gii\Generator
return
$rules
;
return
$rules
;
}
}
/**
* @return array searchable attributes
*/
public
function
getSearchAttributes
()
public
function
getSearchAttributes
()
{
{
return
$this
->
getColumnNames
();
return
$this
->
getColumnNames
();
...
@@ -309,6 +336,7 @@ class Generator extends \yii\gii\Generator
...
@@ -309,6 +336,7 @@ class Generator extends \yii\gii\Generator
*/
*/
public
function
generateSearchLabels
()
public
function
generateSearchLabels
()
{
{
/** @var \yii\base\Model $model */
$model
=
new
$this
->
modelClass
();
$model
=
new
$this
->
modelClass
();
$attributeLabels
=
$model
->
attributeLabels
();
$attributeLabels
=
$model
->
attributeLabels
();
$labels
=
[];
$labels
=
[];
...
@@ -330,11 +358,16 @@ class Generator extends \yii\gii\Generator
...
@@ -330,11 +358,16 @@ class Generator extends \yii\gii\Generator
return
$labels
;
return
$labels
;
}
}
/**
* Generates search conditions
* @return array
*/
public
function
generateSearchConditions
()
public
function
generateSearchConditions
()
{
{
$columns
=
[];
$columns
=
[];
if
((
$table
=
$this
->
getTableSchema
())
===
false
)
{
if
((
$table
=
$this
->
getTableSchema
())
===
false
)
{
$class
=
$this
->
modelClass
;
$class
=
$this
->
modelClass
;
/** @var \yii\base\Model $model */
$model
=
new
$class
();
$model
=
new
$class
();
foreach
(
$model
->
attributes
()
as
$attribute
)
{
foreach
(
$model
->
attributes
()
as
$attribute
)
{
$columns
[
$attribute
]
=
'unknown'
;
$columns
[
$attribute
]
=
'unknown'
;
...
@@ -369,6 +402,10 @@ class Generator extends \yii\gii\Generator
...
@@ -369,6 +402,10 @@ class Generator extends \yii\gii\Generator
return
$conditions
;
return
$conditions
;
}
}
/**
* Generates URL parameters
* @return string
*/
public
function
generateUrlParams
()
public
function
generateUrlParams
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -385,6 +422,10 @@ class Generator extends \yii\gii\Generator
...
@@ -385,6 +422,10 @@ class Generator extends \yii\gii\Generator
}
}
}
}
/**
* Generates action parameters
* @return string
*/
public
function
generateActionParams
()
public
function
generateActionParams
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -397,6 +438,10 @@ class Generator extends \yii\gii\Generator
...
@@ -397,6 +438,10 @@ class Generator extends \yii\gii\Generator
}
}
}
}
/**
* Generates parameter tags for phpdoc
* @return array parameter tags for phpdoc
*/
public
function
generateActionParamComments
()
public
function
generateActionParamComments
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -420,6 +465,10 @@ class Generator extends \yii\gii\Generator
...
@@ -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
()
public
function
getTableSchema
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -431,6 +480,9 @@ class Generator extends \yii\gii\Generator
...
@@ -431,6 +480,9 @@ class Generator extends \yii\gii\Generator
}
}
}
}
/**
* @return array model column names
*/
public
function
getColumnNames
()
public
function
getColumnNames
()
{
{
/** @var ActiveRecord $class */
/** @var ActiveRecord $class */
...
@@ -438,6 +490,7 @@ class Generator extends \yii\gii\Generator
...
@@ -438,6 +490,7 @@ class Generator extends \yii\gii\Generator
if
(
is_subclass_of
(
$class
,
'yii\db\ActiveRecord'
))
{
if
(
is_subclass_of
(
$class
,
'yii\db\ActiveRecord'
))
{
return
$class
::
getTableSchema
()
->
getColumnNames
();
return
$class
::
getTableSchema
()
->
getColumnNames
();
}
else
{
}
else
{
/** @var \yii\base\Model $model */
$model
=
new
$class
();
$model
=
new
$class
();
return
$model
->
attributes
();
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