Beispiel #1
0
 /**
  * Create a location object and return it.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5)
  * );
  *
  * $locations   = new Crowdfunding\Location\Locations(\JFactory::getDbo());
  * $locations->load($options);
  *
  * $locationId = 1;
  * $location   = $locations->getLocation($locationId);
  * </code>
  *
  * @param int|string $id Location ID or location name.
  *
  * @return null|Location
  */
 public function getLocation($id)
 {
     if (!$id) {
         throw new \UnexpectedValueException(\JText::_('LIB_CROWDFUNDING_INVALID_LOCATION_ID'));
     }
     $location = null;
     foreach ($this->items as $item) {
         if (is_numeric($id) and (int) $id === (int) $item['id']) {
             $location = new Location($this->db);
             $location->bind($item);
             break;
         } elseif (strcmp($id, $item['name']) === 0) {
             $location = new Location($this->db);
             $location->bind($item);
             break;
         }
     }
     return $location;
 }
 /**
  * Return the locations as array with objects.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5)
  * );
  *
  * $locations   = new Crowdfunding\Location\Locations(\JFactory::getDbo());
  * $locations->load($options);
  *
  * $items = $locations->getLocations();
  * </code>
  *
  * @return array
  */
 public function getLocations()
 {
     $results = array();
     $i = 0;
     foreach ($this->items as $item) {
         $location = new Location($this->db);
         $location->bind($item);
         $results[$i] = $location;
         $i++;
     }
     return $results;
 }