|
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('hooktest'); |
|
19
|
|
|
$variable->setDescription('test temperature metric'); |
|
20
|
|
|
$variable->setSource('internal'); |
|
21
|
|
|
$variable->setParser('Simple'); |
|
22
|
|
|
$variable->setValue('20'); |
|
23
|
|
|
$variable->needHistory = true; |
|
24
|
|
|
$variable->needSync = false; |
|
25
|
|
|
|
|
26
|
|
|
$manager->persist($variable); |
|
27
|
|
|
|
|
28
|
|
|
$device = new Device(); |
|
29
|
|
|
$device->setAlias('pi.fs'); |
|
30
|
|
|
$device->setName('Filesystem'); |
|
31
|
|
|
|
|
32
|
|
|
$manager->persist($device); |
|
33
|
|
|
|
|
34
|
|
|
$action = new Action(); |
|
35
|
|
|
|
|
36
|
|
|
$action->setArguments(json_encode(['file'=>'/tmp/testfile.log', 'text'=>'testtext'])); |
|
37
|
|
|
$action->setType('real'); |
|
38
|
|
|
$action->setAlias('file.write'); |
|
39
|
|
|
$action->setDevice($device); |
|
40
|
|
|
$action->setName("Write file to disk"); |
|
41
|
|
|
$action->setExecutor('FileWriter:write'); |
|
42
|
|
|
|
|
43
|
|
|
$manager->persist($action); |
|
44
|
|
|
|
|
45
|
|
|
$varHook = new VarHook(); |
|
46
|
|
|
$varHook->setVariable($variable); |
|
47
|
|
|
$varHook->setAction($action); |
|
48
|
|
|
$varHook->setName("Test variable hook"); |
|
49
|
|
|
$varHook->setType("decider"); |
|
50
|
|
|
$varHook->setExecutor("FileWriter:decideTrue"); |
|
51
|
|
|
$varHook->setArguments('{"text":"test text"}'); |
|
52
|
|
|
|
|
53
|
|
|
$manager->persist($varHook); |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
$manager->flush(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|