UsecasesController::updateAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
class UsecasesController extends \ControllerBase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    protected $model;
7
    protected $title;
8
    protected $controller;
9
10
    public function initialize()
11
    {
12
        $this->model = "Usecase";
13
        $this->title = "Usecases";
14
        $this->controller = "Usecases";
15
    }
16
17
    public function updateAction($id=null){
18
        parent::updateAction();
19
        $this->response->redirect("Projets/read/$id/2");
20
    }
21
22
    public function deleteAction($id = null){
0 ignored issues
show
Coding Style introduced by
deleteAction uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
23
        $object = Usecase::findFirst("id = $id");
24
        $codeUseCase = $object->getCode();
25
        $taches = Tache::find("codeUseCase = '$codeUseCase'");
26
        //Deletion des taches liés avant deletion de la UseCase
27
        foreach($taches as $t){
28
            $t->delete();
29
        }
30
        $object->delete();
31
        $this->response->redirect($_SERVER['HTTP_REFERER']."/2");
32
    }
33
}
34
35