public static function imgPhysicalPathBuilder($mainFolderName, $subFolderName, $fileName_withExstension) { $relativeFilePath = FileSystemService::imgPhysicalPathBuilder($mainFolderName, $subFolderName, $fileName_withExstension); $appRootPath = Yii::getPathOfAlias('webroot') . '/'; // e.g. 'c:/htdocs/' $physicalPath = $appRootPath . $relativeFilePath; return $physicalPath; }
public function deepDelete($thatTransaction = null) { $transaction = null; $isHandlingTransaction = $thatTransaction == null; if ($isHandlingTransaction) { $transaction = Yii::app()->db->beginTransaction(); } else { $transaction = $thatTransaction; } try { /** remove all bookmark */ $allBookmarkRelations_array = $this->bookmarkRelations; foreach ($allBookmarkRelations_array as $bookmarkRelation) { $bookmarkRelation->delete(); } //remove the ownership of this illust $allOwnerShip_array = $this->ownership; foreach ($allOwnerShip_array as $ownership) { $ownership->delete(); } //remove all viewed user relation with this illust $allViewedRelation_array = $this->viewedUserRelation; foreach ($allViewedRelation_array as $viewedRelation) { $viewedRelation->delete(); } /**remove all the img */ $allFullImgFilePath = $this->getAllImgSrcPhysicalPath(); foreach ($allFullImgFilePath as $fullImgPath) { FileSystemService::removeFile($fullImgPath); } /** remove itself */ $this->delete(); if ($isHandlingTransaction) { $transaction->commit(); } } catch (Exception $ex) { if ($isHandlingTransaction) { $transaction->rollback(); } throw $ex; } }
/** @relation-command */ public function deepDelete($thatTransaction = null) { $transaction = null; $isHandlingTransaction = $thatTransaction == null; if ($isHandlingTransaction) { $transaction = Yii::app()->db->beginTransaction(); } else { $transaction = $thatTransaction; } try { /** remove all related events */ $allEventRelations_array = $this->eventRelations; foreach ($allEventRelations_array as $eventRelation) { $eventRelation->delete(); } //remove all viewed relation $allUserViewdRelation_array = $this->UserViewedRelations; foreach ($allUserViewdRelation_array as $userViewedRelation) { $userViewedRelation->delete(); } /**remove all the img */ $allFullImgFilePath = $this->getAllImgSrcPhysicalPath(); foreach ($allFullImgFilePath as $fullImgPath) { FileSystemService::removeFile($fullImgPath); } /** remove itself */ $this->delete(); if ($isHandlingTransaction) { $transaction->commit(); } } catch (Exception $ex) { if ($isHandlingTransaction) { $transaction->rollback(); } throw $ex; } }