Пример #1
0
 /**
  * Remove lyric of this object
  * through the artist_lyric cross reference table.
  *
  * @param ChildLyric $lyric
  * @return ChildArtist The current object (for fluent API support)
  */
 public function removeLyric(ChildLyric $lyric)
 {
     if ($this->getLyrics()->contains($lyric)) {
         $artistLyric = new ArtistLyric();
         $artistLyric->setLyric($lyric);
         if ($lyric->isArtistsLoaded()) {
             //remove the back reference if available
             $lyric->getArtists()->removeObject($this);
         }
         $artistLyric->setArtist($this);
         $this->removeArtistLyric(clone $artistLyric);
         $artistLyric->clear();
         $this->collLyrics->remove($this->collLyrics->search($lyric));
         if (null === $this->lyricsScheduledForDeletion) {
             $this->lyricsScheduledForDeletion = clone $this->collLyrics;
             $this->lyricsScheduledForDeletion->clear();
         }
         $this->lyricsScheduledForDeletion->push($lyric);
     }
     return $this;
 }
Пример #2
0
 /**
  * Filter the query by a related \Tekstove\ApiBundle\Model\Artist\ArtistLyric object
  *
  * @param \Tekstove\ApiBundle\Model\Artist\ArtistLyric|ObjectCollection $artistLyric the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildLyricQuery The current query, for fluid interface
  */
 public function filterByArtistLyric($artistLyric, $comparison = null)
 {
     if ($artistLyric instanceof \Tekstove\ApiBundle\Model\Artist\ArtistLyric) {
         return $this->addUsingAlias(LyricTableMap::COL_ID, $artistLyric->getLyricId(), $comparison);
     } elseif ($artistLyric instanceof ObjectCollection) {
         return $this->useArtistLyricQuery()->filterByPrimaryKeys($artistLyric->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByArtistLyric() only accepts arguments of type \\Tekstove\\ApiBundle\\Model\\Artist\\ArtistLyric or Collection');
     }
 }
Пример #3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database. In some cases you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by find*()
  * and findPk*() calls.
  *
  * @param \Tekstove\ApiBundle\Model\Artist\ArtistLyric $obj A \Tekstove\ApiBundle\Model\Artist\ArtistLyric object.
  * @param string $key             (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if (null === $key) {
             $key = serialize([null === $obj->getLyricId() || is_scalar($obj->getLyricId()) || is_callable([$obj->getLyricId(), '__toString']) ? (string) $obj->getLyricId() : $obj->getLyricId(), null === $obj->getArtistId() || is_scalar($obj->getArtistId()) || is_callable([$obj->getArtistId(), '__toString']) ? (string) $obj->getArtistId() : $obj->getArtistId()]);
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #4
0
 /**
  * Update artists to given array of ids.
  * Order is the same as keys in the array
  * @param array $artistsIds
  * @throws \Exception
  */
 public function setArtistsIds(array $artistsIds)
 {
     $artistLyrics = new \Propel\Runtime\Collection\Collection();
     $artistOrder = 1;
     foreach ($artistsIds as $artistId) {
         $artistQuery = new \Tekstove\ApiBundle\Model\ArtistQuery();
         $artist = $artistQuery->findOneById($artistId);
         if ($artist === null) {
             throw new \Exception("Can not find artist #{$artistId}");
         }
         $artistFound = false;
         foreach ($this->getArtistLyrics() as $artistLyricExisting) {
             if ($artistLyricExisting->getArtist()->getId() == $artistId) {
                 $artistLyricExisting->setOrder($artistOrder);
                 $artistLyrics->append($artistLyricExisting);
                 $artistFound = true;
                 break;
             }
         }
         if (!$artistFound) {
             $artistLyric = new ArtistLyric();
             $artistLyric->setLyric($this);
             $artistLyric->setArtist($artist);
             $artistLyric->setOrder($artistOrder);
             $artistLyrics->append($artistLyric);
         }
         $artistOrder++;
     }
     $this->setArtistLyrics($artistLyrics);
 }
Пример #5
0
 /**
  * Exclude object from result
  *
  * @param   ChildArtistLyric $artistLyric Object to remove from the list of results
  *
  * @return $this|ChildArtistLyricQuery The current query, for fluid interface
  */
 public function prune($artistLyric = null)
 {
     if ($artistLyric) {
         $this->addCond('pruneCond0', $this->getAliasedColName(ArtistLyricTableMap::COL_LYRIC_ID), $artistLyric->getLyricId(), Criteria::NOT_EQUAL);
         $this->addCond('pruneCond1', $this->getAliasedColName(ArtistLyricTableMap::COL_ARTIST_ID), $artistLyric->getArtistId(), Criteria::NOT_EQUAL);
         $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
     }
     return $this;
 }