1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\DataFixtures\ORM; |
4
|
|
|
|
5
|
|
|
use AppBundle\Entity\Action; |
6
|
|
|
use AppBundle\Entity\Device; |
7
|
|
|
use AppBundle\Entity\VarHook; |
8
|
|
|
use AppBundle\Entity\Variable; |
9
|
|
|
use Doctrine\Common\DataFixtures\FixtureInterface; |
10
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
11
|
|
|
|
12
|
|
|
class LoadActionData implements FixtureInterface |
13
|
|
|
{ |
14
|
|
|
public function load(ObjectManager $manager) |
15
|
|
|
{ |
16
|
|
|
$variable = new Variable(); |
17
|
|
|
|
18
|
|
|
$variable->setName('temperature'); |
19
|
|
|
$variable->setDescription('test temperature metric'); |
20
|
|
|
$variable->setSource('internal'); |
21
|
|
|
$variable->setParser('Simple'); |
22
|
|
|
$variable->setValue('20'); |
23
|
|
|
|
24
|
|
|
$manager->persist($variable); |
25
|
|
|
|
26
|
|
|
$device = new Device(); |
27
|
|
|
$device->setAlias('pi.fs'); |
28
|
|
|
$device->setName('Filesystem'); |
29
|
|
|
|
30
|
|
|
$manager->persist($device); |
31
|
|
|
|
32
|
|
|
$action = new Action(); |
33
|
|
|
|
34
|
|
|
$action->setArguments(json_encode(['file'=>'/tmp/testfile.log','text'=>'testtext'])); |
35
|
|
|
$action->setType('real'); |
36
|
|
|
$action->setAlias('file.write'); |
37
|
|
|
$action->setDevice($device); |
38
|
|
|
$action->setName("Write file to disk"); |
39
|
|
|
$action->setExecutor('FileWriter:write'); |
40
|
|
|
|
41
|
|
|
$manager->persist($action); |
42
|
|
|
|
43
|
|
|
$varHook = new VarHook(); |
44
|
|
|
$varHook->setVariable($variable); |
45
|
|
|
$varHook->setAction($action); |
46
|
|
|
$varHook->setName("Test variable hook"); |
47
|
|
|
$varHook->setType("decider"); |
48
|
|
|
$varHook->setExecutor("FileWriter:decideTrue"); |
49
|
|
|
$varHook->setArguments('{"text":"test text"}'); |
50
|
|
|
|
51
|
|
|
$manager->persist($varHook); |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
$manager->flush(); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|