Completed
Push — master ( a7cf71...06c6ea )
by Craig
06:43
created

AbstractEditHandler::applyAction()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 31
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 18
nc 6
nop 1
dl 0
loc 31
rs 8.439
c 0
b 0
f 0
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.0 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule\Form\Handler\Route\Base;
14
15
use Zikula\RoutesModule\Form\Handler\Common\EditHandler;
16
17
use Symfony\Component\HttpFoundation\RedirectResponse;
18
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
19
use ModUtil;
20
use RuntimeException;
21
use System;
22
use UserUtil;
23
24
/**
25
 * This handler class handles the page events of editing forms.
26
 * It aims on the route object type.
27
 */
28
abstract class AbstractEditHandler extends EditHandler
29
{
30
    /**
31
     * Initialise form handler.
32
     *
33
     * This method takes care of all necessary initialisation of our data and form states.
34
     *
35
     * @param array $templateParameters List of preassigned template variables
36
     *
37
     * @return boolean False in case of initialisation errors, otherwise true
38
     */
39
    public function processForm(array $templateParameters)
40
    {
41
        $this->objectType = 'route';
42
        $this->objectTypeCapital = 'Route';
43
        $this->objectTypeLower = 'route';
44
        
45
        $this->hasPageLockSupport = true;
46
    
47
        $result = parent::processForm($templateParameters);
48
    
49
        if ($this->templateParameters['mode'] == 'create') {
50
            $modelHelper = $this->container->get('zikula_routes_module.model_helper');
51
            if (!$modelHelper->canBeCreated($this->objectType)) {
52
                $this->request->getSession()->getFlashBag()->add('error', $this->__('Sorry, but you can not create the route yet as other items are required which must be created before!'));
53
                $logger = $this->container->get('logger');
54
                $logArgs = ['app' => 'ZikulaRoutesModule', 'user' => $this->container->get('zikula_users_module.current_user')->get('uname'), 'entity' => $this->objectType];
55
                $logger->notice('{app}: User {user} tried to create a new {entity}, but failed as it other items are required which must be created before.', $logArgs);
56
    
57
                return new RedirectResponse($this->getRedirectUrl(['commandName' => '']), 302);
0 ignored issues
show
Security Cross-Site Scripting introduced by
$this->getRedirectUrl(array('commandName' => '')) can contain request data and is used in output context(s) leading to a potential security vulnerability.

3 paths for user data to reach this point

  1. Path: HeaderBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 207
  1. HeaderBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 207
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 57
  2. Path: ParameterBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 201
  1. ParameterBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 201
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 57
  3. Path: Session::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 205
  1. Session::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 205
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 57

Used in output context

  1. RedirectResponse::__construct() uses RedirectResponse::setTargetUrl() ($url)
    in vendor/src/Symfony/Component/HttpFoundation/RedirectResponse.php on line 39
  2. RedirectResponse::setTargetUrl() uses Response::setContent() ($content)
    in vendor/src/Symfony/Component/HttpFoundation/RedirectResponse.php on line 86
  3. Response::setContent() uses property Response::$content for writing
    in vendor/src/Symfony/Component/HttpFoundation/Response.php on line 447
  4. Property Response::$content is used in echo
    in vendor/src/Symfony/Component/HttpFoundation/Response.php on line 406

Preventing Cross-Site-Scripting Attacks

Cross-Site-Scripting allows an attacker to inject malicious code into your website - in particular Javascript code, and have that code executed with the privileges of a visiting user. This can be used to obtain data, or perform actions on behalf of that visiting user.

In order to prevent this, make sure to escape all user-provided data:

// for HTML
$sanitized = htmlentities($tainted, ENT_QUOTES);

// for URLs
$sanitized = urlencode($tainted);

General Strategies to prevent injection

In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:

if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
    throw new \InvalidArgumentException('This input is not allowed.');
}

For numeric data, we recommend to explicitly cast the data:

$sanitized = (integer) $tainted;
Loading history...
58
            }
59
        }
60
    
61
        $entity = $this->entityRef;
62
    
63
        // save entity reference for later reuse
64
        $this->entityRef = $entity;
65
    
66
        $entityData = $entity->toArray();
67
    
68
        // assign data to template as array (makes translatable support easier)
69
        $this->templateParameters[$this->objectTypeLower] = $entityData;
70
    
71
        return $result;
72
    }
73
    
74
    /**
75
     * Creates the form type.
76
     */
77
    protected function createForm()
78
    {
79
        $options = [
80
            'mode' => $this->templateParameters['mode'],
81
            'actions' => $this->templateParameters['actions'],
82
        ];
83
    
84
        return $this->container->get('form.factory')->create('Zikula\RoutesModule\Form\Type\RouteType', $this->entityRef, $options);
85
    }
86
87
88
    /**
89
     * Get list of allowed redirect codes.
90
     *
91
     * @return array list of possible redirect codes
92
     */
93
    protected function getRedirectCodes()
