add changetype
This commit is contained in:
parent
a44350407e
commit
109e7d679c
|
@ -267,6 +267,14 @@ class Importer {
|
|||
}
|
||||
else {
|
||||
$type = $firstAttribute[Importer::VALUE];
|
||||
if ($type === 'add') {
|
||||
$attributes = array();
|
||||
foreach ($entry as $line) {
|
||||
$lineData = $this->getLineKeyValue($line);
|
||||
$attributes[$lineData[Importer::KEY]][] = $lineData[Importer::VALUE];
|
||||
}
|
||||
return new AddEntryTask($dn, $attributes);
|
||||
}
|
||||
$changes = array();
|
||||
$subtasks = array();
|
||||
$currentLines = array();
|
||||
|
@ -286,7 +294,7 @@ class Importer {
|
|||
$currentLines[] = $line;
|
||||
}
|
||||
$subtasks[] = $this->getChangeTypeTask($dn, $currentLines, $type);
|
||||
return new MultiTask($subtasks);
|
||||
return new MultiTask($subtasks, $dn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +313,7 @@ class Importer {
|
|||
$attributes[$lineData[Importer::KEY]][] = $lineData[Importer::VALUE];
|
||||
}
|
||||
if ($type === 'add') {
|
||||
return new AddAttributesTask($dn, $attributes);
|
||||
return new AddEntryTask($dn, $attributes);
|
||||
}
|
||||
throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . ' - ' . Importer::CHANGETYPE . ': ' . htmlspecialchars($type));
|
||||
}
|
||||
|
@ -414,13 +422,19 @@ class MultiTask implements ImporterTask {
|
|||
*/
|
||||
private $tasks = array();
|
||||
|
||||
/**
|
||||
* @var string DN
|
||||
*/
|
||||
private $dn = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ImporterTask[] $tasks tasks
|
||||
*/
|
||||
public function __construct($tasks) {
|
||||
public function __construct($tasks, $dn) {
|
||||
$this->tasks = $tasks;
|
||||
$this->dn = $dn;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
use \LAM\TOOLS\IMPORT_EXPORT\Importer;
|
||||
use LAM\TOOLS\IMPORT_EXPORT\MultiTask;
|
||||
use LAM\TOOLS\IMPORT_EXPORT\AddAttributesTask;
|
||||
use LAM\TOOLS\IMPORT_EXPORT\AddEntryTask;
|
||||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||
|
@ -157,10 +158,8 @@ class ImporterTest extends PHPUnit_Framework_TestCase {
|
|||
$importer = new Importer();
|
||||
$tasks = $importer->getTasks($lines);
|
||||
$this->assertEquals(1, sizeof($tasks));
|
||||
$multiTask = $tasks[0];
|
||||
$this->assertEquals(MultiTask::class, get_class($multiTask));
|
||||
$this->assertEquals(1, sizeof($multiTask->getTasks()));
|
||||
$this->assertEquals(AddAttributesTask::class, get_class($multiTask->getTasks()[0]));
|
||||
$task = $tasks[0];
|
||||
$this->assertEquals(AddEntryTask::class, get_class($task));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue