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
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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4 additions
and
65 deletions
+4
-65
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
+1
-17
UpdateAction.php
framework/rest/UpdateAction.php
+1
-19
No files found.
framework/CHANGELOG.md
View file @
b4914412
...
...
@@ -55,6 +55,7 @@ Yii Framework 2 Change Log
-
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\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
...
...
framework/rest/ActiveController.php
View file @
b4914412
...
...
@@ -50,11 +50,6 @@ class ActiveController extends Controller
* @see \yii\base\Model::scenarios()
*/
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
...
...
@@ -88,20 +83,17 @@ class ActiveController extends Controller
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'scenario'
=>
$this
->
createScenario
,
'transactional'
=>
$this
->
transactional
,
],
'update'
=>
[
'class'
=>
'yii\rest\UpdateAction'
,
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'scenario'
=>
$this
->
updateScenario
,
'transactional'
=>
$this
->
transactional
,
],
'delete'
=>
[
'class'
=>
'yii\rest\DeleteAction'
,
'modelClass'
=>
$this
->
modelClass
,
'checkAccess'
=>
[
$this
,
'checkAccess'
],
'transactional'
=>
$this
->
transactional
,
],
'options'
=>
[
'class'
=>
'yii\rest\OptionsAction'
,
...
...
framework/rest/CreateAction.php
View file @
b4914412
...
...
@@ -25,10 +25,6 @@ class CreateAction extends Action
*/
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.
*/
public
$viewAction
=
'view'
;
...
...
@@ -52,23 +48,7 @@ class CreateAction extends Action
]);
$model
->
load
(
Yii
::
$app
->
getRequest
()
->
getBodyParams
(),
''
);
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
())
{
if
(
$model
->
save
())
{
$response
=
Yii
::
$app
->
getResponse
();
$response
->
setStatusCode
(
201
);
$id
=
implode
(
','
,
array_values
(
$model
->
getPrimaryKey
(
true
)));
...
...
framework/rest/DeleteAction.php
View file @
b4914412
...
...
@@ -19,11 +19,6 @@ use yii\db\ActiveRecord;
class
DeleteAction
extends
Action
{
/**
* @var boolean whether to start a DB transaction when deleting the model.
*/
public
$transactional
=
true
;
/**
* Deletes a model.
*/
public
function
run
(
$id
)
...
...
@@ -34,18 +29,7 @@ class DeleteAction extends Action
call_user_func
(
$this
->
checkAccess
,
$this
->
id
,
$model
);
}
if
(
$this
->
transactional
&&
$model
instanceof
ActiveRecord
)
{
$transaction
=
$model
->
getDb
()
->
beginTransaction
();
try
{
$model
->
delete
();
$transaction
->
commit
();
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
}
else
{
$model
->
delete
();
}
$model
->
delete
();
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
}
...
...
framework/rest/UpdateAction.php
View file @
b4914412
...
...
@@ -23,10 +23,6 @@ class UpdateAction extends Action
* @var string the scenario to be assigned to the model before it is validated and updated.
*/
public
$scenario
=
Model
::
SCENARIO_DEFAULT
;
/**
* @var boolean whether to start a DB transaction when saving the model.
*/
public
$transactional
=
true
;
/**
* Updates an existing model.
...
...
@@ -45,21 +41,7 @@ class UpdateAction extends Action
$model
->
scenario
=
$this
->
scenario
;
$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
;
}
...
...
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