Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
918
Issues
918
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Development
Core
Commits
31ecdc7e
Unverified
Commit
31ecdc7e
authored
Mar 25, 2020
by
Eileen McNaughton
Committed by
GitHub
Mar 25, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16869 from colemanw/del
APIv3 - Use new DAO::deleteRecord method
parents
064037b6
a7d540f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
16 deletions
+5
-16
api/v3/utils.php
api/v3/utils.php
+5
-16
No files found.
api/v3/utils.php
View file @
31ecdc7e
...
@@ -1344,7 +1344,7 @@ function _civicrm_api3_basic_create_fallback($bao_name, $params) {
...
@@ -1344,7 +1344,7 @@ function _civicrm_api3_basic_create_fallback($bao_name, $params) {
*
*
* When the api is only doing a $bao::del then use this if api::del doesn't exist it will try DAO delete method.
* When the api is only doing a $bao::del then use this if api::del doesn't exist it will try DAO delete method.
*
*
* @param string $bao_name
* @param string
|CRM_Core_DAO
$bao_name
* @param array $params
* @param array $params
*
*
* @return array
* @return array
...
@@ -1357,8 +1357,8 @@ function _civicrm_api3_basic_create_fallback($bao_name, $params) {
...
@@ -1357,8 +1357,8 @@ function _civicrm_api3_basic_create_fallback($bao_name, $params) {
function
_civicrm_api3_basic_delete
(
$bao_name
,
&
$params
)
{
function
_civicrm_api3_basic_delete
(
$bao_name
,
&
$params
)
{
civicrm_api3_verify_mandatory
(
$params
,
NULL
,
[
'id'
]);
civicrm_api3_verify_mandatory
(
$params
,
NULL
,
[
'id'
]);
_civicrm_api3_check_edit_permissions
(
$bao_name
,
[
'id'
=>
$params
[
'id'
]]);
_civicrm_api3_check_edit_permissions
(
$bao_name
,
[
'id'
=>
$params
[
'id'
]]);
$args
=
[
&
$params
[
'id'
]];
if
(
method_exists
(
$bao_name
,
'del'
))
{
if
(
method_exists
(
$bao_name
,
'del'
))
{
$args
=
[
&
$params
[
'id'
]];
$dao
=
new
$bao_name
();
$dao
=
new
$bao_name
();
$dao
->
id
=
$params
[
'id'
];
$dao
->
id
=
$params
[
'id'
];
if
(
$dao
->
find
())
{
if
(
$dao
->
find
())
{
...
@@ -1370,21 +1370,10 @@ function _civicrm_api3_basic_delete($bao_name, &$params) {
...
@@ -1370,21 +1370,10 @@ function _civicrm_api3_basic_delete($bao_name, &$params) {
}
}
throw
new
API_Exception
(
'Could not delete entity id '
.
$params
[
'id'
]);
throw
new
API_Exception
(
'Could not delete entity id '
.
$params
[
'id'
]);
}
}
elseif
(
method_exists
(
$bao_name
,
'delete'
))
{
$dao
=
new
$bao_name
();
$dao
->
id
=
$params
[
'id'
];
if
(
$dao
->
find
())
{
while
(
$dao
->
fetch
())
{
$dao
->
delete
();
return
civicrm_api3_create_success
();
}
}
else
{
else
{
throw
new
API_Exception
(
'Could not delete entity id '
.
$params
[
'id'
]
);
$bao_name
::
deleteRecord
(
$params
);
}
return
civicrm_api3_create_success
();
}
}
throw
new
API_Exception
(
'no delete method found'
);
}
}
/**
/**
...
...
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