Skip to content

Commit

Permalink
SyncPropertyForm: provide property modifier...
Browse files Browse the repository at this point in the history
...target columns in the drop-down

fixes #13977
  • Loading branch information
Thomas-Gelf committed Jan 12, 2017
1 parent b450280 commit 8a8c088
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions application/forms/SyncPropertyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class SyncPropertyForm extends DirectorObjectForm
/** @var ImportSource */
private $importSource;

/** @var ImportSourceHook */
private $importSourceHook;

private $dummyObject;

const EXPRESSION = '__EXPRESSION__';
Expand Down Expand Up @@ -247,10 +250,16 @@ protected function enumImportSource()
protected function listSourceColumns()
{
$columns = array();
foreach ($this->getImportSource()->listColumns() as $col) {
$source = $this->getImportSource();
$hook = $this->getImportSourceHook();
foreach ($hook->listColumns() as $col) {
$columns['${' . $col . '}'] = $col;
}

foreach ($source->listModifierTargetProperties() as $property) {
$columns['${' . $property . '}'] = $property;
}

return $columns;
}

Expand Down Expand Up @@ -308,20 +317,37 @@ protected function listDestinationFields()
);
}

/**
* @return ImportSource
*/
protected function getImportSource()
{
if ($this->importSource === null) {
if ($this->hasObject()) {
$src = ImportSource::load($this->object->get('source_id'), $this->db);
$this->importSource = ImportSource::load($this->object->get('source_id'), $this->db);
} else {
$src = ImportSource::load($this->getSentValue('source_id'), $this->db);
$this->importSource = ImportSource::load($this->getSentValue('source_id'), $this->db);
}
$this->importSource = ImportSourceHook::loadByName($src->get('source_name'), $this->db);
}

return $this->importSource;
}

/**
* @return ImportSourceHook
*/
protected function getImportSourceHook()
{
if ($this->importSourceHook === null) {
$this->importSourceHook = ImportSourceHook::loadByName(
$this->getImportSource()->get('source_name'),
$this->db
);
}

return $this->importSourceHook;
}

public function onSuccess()
{
$object = $this->getObject();
Expand Down

0 comments on commit 8a8c088

Please sign in to comment.