3 namespace Domain\Entities\StepMania
;
6 use Domain\Entities\StepMania\ISimfile
;
7 use Domain\Entities\IUser
;
8 use Domain\Entities\IFile
;
9 use Domain\Entities\StepMania\IPack
;
10 use Domain\Entities\AbstractEntity
;
12 class Pack
extends AbstractEntity
implements IPack
20 public function __construct(
27 $this->_title
= $title;
28 $this->_uploader
= $uploader;
29 $this->_banner
= $banner;
32 foreach($simfiles as $simfile) {
33 if(!$simfile instanceof ISimfile
) {
34 throw new Exception('Invalid Simfile array. All elements must be an instance of ISimfile.');
38 $this->_simfiles
= $simfiles;
41 public function getContributors() {
42 $contributors = array();
43 foreach($this->_simfiles
as $simfile)
45 /* @var $simfile \Domain\Entities\StepMania\Simfile */
46 $contributors = array_unique(
47 array_merge($contributors, $this->getAllStepArtistsFromSimfile($simfile))
51 //XXX: If there are duplicate contributors, say, index 5 and 6 are the same
52 //then we loose index 5 and have an array like 1,2,3,4,6
54 //This makes json_encode use the indicies as object keys, so we need to
55 //reshuffle the array into a continuous list
56 return array_values($contributors);
59 public function getFile()
64 public function getSimfiles()
66 return $this->_simfiles
;
69 public function getTitle()
74 public function getUploader()
76 return $this->_uploader
;
79 public function getBanner()
81 return $this->_banner
;
84 private function getAllStepArtistsFromSimfile(ISimfile
$simfile)
87 foreach($simfile->getSteps() as $steps)
89 /* @var $steps \Domain\VOs\StepMania\StepChart */
90 if($steps->getArtist()->getTag() && !in_array($steps->getArtist()->getTag(), $artists)) $artists[] = $steps->getArtist()->getTag();