/** * * @return multitype:Country creates an array of all the data a country has. */ public static function getCountries() { $countries = array(); $country = new Country(); $country->setId(1); $country->setName('America'); $countries[$country->getId()] = $country; $country2 = new Country(); $country2->setId(2); $country2->setname('Germany'); $countries[$country2->getId()] = $country2; return $countries; }
public function testGetSetId() { $this->country->setId('GBR'); $this->assertEquals('GBR', $this->country->getId()); }
private function buildDataToInsert($year, $subgroupId, $fontId, $typeId, $varietyId, $originId, $destinyId) { $font = new Font(); $font->setId($fontId); $type = new CoffeType(); $type->setId($typeId); $variety = new Variety(); $variety->setId($varietyId); $origin = new Country(); $origin->setId($originId); $destiny = new Country(); $destiny->setId($destinyId); $subgroup = new Subgroup(); $subgroup->setId($subgroupId); return new Data($year, $subgroup, $font, $type, $variety, $origin, $destiny); }
<?php require_once '../core/generics/Param.php'; require_once '../core/generics/datacenter/Country.php'; require_once '../core/generics/Controller.php'; require_once '../core/generics/GenericDao.php'; $id_country = $_POST['id']; $country = new Country(); $country->setId($id_country); $json = new JsonResponse(); $dao = new GenericDao(Connection::connect()); $controller = new Controller($dao); try { if ($controller->deleteCountry($country)) { print_r($json->response(true, "País excluído com sucesso!")->serialize()); } else { print_r($json->response(false, "Falha ao excluir o país.")->serialize()); } } catch (Exception $err) { print_r($json->response(false, $err->getMessage())->serialize()); }
<?php require_once '../core/generics/Param.php'; require_once '../core/generics/datacenter/Country.php'; require_once '../core/generics/Controller.php'; require_once '../core/generics/GenericDao.php'; $json = new JsonResponse(); $dao = new GenericDao(Connection::connect()); $controller = new Controller($dao); $country_id = $_REQUEST['country']; $object = new Country($_POST['name']); $object->setId($country_id); if (isset($_POST['reexport']) && $_POST['reexport'] == true) { $object->setReexport(); } if ($controller->editCountry($object)) { print_r($json->response(true, "País editado com sucesso!")->serialize()); } else { print_r($json->response(false, "O país não foi editado!")->serialize()); }