|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Routes. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Zikula contributors (Zikula) |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
* @author Zikula contributors <[email protected]>. |
|
8
|
|
|
* @link http://www.zikula.org |
|
9
|
|
|
* @link http://zikula.org |
|
10
|
|
|
* @version Generated by ModuleStudio 0.7.1 (http://modulestudio.de). |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Delete operation. |
|
15
|
|
|
* |
|
16
|
|
|
* @param object $entity The treated object |
|
17
|
|
|
* @param array $params Additional arguments |
|
18
|
|
|
* |
|
19
|
|
|
* @return bool False on failure or true if everything worked well |
|
20
|
|
|
* |
|
21
|
|
|
* @throws RuntimeException Thrown if executing the workflow action fails |
|
22
|
|
|
*/ |
|
23
|
|
|
function ZikulaRoutesModule_operation_delete(&$entity, $params) |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
// get attributes read from the workflow |
|
27
|
|
|
if (isset($params['nextstate']) && !empty($params['nextstate'])) { |
|
28
|
|
|
// assign value to the data object |
|
29
|
|
|
$entity['workflowState'] = $params['nextstate']; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
// get entity manager |
|
33
|
|
|
$serviceManager = \ServiceUtil::getManager(); |
|
34
|
|
|
$entityManager = $serviceManager->get('doctrine.orm.default_entity_manager'); |
|
35
|
|
|
$logger = $serviceManager->get('logger'); |
|
36
|
|
|
$logArgs = ['app' => 'ZikulaRoutesModule', 'user' => $serviceManager->get('zikula_users_module.current_user')->get('uname')]; |
|
37
|
|
|
|
|
38
|
|
|
// delete entity |
|
39
|
|
|
try { |
|
40
|
|
|
$entityManager->remove($entity); |
|
41
|
|
|
$entityManager->flush(); |
|
42
|
|
|
$result = true; |
|
43
|
|
|
$logger->notice('{app}: User {user} deleted an entity.', $logArgs); |
|
44
|
|
|
} catch (\Exception $e) { |
|
45
|
|
|
$logger->error('{app}: User {user} tried to delete an entity, but failed.', $logArgs); |
|
46
|
|
|
throw new \RuntimeException($e->getMessage()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// return result of this operation |
|
50
|
|
|
return $result; |
|
51
|
|
|
} |
|
52
|
|
|
|