diff --git a/src/Command/LoadOrganizationalUnitDefaultCommand.php b/src/Command/LoadOrganizationalUnitDefaultCommand.php new file mode 100644 index 0000000..42ed7f4 --- /dev/null +++ b/src/Command/LoadOrganizationalUnitDefaultCommand.php @@ -0,0 +1,144 @@ + 'Universidad Test', + 'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT + ] + ]; + + $classrooms = [ + [ + 'name' => 'Aula Test 1', + 'type' => OrganizationalUnitTypes::CLASSROOM + ], + [ + 'name' => 'Aula Test 2', + 'type' => OrganizationalUnitTypes::CLASSROOM + ], + [ + 'name' => 'Aula Test 3', + 'type' => OrganizationalUnitTypes::CLASSROOM + ] + ]; + + $clientsA = [ + [ + 'name' => 'Cliente Test 1a', + 'ip' => '1.1.1.1', + 'mac' => '00:1A:2B:3C:4D:5E', + ], + [ + 'name' => 'Cliente Test 1b', + 'ip' => '2.2.2.2', + 'mac' => '00:1B:3C:4D:5E:6F' + ], + [ + 'name' => 'Cliente Test 1c', + 'ip' => '3.3.3.3', + 'mac' => '00:1C:4D:5E:6F:7A' + ] + ]; + + $clientsB = [ + [ + 'name' => 'Cliente Test 2a', + 'ip' => '4.4.4.4', + 'mac' => '00:1D:5E:6F:7A:8B' + ], + [ + 'name' => 'Cliente Test 2b', + 'ip' => '5.5.5.5', + 'mac' => '00:1E:6F:7A:8B:9C' + ], + [ + 'name' => 'Cliente Test 2c', + 'ip' => '6.6.6.6', + 'mac' => '00:1F:7A:8B:9C:AD' + ], + ]; + + $clientsC = [ + [ + 'name' => 'Cliente Test 3a', + 'ip' => '7.7.7.7.', + 'mac' => '00:2A:8B:9C:AD:BE' + ], + [ + 'name' => 'Cliente Test 3b', + 'ip' => '8.8.8.8', + 'mac' => '00:2B:9C:AD:BE:CF' + ], + [ + 'name' => 'Cliente Test 3c', + 'ip' => '9.9.9.9', + 'mac' => '00:2C:AD:BE:CF:D0' + ] + ]; + + + foreach ($organizationalUnits as $organizationalUnit) { + $organizationalUnitEntity = new OrganizationalUnit(); + $organizationalUnitEntity->setName($organizationalUnit['name']); + $organizationalUnitEntity->setType($organizationalUnit['type']); + + $this->entityManager->persist($organizationalUnitEntity); + + foreach ($classrooms as $classroom) { + $classroomEntity = new OrganizationalUnit(); + $classroomEntity->setName($classroom['name']); + $classroomEntity->setType($classroom['type']); + $classroomEntity->setParent($organizationalUnitEntity); + $this->entityManager->persist($classroomEntity); + + + if ($classroomEntity->getName() === 'Aula Test 1') { + $clients = $clientsA; + } elseif ($classroomEntity->getName() === 'Aula Test 2') { + $clients = $clientsB; + } elseif ($classroomEntity->getName() === 'Aula Test 3') { + $clients = $clientsC; + } + + foreach ($clients as $client) { + $clientEntity = new Client(); + $clientEntity->setName($client['name']); + $clientEntity->setIp($client['ip']); + $clientEntity->setMac($client['mac']); + $clientEntity->setMaintenance(false); + $clientEntity->setOrganizationalUnit($classroomEntity); + $this->entityManager->persist($clientEntity); + + } + } + + $this->entityManager->flush(); + } + + return Command::SUCCESS; + } +}