94
    {
95
        $codes = parent::getRedirectCodes();
96
    
97
    
98
        return $codes;
99
    }
100
101
    /**
102
     * Get the default redirect url. Required if no returnTo parameter has been supplied.
103
     * This method is called in handleCommand so we know which command has been performed.
104
     *
105
     * @param array $args List of arguments
106
     *
107
     * @return string The default redirect url
108
     */
109
    protected function getDefaultReturnUrl($args)
110
    {
111
        $objectIsPersisted = $args['commandName'] != 'delete' && !($this->templateParameters['mode'] == 'create' && $args['commandName'] == 'cancel');
112
    
113
        if (null !== $this->returnTo) {
114
            
115
            $isDisplayOrEditPage = substr($this->returnTo, -7) == 'display' || substr($this->returnTo, -4) == 'edit';
116
            if (!$isDisplayOrEditPage || $objectIsPersisted) {
117
                // return to referer
118
                return $this->returnTo;
119
            }
120
        }
121
    
122
        $routeArea = array_key_exists('routeArea', $this->templateParameters) ? $this->templateParameters['routeArea'] : '';
123
    
124
        // redirect to the list of routes
125
        $viewArgs = [];
126
        $url = $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_' . $routeArea . 'view', $viewArgs);
127
    
128
        return $url;
129
    }
130
131
    /**
132
     * Command event handler.
133
     *
134
     * This event handler is called when a command is issued by the user.
135
     *
136
     * @param array $args List of arguments
137
     *
138
     * @return mixed Redirect or false on errors
139
     */
140
    public function handleCommand($args = [])
141
    {
142
        $result = parent::handleCommand($args);
143
        if (false === $result) {
144
            return $result;
145
        }
146
    
147
        // build $args for BC (e.g. used by redirect handling)
148 View Code Duplication
        foreach ($this->templateParameters['actions'] as $action) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
149
            if ($this->form->get($action['id'])->isClicked()) {
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Symfony\Component\Form\AbstractType>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
                $args['commandName'] = $action['id'];
151
            }
152
        }
153
    
154
        return new RedirectResponse($this->getRedirectUrl($args), 302);
0 ignored issues
show
Security Cross-Site Scripting introduced by
$this->getRedirectUrl($args) can contain request data and is used in output context(s) leading to a potential security vulnerability.

3 paths for user data to reach this point

  1. Path: HeaderBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 207
  1. HeaderBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 207
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 154
  2. Path: ParameterBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 201
  1. ParameterBag::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 201
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 154
  3. Path: Session::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 205
  1. Session::get() returns tainted data, and AbstractEditHandler::$returnTo is assigned
    in src/system/RoutesModule/Form/Handler/Common/Base/AbstractEditHandler.php on line 205
  2. Tainted property AbstractEditHandler::$returnTo is read
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 118
  3. AbstractEditHandler::getDefaultReturnUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 252
  4. AbstractEditHandler::getRedirectUrl() returns tainted data
    in src/system/RoutesModule/Form/Handler/Route/Base/AbstractEditHandler.php on line 154

Used in output context

  1. RedirectResponse::__construct() uses RedirectResponse::setTargetUrl() ($url)
    in vendor/src/Symfony/Component/HttpFoundation/RedirectResponse.php on line 39
  2. RedirectResponse::setTargetUrl() uses Response::setContent() ($content)
    in vendor/src/Symfony/Component/HttpFoundation/RedirectResponse.php on line 86
  3. Response::setContent() uses property Response::$content for writing
    in vendor/src/Symfony/Component/HttpFoundation/Response.php on line 447
  4. Property Response::$content is used in echo
    in vendor/src/Symfony/Component/HttpFoundation/Response.php on line 406

Preventing Cross-Site-Scripting Attacks

Cross-Site-Scripting allows an attacker to inject malicious code into your website - in particular Javascript code, and have that code executed with the privileges of a visiting user. This can be used to obtain data, or perform actions on behalf of that visiting user.

In order to prevent this, make sure to escape all user-provided data:

// for HTML
$sanitized = htmlentities($tainted, ENT_QUOTES);

// for URLs
$sanitized = urlencode($tainted);

General Strategies to prevent injection

In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:

if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
    throw new \InvalidArgumentException('This input is not allowed.');
}

For numeric data, we recommend to explicitly cast the data:

$sanitized = (integer) $tainted;
Loading history...
155
    }
156
    
157
    /**
158
     * Get success or error message for default operations.
159
     *
160
     * @param array   $args    Arguments from handleCommand method
161
     * @param Boolean $success Becomes true if this is a success, false for default error
162
     *
163
     * @return String desired status or error message
164
     */
165
    protected function getDefaultMessage($args, $success = false)
