Issues (275)

api/src/Fixture/CaseStatus.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace App\Fixture;
4
5
use App\Entity\CaseEntity;
6
use App\Entity\CaseStatus as CaseStatusEntity;
7
use Doctrine\Common\Persistence\ObjectManager;
0 ignored issues
show
The type Doctrine\Common\Persistence\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Ds\Component\Database\Fixture\Yaml;
0 ignored issues
show
The type Ds\Component\Database\Fixture\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use LogicException;
10
11
/**
12
 * Trait CaseStatus
13
 */
14
trait CaseStatus
15
{
16
    use Yaml;
17
18
    /**
19
     * @var string
20
     */
21
    private $path;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function load(ObjectManager $manager)
27
    {
28
        $objects = $this->parse($this->path);
29
30
        foreach ($objects as $object) {
31
            $case = $this->getReference($object->case);
32
33
            if (!$case) {
34
                throw new LogicException('Case "'.$object->case.'" does not exist.');
35
            }
36
37
            $status = new CaseStatusEntity;
38
            $status
39
                ->setCase($case)
40
                ->setUuid($object->uuid)
41
                ->setOwner($object->owner)
42
                ->setOwnerUuid($object->owner_uuid)
43
                ->setIdentity($object->identity)
44
                ->setIdentityUuid($object->identity_uuid)
45
                ->setTitle((array) $object->title)
46
                ->setDescription((array) $object->description)
47
                ->setData((array) $object->data)
48
                ->setTenant($object->tenant);
49
            $manager->persist($status);
50
        }
51
52
        $manager->flush();
53
    }
54
}
55