public function buildMerchants($xml) { $merchants = new Merchants(); $merchants->setPageOffset((string) $xml->PageOffset); $merchants->setTotalCount((string) $xml->TotalCount); // merchant $merchantArray = array(); foreach ($xml->Merchant as $merchant) { $tmpMerchant = new Merchant(); $tmpMerchant->setId((string) $merchant->Id); $tmpMerchant->setName((string) $merchant->Name); $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl); $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber); $tmpMerchant->setCategory((string) $merchant->Category); $tmpLocation = new Location(); $location = $merchant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpAcceptance = new Acceptance(); //$acceptance = $merchant->Acceptance; // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpFeatures = new Features(); //$features = $merchant->Features; $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpMerchant->setLocation($tmpLocation); array_push($merchantArray, $tmpMerchant); } $merchants->setMerchant($merchantArray); return $merchants; }
public function buildAtms($xml) { $atms = new Atms(); $atms->setPageOffset($xml->PageOffset); $atms->setTotalCount($xml->TotalCount); $atmArray = array(); foreach ($xml->Atm as $atm) { $tmpAtm = new Atm(); $tmpAtm->setHandicapAccessible((string) $atm->HandicapAccessible); $tmpAtm->setCamera((string) $atm->Camera); $tmpAtm->setAvailability((string) $atm->Availability); $tmpAtm->setAccessFees((string) $atm->AccessFees); $tmpAtm->setOwner((string) $atm->Owner); $tmpAtm->setSharedDeposit((string) $atm->SharedDeposit); $tmpAtm->setSurchargeFreeAlliance((string) $atm->SurchargeFreeAlliance); $tmpAtm->setSponsor((string) $atm->Sponsor); $tmpAtm->setSupportEMV((string) $atm->SupportEMV); $tmpAtm->setSurchargeFreeAllianceNetwork((string) $atm->SurchargeFreeAllianceNetwork); $tmpLocation = new Location(); $location = $atm->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpAtm->setLocation($tmpLocation); array_push($atmArray, $tmpAtm); } $atms->setAtm($atmArray); return $atms; }
public function buildAtms($xml) { $pageOffset = (string) $xml->PageOffset; $totalCount = (string) $xml->TotalCount; $restaurantArray = array(); foreach ($xml->Restaurant as $restaurant) { $tmpRestaurant = new Restaurant(); $tmpRestaurant->setId((string) $restaurant->Id); $tmpRestaurant->setName((string) $restaurant->Name); $tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl); $tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber); $tmpRestaurant->setCategory((string) $restaurant->Category); $tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd); $tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd); $tmpLocation = new Location(); $location = $restaurant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpRestaurant->setLocation($tmpLocation); array_push($restaurantArray, $tmpRestaurant); } $restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray); return $restaurants; }
/** * Get employee list after sorting and filtering using given parameters. * * @param EmployeeSearchParameterHolder $parameterHolder */ public function searchEmployees(EmployeeSearchParameterHolder $parameterHolder) { $sortField = $parameterHolder->getOrderField(); $sortOrder = $parameterHolder->getOrderBy(); $offset = $parameterHolder->getOffset(); $limit = $parameterHolder->getLimit(); $filters = $parameterHolder->getFilters(); $returnType = $parameterHolder->getReturnType(); $select = ''; $query = ''; $bindParams = array(); $orderBy = ''; $this->_getEmployeeListQuery($select, $query, $bindParams, $orderBy, $sortField, $sortOrder, $filters); $completeQuery = $select . ' ' . $query . ' ' . $orderBy; if (!is_null($offset) && !is_null($limit)) { $completeQuery .= ' LIMIT ' . $offset . ', ' . $limit; } if (sfConfig::get('sf_logging_enabled')) { $msg = $completeQuery; if (count($bindParams) > 0) { $msg .= ' (' . implode(',', $bindParams) . ')'; } sfContext::getInstance()->getLogger()->info($msg); } $conn = Doctrine_Manager::connection(); $statement = $conn->prepare($completeQuery); $result = $statement->execute($bindParams); if ($returnType == EmployeeSearchParameterHolder::RETURN_TYPE_OBJECT) { $employees = new Doctrine_Collection(Doctrine::getTable('Employee')); if ($result) { while ($row = $statement->fetch()) { $employee = new Employee(); $employee->setEmpNumber($row['empNumber']); $employee->setEmployeeId($row['employeeId']); $employee->setFirstName($row['firstName']); $employee->setMiddleName($row['middleName']); $employee->setLastName($row['lastName']); $employee->setTerminationId($row['terminationId']); $jobTitle = new JobTitle(); $jobTitle->setId($row['jobTitleId']); $jobTitle->setJobTitleName($row['jobTitle']); $jobTitle->setIsDeleted($row['isDeleted']); $employee->setJobTitle($jobTitle); $employeeStatus = new EmploymentStatus(); $employeeStatus->setId($row['employeeStatusId']); $employeeStatus->setName($row['employeeStatus']); $employee->setEmployeeStatus($employeeStatus); $workStation = new SubUnit(); $workStation->setName($row['subDivision']); $workStation->setId($row['subDivisionId']); $employee->setSubDivision($workStation); $supervisorList = isset($row['supervisors']) ? $row['supervisors'] : ''; if (!empty($supervisorList)) { $supervisors = new Doctrine_Collection(Doctrine::getTable('Employee')); $supervisorArray = explode(',', $supervisorList); foreach ($supervisorArray as $supervisor) { list($first, $middle, $last) = explode('##', $supervisor); $supervisor = new Employee(); $supervisor->setFirstName($first); $supervisor->setMiddleName($middle); $supervisor->setLastName($last); $employee->supervisors[] = $supervisor; } } $locationList = $row['locationIds']; if (!empty($locationList)) { // $locations = new Doctrine_Collection(Doctrine::getTable('EmpLocations')); $locationArray = explode(',', $locationList); foreach ($locationArray as $location) { list($id, $name) = explode('##', $location); $empLocation = new Location(); $empLocation->setId($id); $empLocation->setName($name); $employee->locations[] = $empLocation; } } $employees[] = $employee; } } } else { return $statement->fetchAll(); } return $employees; }
public function testGetAccessibleLocationIds() { $mockService = $this->getMock('LocationService'); $locationList = new Doctrine_Collection('Location'); for ($i = 0; $i < 3; $i++) { $location = new Location(); $location->setId($i + 1); $location->setName("test name" . $i + 1); $locationList->add($location); } $mockService->expects($this->once())->method('getLocationList')->will($this->returnValue($locationList)); $this->adminUserRole->setLocationService($mockService); $locationIds = $this->adminUserRole->getAccessibleLocationIds(null, null); $this->assertEquals($locationIds, array(1, 2, 3)); }
<?php include dirname(__FILE__) . '/../bootstrap/dbunit.php'; $t = new lime_test(4, new lime_output_color()); $extractor = new afColumnExtractor('Server', array('name', 'alert_interval', 'updated_at', 'location_id', 'server_type_id', 'is_enabled', 'osversion', 'html_is_enabled')); $location = new Location(); $location->setName('myLocation'); $server = new Server(); $server->setName('localhost'); $server->setOsversion('my <version>'); $server->setAlertInterval(300); $date = '2010-02-14 03:25:45'; $server->setUpdatedAt($date); $server->setLocation($location); $server->setIsEnabled(true); $objects = array($server); $rows = $extractor->extractColumns($objects); $row = $rows[0]; $t->like($row['is_enabled'], '@^<img src=\'/images/famfamfam/accept.png\' .*@'); $t->is($row['html_is_enabled'], $row['is_enabled']); unset($row['is_enabled']); unset($row['html_is_enabled']); $expected = array('name' => 'localhost', 'alert_interval' => 300, 'updated_at' => $date, 'location_id' => 'myLocation', 'server_type_id' => null, 'osversion' => 'my <version>'); $t->is($row, $expected); $t->is(json_encode($row), json_encode($expected));