166
    {
167
        if (false === $success) {
168
            return parent::getDefaultMessage($args, $success);
169
        }
170
    
171
        $message = '';
0 ignored issues
show
Unused Code introduced by
$message is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
172
        switch ($args['commandName']) {
173
            case 'submit':
174
                if ($this->templateParameters['mode'] == 'create') {
175
                    $message = $this->__('Done! Route created.');
176
                } else {
177
                    $message = $this->__('Done! Route updated.');
178
                }
179
                break;
180
            case 'delete':
181
                $message = $this->__('Done! Route deleted.');
182
                break;
183
            default:
184
                $message = $this->__('Done! Route updated.');
185
                break;
186
        }
187
    
188
        return $message;
189
    }
190
191
    /**
192
     * This method executes a certain workflow action.
193
     *
194
     * @param array $args Arguments from handleCommand method
195
     *
196
     * @return bool Whether everything worked well or not
197
     *
198
     * @throws RuntimeException Thrown if concurrent editing is recognised or another error occurs
199
     */
200
    public function applyAction(array $args = [])
201
    {
202
        // get treated entity reference from persisted member var
203
        $entity = $this->entityRef;
204
    
205
        $action = $args['commandName'];
206
    
207
        $success = false;
208
        $flashBag = $this->request->getSession()->getFlashBag();
209
        $logger = $this->container->get('logger');
210
        try {
211
            // execute the workflow action
212
            $workflowHelper = $this->container->get('zikula_routes_module.workflow_helper');
213
            $success = $workflowHelper->executeAction($entity, $action);
214
        } catch(\Exception $e) {
215
            $flashBag->add('error', $this->__f('Sorry, but an error occured during the %action% action. Please apply the changes again!', ['%action%' => $action]) . ' ' . $e->getMessage());
216
            $logArgs = ['app' => 'ZikulaRoutesModule', 'user' => $this->container->get('zikula_users_module.current_user')->get('uname'), 'entity' => 'route', 'id' => $entity->createCompositeIdentifier(), 'errorMessage' => $e->getMessage()];
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Zikula\Core\Doctrine\EntityAccess as the method createCompositeIdentifier() does only exist in the following sub-classes of Zikula\Core\Doctrine\EntityAccess: Zikula\RoutesModule\Enti...ase\AbstractRouteEntity, Zikula\RoutesModule\Entity\RouteEntity. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
217
            $logger->error('{app}: User {user} tried to edit the {entity} with id {id}, but failed. Error details: {errorMessage}.', $logArgs);
218
        }
219
    
220
        $this->addDefaultMessage($args, $success);
221
    
222
        if ($success && $this->templateParameters['mode'] == 'create') {
223
            // store new identifier
224
            foreach ($this->idFields as $idField) {
225
                $this->idValues[$idField] = $entity[$idField];
226
            }
227
        }
228
    
229
        return $success;
230
    }
231
232
    /**
233
     * Get url to redirect to.
234
     *
235
     * @param array $args List of arguments
236
     *
237
     * @return string The redirect url
238
     */
239
    protected function getRedirectUrl($args)
240
    {
241
        if ($this->repeatCreateAction) {
242
            return $this->repeatReturnUrl;
243
        }
244
    
245
        if ($this->request->getSession()->has('referer')) {
246
            $this->request->getSession()->del('referer');
0 ignored issues
show
Bug introduced by
The method del() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
247
        }
248
    
249
        // normal usage, compute return url from given redirect code
250
        if (!in_array($this->returnTo, $this->getRedirectCodes())) {
251
            // invalid return code, so return the default url
252
            return $this->getDefaultReturnUrl($args);
253
        }
254
    
255
        // parse given redirect code and return corresponding url
256
        switch ($this->returnTo) {
257
            case 'admin':
258
                return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_adminindex');
259
            case 'adminView':
260
                return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_adminview');
261 View Code Duplication
            case 'adminDisplay':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
262
                if ($args['commandName'] != 'delete' && !($this->templateParameters['mode'] == 'create' && $args['commandName'] == 'cancel')) {
263
                    foreach ($this->idFields as $idField) {
264
                        $urlArgs[$idField] = $this->idValues[$idField];
0 ignored issues
show
Coding Style Comprehensibility introduced by
$urlArgs was never initialized. Although not strictly required by PHP, it is generally a good practice to add $urlArgs = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
265
                    }
266
                    return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_admindisplay', $urlArgs);
0 ignored issues
show
Bug introduced by
The variable $urlArgs does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
267
                }
268
                return $this->getDefaultReturnUrl($args);
269
            case 'user':
270
                return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_index');
271
            case 'userView':
272
                return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_view');
273 View Code Duplication
            case 'userDisplay':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
274
                if ($args['commandName'] != 'delete' && !($this->templateParameters['mode'] == 'create' && $args['commandName'] == 'cancel')) {
275
                    foreach ($this->idFields as $idField) {
276
                        $urlArgs[$idField] = $this->idValues[$idField];
277
                    }
278
                    return $this->router->generate('zikularoutesmodule_' . $this->objectTypeLower . '_display', $urlArgs);
279
                }
280
                return $this->getDefaultReturnUrl($args);
281
            default:
282
                return $this->getDefaultReturnUrl($args);
283
        }
284
    }
285
}
286