Code Duplication    Length = 20-23 lines in 4 locations

Builder/Admin/ActionsBuilder.php 1 location

@@ 93-112 (lines=20) @@
90
        $this->batchActions[$action->getName()] = $action;
91
    }
92
93
    protected function findBatchActions()
94
    {
95
        $batchActions = $this->getVariable('batch_actions', array());
96
97
        foreach ($batchActions as $actionName => $actionParams) {
98
            $action = $this->findBatchAction($actionName);
99
            if (!$action) {
100
                $action = new Action($actionName);
101
            }
102
103
            if ($globalCredentials = $this->getGenerator()->getFromYaml('params.credentials')) {
104
                // If generator is globally protected by credentials
105
                // batch actions are also protected
106
                $action->setCredentials($globalCredentials);
107
            }
108
109
            $this->setUserBatchActionConfiguration($action);
110
            $this->addBatchAction($action);
111
        }
112
    }
113
}
114

Builder/Admin/BaseBuilder.php 2 locations

@@ 416-438 (lines=23) @@
413
        $this->actions[$action->getName()] = $action;
414
    }
415
416
    protected function findActions()
417
    {
418
        foreach ($this->getVariable('actions', array()) as $actionName => $actionParams) {
419
            $action = $this->findGenericAction($actionName);
420
421
            if (!$action) {
422
                $action = $this->findObjectAction($actionName);
423
            }
424
425
            if (!$action) {
426
                $action = new Action($actionName);
427
            }
428
429
            if ($globalCredentials = $this->getGenerator()->getFromYaml('params.credentials')) {
430
                // If generator is globally protected by credentials
431
                // actions are also protected
432
                $action->setCredentials($globalCredentials);
433
            }
434
435
            $this->setUserActionConfiguration($action);
436
            $this->addAction($action);
437
        }
438
    }
439
440
    /**
441
     * Return a list of action from list.object_actions.
@@ 483-502 (lines=20) @@
480
        $this->objectActions[$action->getName()] = $action;
481
    }
482
483
    protected function findObjectActions()
484
    {
485
        $objectActions = $this->getVariable('object_actions', array());
486
487
        foreach ($objectActions as $actionName => $actionParams) {
488
            $action = $this->findObjectAction($actionName);
489
            if (!$action) {
490
                $action = new Action($actionName);
491
            }
492
493
            if ($globalCredentials = $this->getGenerator()->getFromYaml('params.credentials')) {
494
                // If generator is globally protected by credentials
495
                // object actions are also protected
496
                $action->setCredentials($globalCredentials);
497
            }
498
499
            $this->setUserObjectActionConfiguration($action);
500
            $this->addObjectAction($action);
501
        }
502
    }
503
504
    public function findGenericAction($actionName)
505
    {

Builder/Admin/ListBuilder.php 1 location

@@ 211-231 (lines=21) @@
208
        $this->batchActions[$action->getName()] = $action;
209
    }
210
211
    protected function findBatchActions()
212
    {
213
        $batchActions = $this->getVariable('batch_actions', array());
214
215
        foreach ($batchActions as $actionName => $actionParams) {
216
            $action = $this->findBatchAction($actionName);
217
218
            if (!$action) {
219
                $action = new Action($actionName);
220
            }
221
222
            if ($globalCredentials = $this->getGenerator()->getFromYaml('params.credentials')) {
223
                // If generator is globally protected by credentials
224
                // batch actions are also protected
225
                $action->setCredentials($globalCredentials);
226
            }
227
228
            $this->setUserBatchActionConfiguration($action);
229
            $this->addBatchAction($action);
230
        }
231
    }
232
233
  /**
234
   * Return a list of actions from excel.export