From 7954de40372d1fcf527e604b69a3c3ecb572060c Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 23 Dec 2022 18:21:38 +0100 Subject: [PATCH] group combo and use anonymous function --- _admin.php | 47 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/_admin.php b/_admin.php index 7e7556a..ce93cc5 100644 --- a/_admin.php +++ b/_admin.php @@ -23,49 +23,28 @@ dcCore::app()->addBehavior('adminPostsActions', function (dcPostsActions $pa) { [ __('Comments') => [ __('Mark as opened') => 'commentsopen', - ], - ], - ['behaviorsPostlistOptions', 'commentsOpen'] - ); - $pa->addAction( - [ - __('Comments') => [ __('Mark as closed') => 'commentsclose', - ], - ], - ['behaviorsPostlistOptions', 'commentsClose'] - ); - $pa->addAction( - [ - __('Comments') => [ __('Delete all comments') => 'commentsdelete', ], - ], - ['behaviorsPostlistOptions', 'commentsDelete'] - ); - $pa->addAction( - [ __('Trackbacks') => [ __('Mark as opened') => 'trackbacksopen', - ], - ], - ['behaviorsPostlistOptions', 'trackbacksOpen'] - ); - $pa->addAction( - [ - __('Trackbacks') => [ __('Mark as closed') => 'trackbacksclose', - ], - ], - ['behaviorsPostlistOptions', 'trackbacksClose'] - ); - $pa->addAction( - [ - __('Trackbacks') => [ __('Delete all trackbacks') => 'trackbacksdelete', ], ], - ['behaviorsPostlistOptions', 'trackbacksDelete'] + function (dcPostsActions $pa, ArrayObject $post) { + $actions = [ + 'commentsopen', + 'commentsclose', + 'commentsdelete', + 'trackbacksopen', + 'trackbacksclose', + 'trackbacksdelete', + ]; + if (in_array($pa->getAction(), $actions)) { + behaviorsPostlistOptions::{$pa->getAction()}($pa, $post); + } + } ); });