Override Podcast->fromArray
This commit is contained in:
parent
c166b4f00e
commit
40d0619f10
|
@ -27,12 +27,12 @@ class Podcast extends BasePodcast
|
||||||
*/
|
*/
|
||||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
|
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
|
||||||
{
|
{
|
||||||
$podcastArray = parent::toArray(BasePeer::TYPE_FIELDNAME);
|
$podcastArray = parent::toArray($keyType);
|
||||||
|
|
||||||
$importedPodcast = ImportedPodcastQuery::create()->filterByDbPodcastId($this->getDbId())->findOne();
|
$importedPodcast = ImportedPodcastQuery::create()->filterByDbPodcastId($this->getDbId())->findOne();
|
||||||
$stationPodcast = StationPodcastQuery::create()->filterByDbPodcastId($this->getDbId())->findOne();
|
$stationPodcast = StationPodcastQuery::create()->filterByDbPodcastId($this->getDbId())->findOne();
|
||||||
if (!is_null($importedPodcast)) {
|
if (!is_null($importedPodcast)) {
|
||||||
$importedPodcastArray = $importedPodcast->toArray(BasePeer::TYPE_FIELDNAME);
|
$importedPodcastArray = $importedPodcast->toArray($keyType);
|
||||||
|
|
||||||
//unset these values because we already have the podcast id in $podcastArray
|
//unset these values because we already have the podcast id in $podcastArray
|
||||||
//and we don't need the imported podcast ID
|
//and we don't need the imported podcast ID
|
||||||
|
@ -43,7 +43,7 @@ class Podcast extends BasePodcast
|
||||||
|
|
||||||
} else if (!is_null($stationPodcast)) {
|
} else if (!is_null($stationPodcast)) {
|
||||||
// For now just return $podcastArray because StationPodcast objects do not have any
|
// For now just return $podcastArray because StationPodcast objects do not have any
|
||||||
// extra fields we want to return right now. This may change in the future.
|
// extra fields we want to return. This may change in the future.
|
||||||
return $podcastArray;
|
return $podcastArray;
|
||||||
} else {
|
} else {
|
||||||
return $podcastArray;
|
return $podcastArray;
|
||||||
|
@ -51,4 +51,26 @@ class Podcast extends BasePodcast
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this function so it updates the child class as well.
|
||||||
|
* Child class will either be ImportedPodcast or StationPodcast
|
||||||
|
*
|
||||||
|
* @param array $arr
|
||||||
|
* @param string $keyType
|
||||||
|
* @throws Exception
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
parent::fromArray($arr, $keyType);
|
||||||
|
|
||||||
|
$importedPodcast = ImportedPodcastQuery::create()->filterByDbPodcastId($this->getDbId())->findOne();
|
||||||
|
if (!is_null($importedPodcast)) {
|
||||||
|
$importedPodcast->fromArray($arr, $keyType);
|
||||||
|
$importedPodcast->save();
|
||||||
|
} else {
|
||||||
|
//TODO: station podcast
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,19 +278,11 @@ class Application_Service_PodcastService
|
||||||
throw new PodcastNotFoundException();
|
throw new PodcastNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::removePrivateFields($data);
|
self::removePrivateFields($data["podcast"]);
|
||||||
self::validatePodcastMetadata($data);
|
self::validatePodcastMetadata($data["podcast"]);
|
||||||
|
|
||||||
$importedPodcast = ImportedPodcastQuery::create()->filterByDbPodcastId($podcast->getDbId())->findOne();
|
$podcast->fromArray($data["podcast"], BasePeer::TYPE_FIELDNAME);
|
||||||
if (!is_null($importedPodcast)) {
|
$podcast->save();
|
||||||
$importedPodcast->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
|
||||||
$importedPodcast->save();
|
|
||||||
} else {
|
|
||||||
//TODO: station podcast
|
|
||||||
}
|
|
||||||
|
|
||||||
//$podcast->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
|
||||||
//$podcast->save();
|
|
||||||
|
|
||||||
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
|
return $podcast->toArray(BasePeer::TYPE_FIELDNAME);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue