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
b4914412
Commit
b4914412
authored
May 07, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed `yii\rest\ActiveController::$transactional` property and connected functionality
parent
afff6a2f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
63 deletions
+2
-63
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ActiveController.php
framework/rest/ActiveController.php
+0
-8
CreateAction.php
framework/rest/CreateAction.php
+1
-21
DeleteAction.php
framework/rest/DeleteAction.php
+0
-16
UpdateAction.php
framework/rest/UpdateAction.php
+0
-18
No files found.
framework/CHANGELOG.md
View file @
b4914412
...
@@ -55,6 +55,7 @@ Yii Framework 2 Change Log
...
@@ -55,6 +55,7 @@ Yii Framework 2 Change Log
-
Chg: Added
`$user`
as the first parameter of
`yii\rbac\Rule::execute()`
(qiangxue)
-
Chg: Added
`$user`
as the first parameter of
`yii\rbac\Rule::execute()`
(qiangxue)
-
Chg:
`yii\grid\DataColumn::getDataCellValue()`
visibility is now
`public`
to allow accessing the value from a GridView directly (cebe)
-
Chg:
`yii\grid\DataColumn::getDataCellValue()`
visibility is now
`public`
to allow accessing the value from a GridView directly (cebe)
-
Chg:
`yii\data\ActiveDataProvider::$query`
will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe)
-
Chg:
`yii\data\ActiveDataProvider::$query`
will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe)
-
Chg: Removed
`yii\rest\ActiveController::$transactional`
property and connected functionality (samdark)
2.0.0-beta April 13, 2014
2.0.0-beta April 13, 2014
...
...
framework/rest/ActiveController.php
View file @
b4914412
...
@@ -50,11 +50,6 @@ class ActiveController extends Controller
...
@@ -50,11 +50,6 @@ class ActiveController extends Controller
* @see \yii\base\Model::scenarios()
* @see \yii\base\Model::scenarios()
*/
*/
public
$createScenario
=
Model
::
SCENARIO_DEFAULT
;
public
$createScenario
=
Model
::
SCENARIO_DEFAULT
;
/**
* @var boolean whether to use a DB transaction when creating, updating or deleting a model.
* This property is only useful for relational database.
*/
public
$transactional
=
true
;
/**
/**
* @inheritdoc
* @inheritdoc
...
@@ -88,20 +83,17 @@ class ActiveController extends Controller
...
@@ -88,20 +83,17 @@ class ActiveController extends Controller
'modelClass'
=>
$this
->
modelClass
,
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'scenario'
=>
$this
->
createScenario
,
'scenario'
=>
$this
->
createScenario
,
'transactional'
=>
$this
->
transactional
,
],
],
'update'
=>
[
'update'
=>
[
'class'
=>
'yii\rest\UpdateAction'
,
'class'
=>
'yii\rest\UpdateAction'
,
'modelClass'
=>
$this
->
modelClass
,
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'scenario'
=>
$this
->
updateScenario
,
'scenario'
=>
$this
->
updateScenario
,
'transactional'
=>
$this
->
transactional
,
],
],
'delete'
=>
[
'delete'
=>
[
'class'
=>
'yii\rest\DeleteAction'
,
'class'
=>
'yii\rest\DeleteAction'
,
'modelClass'
=>
$this
->
modelClass
,
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'transactional'
=>
$this
->
transactional
,
],
],
'options'
=>
[
'options'
=>
[
'class'
=>
'yii\rest\OptionsAction'
,
'class'
=>
'yii\rest\OptionsAction'
,
...
...
framework/rest/CreateAction.php
View file @
b4914412
...
@@ -25,10 +25,6 @@ class CreateAction extends Action
...
@@ -25,10 +25,6 @@ class CreateAction extends Action
*/
*/
public
$scenario
=
Model
::
SCENARIO_DEFAULT
;
public
$scenario
=
Model
::
SCENARIO_DEFAULT
;
/**
/**
* @var boolean whether to start a DB transaction when saving the model.
*/
public
$transactional
=
true
;
/**
* @var string the name of the view action. This property is need to create the URL when the mode is successfully created.
* @var string the name of the view action. This property is need to create the URL when the mode is successfully created.
*/
*/
public
$viewAction
=
'view'
;
public
$viewAction
=
'view'
;
...
@@ -52,23 +48,7 @@ class CreateAction extends Action
...
@@ -52,23 +48,7 @@ class CreateAction extends Action
]);
]);
$model
->
load
(
Yii
::
$app
->
getRequest
()
->
getBodyParams
(),
''
);
$model
->
load
(
Yii
::
$app
->
getRequest
()
->
getBodyParams
(),
''
);
if
(
$model
->
save
())
{
if
(
$this
->
transactional
&&
$model
instanceof
ActiveRecord
)
{
if
(
$model
->
validate
())
{
$transaction
=
$model
->
getDb
()
->
beginTransaction
();
try
{
$model
->
insert
(
false
);
$transaction
->
commit
();
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
}
}
else
{
$model
->
save
();
}
if
(
!
$model
->
hasErrors
())
{
$response
=
Yii
::
$app
->
getResponse
();
$response
=
Yii
::
$app
->
getResponse
();
$response
->
setStatusCode
(
201
);
$response
->
setStatusCode
(
201
);
$id
=
implode
(
','
,
array_values
(
$model
->
getPrimaryKey
(
true
)));
$id
=
implode
(
','
,
array_values
(
$model
->
getPrimaryKey
(
true
)));
...
...
framework/rest/DeleteAction.php
View file @
b4914412
...
@@ -19,11 +19,6 @@ use yii\db\ActiveRecord;
...
@@ -19,11 +19,6 @@ use yii\db\ActiveRecord;
class
DeleteAction
extends
Action
class
DeleteAction
extends
Action
{
{
/**
/**
* @var boolean whether to start a DB transaction when deleting the model.
*/
public
$transactional
=
true
;
/**
* Deletes a model.
* Deletes a model.
*/
*/
public
function
run
(
$id
)
public
function
run
(
$id
)
...
@@ -34,18 +29,7 @@ class DeleteAction extends Action
...
@@ -34,18 +29,7 @@ class DeleteAction extends Action
call_user_func
(
$this
->
checkAccess
,
$this
->
id
,
$model
);
call_user_func
(
$this
->
checkAccess
,
$this
->
id
,
$model
);
}
}
if
(
$this
->
transactional
&&
$model
instanceof
ActiveRecord
)
{
$transaction
=
$model
->
getDb
()
->
beginTransaction
();
try
{
$model
->
delete
();
$model
->
delete
();
$transaction
->
commit
();
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
}
else
{
$model
->
delete
();
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
}
}
...
...
framework/rest/UpdateAction.php
View file @
b4914412
...
@@ -23,10 +23,6 @@ class UpdateAction extends Action
...
@@ -23,10 +23,6 @@ class UpdateAction extends Action
* @var string the scenario to be assigned to the model before it is validated and updated.
* @var string the scenario to be assigned to the model before it is validated and updated.
*/
*/
public
$scenario
=
Model
::
SCENARIO_DEFAULT
;
public
$scenario
=
Model
::
SCENARIO_DEFAULT
;
/**
* @var boolean whether to start a DB transaction when saving the model.
*/
public
$transactional
=
true
;
/**
/**
* Updates an existing model.
* Updates an existing model.
...
@@ -45,21 +41,7 @@ class UpdateAction extends Action
...
@@ -45,21 +41,7 @@ class UpdateAction extends Action
$model
->
scenario
=
$this
->
scenario
;
$model
->
scenario
=
$this
->
scenario
;
$model
->
load
(
Yii
::
$app
->
getRequest
()
->
getBodyParams
(),
''
);
$model
->
load
(
Yii
::
$app
->
getRequest
()
->
getBodyParams
(),
''
);
if
(
$this
->
transactional
&&
$model
instanceof
ActiveRecord
)
{
if
(
$model
->
validate
())
{
$transaction
=
$model
->
getDb
()
->
beginTransaction
();
try
{
$model
->
update
(
false
);
$transaction
->
commit
();
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
}
}
else
{
$model
->
save
();
$model
->
save
();
}
return
$model
;
return
$model
;
}
}
...
...
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