diff --git a/src/Option/Parser/Select.php b/src/Option/Parser/Select.php index e1274c8..c4ee7b2 100644 --- a/src/Option/Parser/Select.php +++ b/src/Option/Parser/Select.php @@ -52,6 +52,7 @@ class Select extends Base private function parseModePapierDb() { + $this->element->setNewPaperObject($this->getPaperRepository()->getNewObject()); /** @var PaperContainer\Container $container */ $container = $this->getPaperContainer()->getContainerById((string)$this->node['container']); diff --git a/src/Option/Type/PaperDbSelect.php b/src/Option/Type/PaperDbSelect.php index e5dc2d6..456b004 100644 --- a/src/Option/Type/PaperDbSelect.php +++ b/src/Option/Type/PaperDbSelect.php @@ -7,6 +7,8 @@ use PSC\Library\Calc\Tests\Mock\Paper; class PaperDbSelect extends Select { + protected $newPaperObject = null; + public function getSelectedOption() { /** @var Opt $opt */ @@ -20,7 +22,7 @@ class PaperDbSelect extends Select $opt->setId($this->savedCalcValues[$this->getId()]['art_nr']); $opt->setLabel($this->savedCalcValues[$this->getId()]['description_1']); - $paper = new Paper(); + $paper = $this->newPaperObject; $paper->setId($this->savedCalcValues[$this->getId()]['id']); $paper->setArtNr($this->savedCalcValues[$this->getId()]['art_nr']); $paper->setDescription1($this->savedCalcValues[$this->getId()]['description_1']); @@ -119,4 +121,12 @@ class PaperDbSelect extends Select return $variables; } + /** + * @param null $newPaperObject + */ + public function setNewPaperObject($newPaperObject) + { + $this->newPaperObject = $newPaperObject; + } + } \ No newline at end of file diff --git a/tests/Mock/PaperRepostory.php b/tests/Mock/PaperRepostory.php index 0a23c05..b5c3660 100644 --- a/tests/Mock/PaperRepostory.php +++ b/tests/Mock/PaperRepostory.php @@ -214,4 +214,9 @@ class PaperRepostory implements ObjectRepository { // TODO: Implement getClassName() method. } + + public function getNewObject() + { + return new Paper(); + } }