Пример #1
0
 /**
  * To string
  *
  * @return string
  */
 public function __toString()
 {
     $result = 'New GroupGenre';
     if (null !== $this->group && null !== $this->genre) {
         $result = $this->group->getName() . ' - ' . $this->genre->getName();
     }
     return $result;
 }
Пример #2
0
 /**
  * To string
  *
  * @return string
  */
 public function __toString()
 {
     $result = 'New EventGroup';
     if (null !== $this->event && null !== $this->group) {
         $result = $this->event->getName() . ' - ' . $this->group->getName();
     }
     return $result;
 }
Пример #3
0
 /**
  * Test an empty Group entity
  */
 public function testEmptyGroup()
 {
     $group = new Group();
     $this->assertNull($group->getId());
     $this->assertNull($group->getName());
     $this->assertNull($group->getDescription());
     $this->assertNull($group->getCreatedBy());
     $this->assertNull($group->getUpdatedBy());
     $this->assertNull($group->getSlug());
 }
 /**
  * Find Album group
  *
  * @param Group  $group Group
  * @param string $album Album
  *
  * @throws BadRequestHttpException
  *
  * @return []
  */
 public function findAlbumGroup($group, $album)
 {
     $response = $this->client->get($this->lastFmApiUrl, ['query' => ['method' => 'album.getinfo', 'artist' => $group->getName(), 'album' => $album, 'api_key' => $this->lastFmKey, 'format' => 'json']]);
     $data = json_decode((string) $response->getBody()->getContents(), true);
     if (array_key_exists('error', $data)) {
         throw new BadRequestHttpException('Не правильний запит');
     }
     $durationMinutes = 0;
     $album = $data['album'];
     if (!array_key_exists('wiki', $album)) {
         $album['wiki']['published'] = 'Не відомо';
     }
     foreach ($album['tracks']['track'] as $track) {
         $durationMinutes += $track['duration'];
     }
     $album['duration'] = ['hour' => round($durationMinutes / 60), 'minute' => $durationMinutes % 60];
     $album['groupSlug'] = $group->getSlug();
     return $album;
 }
 /**
  * Convert object AppBundle\Entity\Group to AppBundle\Form\Entity\Group
  *
  * @param Group $group Group
  *
  * @return GroupForm[]
  */
 public function convertToGroupForm(Group $group)
 {
     return (new GroupForm())->setName($group->getName())->setDescription($group->getDescription())->setCountry($group->getCountry())->setCity($group->getCity())->setFoundedAt($group->getFoundedAt()->format('Y'));
 }