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
c63edd31
Commit
c63edd31
authored
May 01, 2014
by
johonunu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformating code. Removed \t signs, using spaces. Edited Changelog.
parent
6f9aee90
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
11 deletions
+16
-11
CHANGELOG.md
extensions/gii/CHANGELOG.md
+1
-0
Generator.php
extensions/gii/generators/crud/Generator.php
+4
-2
controller.php
extensions/gii/generators/crud/default/controller.php
+6
-6
index.php
extensions/gii/generators/crud/default/views/index.php
+5
-3
No files found.
extensions/gii/CHANGELOG.md
View file @
c63edd31
...
...
@@ -27,6 +27,7 @@ Yii Framework 2 gii extension Change Log
-
Enh #2633: Keyboard shortcuts to browse through files (thiagotalma)
-
Enh #2822: possibility to generate I18N messages (lucianobaraglia)
-
Enh #2843: Option to filter files according to the action. (thiagotalma)
-
Enh #2018: Search model not required anymore in crud generator. (johonunu)
2.
0.0-alpha, December 1, 2013
-----------------------------
...
...
extensions/gii/generators/crud/Generator.php
View file @
c63edd31
...
...
@@ -167,7 +167,7 @@ class Generator extends \yii\gii\Generator
new
CodeFile
(
$controllerFile
,
$this
->
render
(
'controller.php'
)),
];
if
(
!
empty
(
$this
->
searchModelClass
))
{
if
(
!
empty
(
$this
->
searchModelClass
))
{
$searchModel
=
Yii
::
getAlias
(
'@'
.
str_replace
(
'\\'
,
'/'
,
ltrim
(
$this
->
searchModelClass
,
'\\'
)
.
'.php'
));
$files
[]
=
new
CodeFile
(
$searchModel
,
$this
->
render
(
'search.php'
));
}
...
...
@@ -175,7 +175,9 @@ class Generator extends \yii\gii\Generator
$viewPath
=
$this
->
getViewPath
();
$templatePath
=
$this
->
getTemplatePath
()
.
'/views'
;
foreach
(
scandir
(
$templatePath
)
as
$file
)
{
if
(
empty
(
$this
->
searchModelClass
)
&&
$file
===
'_search.php'
)
continue
;
if
(
empty
(
$this
->
searchModelClass
)
&&
$file
===
'_search.php'
)
{
continue
;
}
if
(
is_file
(
$templatePath
.
'/'
.
$file
)
&&
pathinfo
(
$file
,
PATHINFO_EXTENSION
)
===
'php'
)
{
$files
[]
=
new
CodeFile
(
"
$viewPath
/
$file
"
,
$this
->
render
(
"views/
$file
"
));
}
...
...
extensions/gii/generators/crud/default/controller.php
View file @
c63edd31
...
...
@@ -31,11 +31,11 @@ namespace <?= StringHelper::dirname(ltrim($generator->controllerClass, '\\')) ?>
use Yii;
use
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
;
<?php
if
(
!
empty
(
$generator
->
searchModelClass
)){
?>
<?php
if
(
!
empty
(
$generator
->
searchModelClass
))
:
?>
use
<?=
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
.
(
isset
(
$searchModelAlias
)
?
" as
$searchModelAlias
"
:
""
)
?>
;
<?php
}
else
{
?>
<?php
else
:
?>
use yii\data\ActiveDataProvider;
<?php
}
?>
<?php
endif
;
?>
use
<?=
ltrim
(
$generator
->
baseControllerClass
,
'\\'
)
?>
;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
...
...
@@ -63,7 +63,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
*/
public function actionIndex()
{
<?php
if
(
!
empty
(
$generator
->
searchModelClass
)){
?>
<?php
if
(
!
empty
(
$generator
->
searchModelClass
))
:
?>
$searchModel = new
<?=
isset
(
$searchModelAlias
)
?
$searchModelAlias
:
$searchModelClass
?>
;
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
...
...
@@ -71,7 +71,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
<?php
}
else
{
?>
<?php
else
:
?>
$dataProvider = new ActiveDataProvider([
'query' =>
<?=
$modelClass
?>
::find(),
]);
...
...
@@ -79,7 +79,7 @@ class <?= $controllerClass ?> extends <?= StringHelper::basename($generator->bas
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
<?php
}
?>
<?php
endif
;
?>
}
/**
...
...
extensions/gii/generators/crud/default/views/index.php
View file @
c63edd31
...
...
@@ -20,7 +20,7 @@ use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\w
/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
<?=
!
empty
(
$generator
->
searchModelClass
)
?
" * @var "
.
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
.
"
\$
searchModel
\n
"
:
''
?>
<?=
!
empty
(
$generator
->
searchModelClass
)
?
" * @var "
.
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
.
"
\$
searchModel
\n
"
:
''
?>
*/
$this->title =
<?=
$generator
->
generateString
(
Inflector
::
pluralize
(
Inflector
::
camel2words
(
StringHelper
::
basename
(
$generator
->
modelClass
))))
?>
;
...
...
@@ -29,7 +29,9 @@ $this->params['breadcrumbs'][] = $this->title;
<div
class=
"
<?=
Inflector
::
camel2id
(
StringHelper
::
basename
(
$generator
->
modelClass
))
?>
-index"
>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<?php
if
(
!
empty
(
$generator
->
searchModelClass
)){
?><?=
"<?php "
.
(
$generator
->
indexWidgetType
===
'grid'
?
"// "
:
""
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<?php
}
?>
<?php
if
(
!
empty
(
$generator
->
searchModelClass
))
:
?>
<?=
" <?php "
.
(
$generator
->
indexWidgetType
===
'grid'
?
"// "
:
""
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<?php
endif
;
?>
<p>
<?=
"<?= "
?>
Html::a(
<?=
$generator
->
generateString
(
'Create {modelClass}'
,
[
'modelClass'
=>
Inflector
::
camel2words
(
StringHelper
::
basename
(
$generator
->
modelClass
))])
?>
, ['create'], ['class' => 'btn btn-success']) ?>
...
...
@@ -38,7 +40,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
<?=
"<?= "
?>
GridView::widget([
'dataProvider' => $dataProvider,
<?=
!
empty
(
$generator
->
searchModelClass
)
?
"'filterModel' =>
\$
searchModel,
\n\t\t
'columns' => [
\n
"
:
"'columns' => [
\n
"
;
?>
<?=
!
empty
(
$generator
->
searchModelClass
)
?
"'filterModel' =>
\$
searchModel,
\n
'columns' => [
\n
"
:
"'columns' => [
\n
"
;
?>
['class' => 'yii\grid\SerialColumn'],
<?php
...
...
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