diff --git a/config/packages/mapping/Workspace.orm.xml b/config/packages/mapping/Workspace.orm.xml new file mode 100644 index 0000000..42de063 --- /dev/null +++ b/config/packages/mapping/Workspace.orm.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 4374ca8..cb2c9ff 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -1,5 +1,4 @@ id; + } + + /** + * Set the ID of the workspace + *
This should not be done after creation + * + * @param string $id + * @return self + */ + public function setId(string $id): self + { + $this->id = $id; + + return $this; + } + + /** + * Generate and save a random ID + * + * @return string Generated ID + */ + public function generateId(): string + { + // Generate ID + $base = array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')); + $id = ""; + for ($index = 0; $index < 8; $index ++) { + $id .= $base[rand(0, count($base) - 1)]; + } + + // Save and return + $this->setId($id); + return $id; + } + + /** + * Get the name of the workspace + * + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * Set a new name for the workspace + * @param string $name + * @return self + */ + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + /** + * If the workspace is active + * + * @return bool + */ + public function getActive(): bool + { + return $this->active; + } + + /** + * Set the active status of the workspace + * + * @param bool $active + * @return self + */ + public function setActive(bool $active): self + { + $this->active = $active; + + return $this->active; + } +} \ No newline at end of file diff --git a/src/Repository/WorkspaceRepository.php b/src/Repository/WorkspaceRepository.php new file mode 100644 index 0000000..dedbfad --- /dev/null +++ b/src/Repository/WorkspaceRepository.php @@ -0,0 +1,9 @@ +