Code Duplication    Length = 31-32 lines in 2 locations

module/Admin/src/Admin/Controller/AclController.php 2 locations

@@ 269-300 (lines=32) @@
266
     * list roles
267
     * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel
268
     */
269
    public function rolesAction()
270
    {
271
272
        if ( $this->isXHR() ) {
273
            $datatablesData = array('data' => $this->getAclroleTable()->fetchAll()->toArray());
274
            $oController = $this;
275
            $datatablesData['data'] = array_map(
276
                function ($row) use ($oController) {
277
                    $actions = '<div class="button-group tiny btn-group btn-group-xs">'.
278
                        '<a class="button btn btn-default tiny btn-xs btn-clean btn-cta-xhr cta-xhr-modal" href="'.$oController->url()->fromRoute(
279
                            'admin/acledit',
280
                            array('action'=>'editrole', 'acl_id' => $row["aclroles_id"])
281
                        ).'"><span class="fa fa-pencil"></span> '.$oController->translate("edit").'</a>'.
282
                        '<a class="button btn btn-default tiny btn-xs btn-clean btn-cta-xhr cta-xhr-modal" href="'.$oController->url()->fromRoute(
283
                            'admin/acledit',
284
                            array('action'=>'deleterole', 'acl_id' => $row["aclroles_id"])
285
                        ).'"><span class="fa fa-trash-o"></span> '.$oController->translate("delete").'</a>'.
286
                    '</div>';
287
                    $row["_actions_"] = $actions;
288
                    return $row;
289
                }, $datatablesData['data'] 
290
            );
291
            return $this->getResponse()->setContent(json_encode($datatablesData));
292
        }
293
        return new ViewModel(
294
            array(
295
                'acldata' => $this->getAclTable()->fetchAll(),
296
                'roles' => $this->getAclroleTable()->fetchAll(),
297
                'resources' => $this->getAclresourceTable()->fetchAll(),
298
            )
299
        );
300
    }
301
302
    /**
303
     * list resources
@@ 306-336 (lines=31) @@
303
     * list resources
304
     * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel
305
     */
306
    public function resourcesAction()
307
    {
308
        if ( $this->isXHR() ) {
309
            $datatablesData = array('data' => $this->getAclresourceTable()->fetchAll()->toArray());
310
            $oController = $this;
311
            $datatablesData['data'] = array_map(
312
                function ($row) use ($oController) {
313
                    $actions = '<div class="button-group tiny btn-group btn-group-xs">'.
314
                    '<a class="button btn btn-default tiny btn-xs btn-clean btn-cta-xhr cta-xhr-modal" href="'.$oController->url()->fromRoute(
315
                        'admin/acledit',
316
                        array('action'=>'editresource', 'acl_id' => $row["aclresources_id"])
317
                    ).'"><span class="fa fa-pencil"></span> '.$oController->translate("edit").'</a>'.
318
                    '<a class="button btn btn-default tiny btn-xs btn-clean btn-cta-xhr cta-xhr-modal" href="'.$oController->url()->fromRoute(
319
                        'admin/acledit',
320
                        array('action'=>'deleteresource', 'acl_id' => $row["aclresources_id"])
321
                    ).'"><span class="fa fa-trash-o"></span> '.$oController->translate("delete").'</a>'.
322
                    '</div>';
323
                    $row["_actions_"] = $actions;
324
                    return $row;
325
                }, $datatablesData['data'] 
326
            );
327
            return $this->getResponse()->setContent(json_encode($datatablesData));
328
        }
329
        return new ViewModel(
330
            array(
331
            'acldata' => $this->getAclTable()->fetchAll(),
332
            'roles' => $this->getAclroleTable()->fetchAll(),
333
            'resources' => $this->getAclresourceTable()->fetchAll(),
334
            )
335
        );
336
    }
337
338
    /**
339
     * add acl entry