From 0e6002f6e0be7120ce04634dc22602b01e084f9c Mon Sep 17 00:00:00 2001 From: Francois Suter Date: Tue, 8 Mar 2016 10:22:53 +0100 Subject: [PATCH] [FOLLOWUP] Added missing class --- Classes/Domain/Model/RecordLink.php | 134 ++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Classes/Domain/Model/RecordLink.php diff --git a/Classes/Domain/Model/RecordLink.php b/Classes/Domain/Model/RecordLink.php new file mode 100644 index 0000000..04c504f --- /dev/null +++ b/Classes/Domain/Model/RecordLink.php @@ -0,0 +1,134 @@ +setRecordReference($recordReference); + } + } + + /** + * @return string + */ + public function getConfigurationKey() + { + return $this->configurationKey; + } + + /** + * @param string $configurationKey + */ + public function setConfigurationKey($configurationKey) + { + $this->configurationKey = $configurationKey; + } + + /** + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * @param string $table + */ + public function setTable($table) + { + $this->table = $table; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getRecordReference() + { + return $this->recordReference; + } + + /** + * @param string $recordReference + * @throws \InvalidArgumentException + */ + public function setRecordReference($recordReference) + { + if (empty($recordReference)) { + throw new \InvalidArgumentException( + 'Record reference cannot be empty', + 1457367830 + ); + } + $referenceParts = explode(':', $recordReference); + if (count($referenceParts) === 4) { + $this->recordReference = $recordReference; + $this->configurationKey = $referenceParts[1]; + $this->table = $referenceParts[2]; + $this->id = (int)$referenceParts[3]; + } else { + throw new \InvalidArgumentException( + 'Expected record reference structure is "record:key:table:id"', + 1457367830 + ); + } + } + +} \ No newline at end of file