Beispiel #1
0
 /**
  * Transforms the leagues property to league entities.
  *
  * @param array $values
  *   The source value of the leagues property.
  * @param \stdClass $context
  *   The source object representing this sport.
  * @param EntityManagerInterface $entityManager
  *   The entity manager.
  *
  * @return \TheSportsDb\Entity\LeagueInterface[]
  *   The league entities.
  */
 public static function transformLeagues($values, $context, EntityManagerInterface $entityManager)
 {
     $mappedLeagues = array();
     foreach ($values as $leagueData) {
         $mappedLeagues[] = $entityManager->repository('league')->byId($leagueData->idLeague);
     }
     return $mappedLeagues;
 }
Beispiel #2
0
 /**
  * Transforms a property value to an entity.
  *
  * @param mixed $value
  *   The value to transform.
  * @param \stdClass $context
  *   The context for this mapping. Usually the raw entity as defined by the
  *   sportsdb api this property is from.
  * @param EntityManagerInterface $entityManager
  *   The entity manager.
  * @param string $entityType
  *   The enitity type to transform this value to.
  * @param string $idName
  *   The name of the identifier property as defined by the sportsdb api.
  * @param array $contextPropertyMap
  *   Extra properties to map from the context
  *
  * @return \TheSportsDb\Entity\EntityInterface
  *   The mapped entity.
  */
 public static function transform($value, $context, EntityManagerInterface $entityManager, $entityType, $idName, array $contextPropertyMap = array())
 {
     $data = static::transformHelper($value, $context, $idName, $contextPropertyMap);
     $entity = $entityManager->repository($entityType)->byId($data['id']);
     // Update with given values.
     $entity->update($data['object']);
     return $entity;
 }
Beispiel #3
0
 /**
  * Transforms the events property to event entities.
  *
  * @param array $values
  *   The source value of the event property.
  * @param \stdClass $context
  *   The source object representing this season.
  * @param EntityManagerInterface $entityManager
  *   The entity manager.
  *
  * @return \TheSportsDb\Entity\EventInterface[]
  *   The event entity.
  */
 public static function transformEvents(array $values, $context, EntityManagerInterface $entityManager)
 {
     $mappedEvents = array();
     foreach ($values as $eventData) {
         $mappedEvents[] = $entityManager->repository('event')->byId($eventData->idEvent);
     }
     return $mappedEvents;
 }
Beispiel #4
0
 /**
  * Transforms the seasons property to season entities.
  *
  * @param array $values
  *   The source value of the seasons property.
  * @param \stdClass $context
  *   The source object representing this league.
  * @param EntityManagerInterface $entityManager
  *   The entity manager.
  *
  * @return \TheSportsDb\Entity\SeasonInterface[]
  *   The season entities.
  */
 public static function transformSeasons($values, $context, EntityManagerInterface $entityManager)
 {
     $mappedSeasons = array();
     foreach ($values as $season) {
         $id = $season->strSeason . '|' . $season->idLeague;
         $mappedSeasons[] = $entityManager->repository('season')->byId($id);
     }
     return $mappedSeasons;
 }