function getByStationIdArray($id)
 {
     $sblf = new StationBranchListFactory();
     $sblf->getByStationId($id);
     foreach ($sblf as $obj) {
         $list[$obj->getStation()] = NULL;
     }
     if (isset($list)) {
         return $list;
     }
     return array();
 }
 function setBranch($ids)
 {
     Debug::text('Setting IDs...', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Arr($ids, 'IDs: ', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($ids)) {
         $tmp_ids = array();
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $lf_a = new StationBranchListFactory();
             $lf_a->getByStationId($this->getId());
             foreach ($lf_a as $obj) {
                 $id = $obj->getBranch();
                 Debug::text('Branch ID: ' . $obj->getBranch() . ' ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                 //Delete users that are not selected.
                 if (!in_array($id, $ids)) {
                     Debug::text('Deleting: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $obj->Delete();
                 } else {
                     //Save ID's that need to be updated.
                     Debug::text('NOT Deleting : ' . $id, __FILE__, __LINE__, __METHOD__, 10);
                     $tmp_ids[] = $id;
                 }
             }
             unset($id, $obj);
         }
         //Insert new mappings.
         $lf_b = new BranchListFactory();
         foreach ($ids as $id) {
             if (isset($ids) and !in_array($id, $tmp_ids)) {
                 $f = new StationBranchFactory();
                 $f->setStation($this->getId());
                 $f->setBranch($id);
                 $obj = $lf_b->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('branch', $f->Validator->isValid(), TTi18n::gettext('Selected Branch is invalid') . ' (' . $obj->getName() . ')')) {
                     $f->save();
                 }
             }
         }
         return TRUE;
     }
     Debug::text('No IDs to set.', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }