Created
June 18, 2015 13:44
-
-
Save zogot/072f93c69f85265478de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function map(SoundGroupModel $soundGroupModel) | |
{ | |
$soundGroupArray = $soundGroupModel->toArray(); | |
$soundGroup = $this->mapper->map($soundGroupArray); | |
$customFiles = $soundGroup->getCustomFiles(); | |
foreach ($soundGroupModel->files as $soundGroupFileModel) { | |
// Needed variables | |
$name = $soundGroupFileModel->name; | |
$relativePath = $soundGroupFileModel->relative_path; | |
$absolutePath = $soundGroupFileModel->absolute_path; | |
// Get the root of the application and the custom folder for this sound file. | |
$root = str_replace("/$relativePath", '', $absolutePath); | |
$folder = str_replace("$name", '', $relativePath); | |
// Get the custom file. | |
$folderCollection = $customFiles->getFolder($folder); | |
$foundFile = $folderCollection->getFile($name); | |
$newFile = (new SoundFile($root, $relativePath)) | |
->setAltered(true) | |
->setMigrating($soundGroupFileModel->migrating); | |
if ( is_null($foundFile)) { | |
$folderCollection->push($newFile); | |
} else { | |
$folderCollection->replaceFile($newFile); | |
} | |
} | |
return $soundGroup; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment