club = $this->em()->create('RomhackPlaza\Master:Club'); $this->setUser($creator); $this->setupDefaults(); } protected function setupDefaults() { $this->club->club_state = 'moderated'; } public function getClub() { return $this->club; } public function getUser() { return $this->user; } public function setUser(User $user) { $this->user = $user; $this->club->user_id = $this->user->user_id; } public function setContent(string $title, string $description ) { $this->club->title = $title; $this->club->description = $description; } public function setBannerUpload(?Upload $upload = null) { if ($upload) { $upload->requireImage(); if($upload->isValid()){ $this->bannerUpload = $upload; } } } protected function _validate() { $this->club->preSave(); return $this->club->getErrors(); } protected function _save() { $this->club->save(); if( $this->bannerUpload ){ $path = 'data://club_banners/' . $this->club->club_id . '.jpg'; if( File::copyFileToAbstractedPath($this->bannerUpload->getFileWrapper()->getFilePath(), $path) ){ $this->club->banner_date = \XF::$time; $this->club->save(); } } return $this->club; } }