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
3eb90c54
Commit
3eb90c54
authored
Mar 21, 2014
by
Luciano Baraglia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable I18N for GII model generator
parent
7c36fa93
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
gii.js
extensions/gii/assets/gii.js
+3
-3
Generator.php
extensions/gii/generators/model/Generator.php
+7
-5
model.php
extensions/gii/generators/model/default/model.php
+1
-1
form.php
extensions/gii/generators/model/form.php
+2
-0
No files found.
extensions/gii/assets/gii.js
View file @
3eb90c54
...
@@ -115,9 +115,9 @@ yii.gii = (function ($) {
...
@@ -115,9 +115,9 @@ yii.gii = (function ($) {
$
(
'#model-generator .field-generator-modelclass'
).
toggle
(
$
(
this
).
val
().
indexOf
(
'*'
)
==
-
1
);
$
(
'#model-generator .field-generator-modelclass'
).
toggle
(
$
(
this
).
val
().
indexOf
(
'*'
)
==
-
1
);
}).
change
();
}).
change
();
//
CRUD generator: hide messageC
ategory when I18N is disabled
//
hide message c
ategory when I18N is disabled
$
(
'
#crud-generator
#generator-enablei18n'
).
change
(
function
()
{
$
(
'
form
#generator-enablei18n'
).
change
(
function
()
{
$
(
'
#crud-generator
.field-generator-messagecategory'
).
toggle
(
$
(
this
).
is
(
':checked'
));
$
(
'
form
.field-generator-messagecategory'
).
toggle
(
$
(
this
).
is
(
':checked'
));
}).
change
();
}).
change
();
// hide Generate button if any input is changed
// hide Generate button if any input is changed
...
...
extensions/gii/generators/model/Generator.php
View file @
3eb90c54
...
@@ -64,6 +64,8 @@ class Generator extends \yii\gii\Generator
...
@@ -64,6 +64,8 @@ class Generator extends \yii\gii\Generator
[[
'modelClass'
],
'validateModelClass'
,
'skipOnEmpty'
=>
false
],
[[
'modelClass'
],
'validateModelClass'
,
'skipOnEmpty'
=>
false
],
[[
'baseClass'
],
'validateClass'
,
'params'
=>
[
'extends'
=>
ActiveRecord
::
className
()]],
[[
'baseClass'
],
'validateClass'
,
'params'
=>
[
'extends'
=>
ActiveRecord
::
className
()]],
[[
'generateRelations'
,
'generateLabelsFromComments'
],
'boolean'
],
[[
'generateRelations'
,
'generateLabelsFromComments'
],
'boolean'
],
[[
'enableI18N'
],
'boolean'
],
[[
'messageCategory'
],
'validateMessageCategory'
,
'skipOnEmpty'
=>
false
],
]);
]);
}
}
...
@@ -72,7 +74,7 @@ class Generator extends \yii\gii\Generator
...
@@ -72,7 +74,7 @@ class Generator extends \yii\gii\Generator
*/
*/
public
function
attributeLabels
()
public
function
attributeLabels
()
{
{
return
[
return
array_merge
(
parent
::
attributeLabels
(),
[
'ns'
=>
'Namespace'
,
'ns'
=>
'Namespace'
,
'db'
=>
'Database Connection ID'
,
'db'
=>
'Database Connection ID'
,
'tableName'
=>
'Table Name'
,
'tableName'
=>
'Table Name'
,
...
@@ -80,7 +82,7 @@ class Generator extends \yii\gii\Generator
...
@@ -80,7 +82,7 @@ class Generator extends \yii\gii\Generator
'baseClass'
=>
'Base Class'
,
'baseClass'
=>
'Base Class'
,
'generateRelations'
=>
'Generate Relations'
,
'generateRelations'
=>
'Generate Relations'
,
'generateLabelsFromComments'
=>
'Generate Labels from DB Comments'
,
'generateLabelsFromComments'
=>
'Generate Labels from DB Comments'
,
];
]
)
;
}
}
/**
/**
...
@@ -88,7 +90,7 @@ class Generator extends \yii\gii\Generator
...
@@ -88,7 +90,7 @@ class Generator extends \yii\gii\Generator
*/
*/
public
function
hints
()
public
function
hints
()
{
{
return
[
return
array_merge
(
parent
::
hints
(),
[
'ns'
=>
'This is the namespace of the ActiveRecord class to be generated, e.g., <code>app\models</code>'
,
'ns'
=>
'This is the namespace of the ActiveRecord class to be generated, e.g., <code>app\models</code>'
,
'db'
=>
'This is the ID of the DB application component.'
,
'db'
=>
'This is the ID of the DB application component.'
,
'tableName'
=>
'This is the name of the DB table that the new ActiveRecord class is associated with, e.g. <code>tbl_post</code>.
'tableName'
=>
'This is the name of the DB table that the new ActiveRecord class is associated with, e.g. <code>tbl_post</code>.
...
@@ -107,7 +109,7 @@ class Generator extends \yii\gii\Generator
...
@@ -107,7 +109,7 @@ class Generator extends \yii\gii\Generator
you may want to uncheck this option to accelerate the code generation process.'
,
you may want to uncheck this option to accelerate the code generation process.'
,
'generateLabelsFromComments'
=>
'This indicates whether the generator should generate attribute labels
'generateLabelsFromComments'
=>
'This indicates whether the generator should generate attribute labels
by using the comments of the corresponding DB columns.'
,
by using the comments of the corresponding DB columns.'
,
];
]
)
;
}
}
/**
/**
...
@@ -140,7 +142,7 @@ class Generator extends \yii\gii\Generator
...
@@ -140,7 +142,7 @@ class Generator extends \yii\gii\Generator
*/
*/
public
function
stickyAttributes
()
public
function
stickyAttributes
()
{
{
return
[
'ns'
,
'db'
,
'baseClass'
,
'generateRelations'
,
'generateLabelsFromComments'
]
;
return
array_merge
(
parent
::
stickyAttributes
(),
[
'ns'
,
'db'
,
'baseClass'
,
'generateRelations'
,
'generateLabelsFromComments'
])
;
}
}
/**
/**
...
...
extensions/gii/generators/model/default/model.php
View file @
3eb90c54
...
@@ -55,7 +55,7 @@ class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') .
...
@@ -55,7 +55,7 @@ class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') .
{
{
return [
return [
<?php
foreach
(
$labels
as
$name
=>
$label
)
:
?>
<?php
foreach
(
$labels
as
$name
=>
$label
)
:
?>
<?=
"'
$name
' =>
'"
.
addslashes
(
$label
)
.
"'
,
\n
"
?>
<?=
"'
$name
' =>
"
.
$generator
->
generateString
(
$label
)
.
"
,
\n
"
?>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
];
];
}
}
...
...
extensions/gii/generators/model/form.php
View file @
3eb90c54
...
@@ -12,3 +12,5 @@ echo $form->field($generator, 'baseClass');
...
@@ -12,3 +12,5 @@ echo $form->field($generator, 'baseClass');
echo
$form
->
field
(
$generator
,
'db'
);
echo
$form
->
field
(
$generator
,
'db'
);
echo
$form
->
field
(
$generator
,
'generateRelations'
)
->
checkbox
();
echo
$form
->
field
(
$generator
,
'generateRelations'
)
->
checkbox
();
echo
$form
->
field
(
$generator
,
'generateLabelsFromComments'
)
->
checkbox
();
echo
$form
->
field
(
$generator
,
'generateLabelsFromComments'
)
->
checkbox
();
echo
$form
->
field
(
$generator
,
'enableI18N'
)
->
checkbox
();
echo
$form
->
field
(
$generator
,
'messageCategory'
);
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