当前位置: 首页>>代码示例>>PHP>>正文


PHP Artist::setSpotifyId方法代码示例

本文整理汇总了PHP中Artist::setSpotifyId方法的典型用法代码示例。如果您正苦于以下问题:PHP Artist::setSpotifyId方法的具体用法?PHP Artist::setSpotifyId怎么用?PHP Artist::setSpotifyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Artist的用法示例。


在下文中一共展示了Artist::setSpotifyId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findEvents

 public static function findEvents($entityManager, $date)
 {
     error_log("date: " . $date->format('Y-m-d'));
     $query = $entityManager->createQuery('SELECT count(e) FROM Event e WHERE e.date LIKE :date');
     $query->setParameter("date", "%" . $date->format('m-d'));
     $eventNumber = $query->getSingleScalarResult();
     if ($eventNumber) {
         error_log("events for " . $date->format('Y-m-d') . " already exist.");
         return "1";
     }
     $dim = new \ThisDayIn\Music($date->format('j'), $date->format('F'));
     $evs = $dim->getEvents();
     foreach ($evs as $ev) {
         $date = new \DateTime($ev['date']);
         if ($ev['type'] === 'Death') {
             $ev['description'] = sprintf('%s, %s', $ev['name'], $ev['description']);
         }
         //unlike the death events, the birth events do not include enough information in the description.
         if ($ev['type'] === 'Birth') {
             $ev['description'] = sprintf('%s, %s was born', $ev['name'], $ev['description']);
         }
         //must find artist name for these kind of events
         if ($ev['type'] == 'Event') {
             $artist = self::findEventArtist($ev['description']);
             $ev['name'] = $artist['name'];
             if (isset($artist['spotifyId'])) {
                 $ev['spotifyId'] = $artist['spotifyId'];
             }
         }
         #TODO: find artist spotify id for the other event types
         //set current event
         $event = new \Event();
         $event->setDate($date);
         $event->setDescription($ev['description']);
         $event->setType($ev['type']);
         $event->setSource($dim->getSource());
         //connects the event to an artist
         if ($ev['name']) {
             $artist = $entityManager->getRepository('Artist')->findBy(array('name' => $ev['name']));
             $artist = array_shift($artist);
             if (!$artist) {
                 $artist = new \Artist();
                 $artist->setName($ev['name']);
                 if (isset($ev['spotifyId'])) {
                     $artist->setSpotifyId($ev['spotifyId']);
                 }
             }
             error_log("artist name: " . $artist->getName());
             $event->setArtist($artist);
             $entityManager->persist($event);
             $artist->assignToEvent($event);
             $entityManager->persist($artist);
             #one must save here so it copes for repeated artist in the event list
             $entityManager->flush();
         }
         $entityManager->persist($event);
     }
     //insert all events to db
     if (count($evs)) {
         $entityManager->flush();
     }
     return 0;
 }
开发者ID:andreiamlm,项目名称:ThisDayInMusic,代码行数:63,代码来源:ThisDayInMusic.php


注:本文中的Artist::setSpotifyId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。