Created
October 31, 2014 21:51
-
-
Save mockiemockiz/9f5e89ee2444be897403 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function indexAction() | |
{ | |
$repository = $this->em->getRepository('UserDetail\Entity\UserCountry'); | |
$adapter = new DoctrineAdapter( | |
new ORMPaginator( | |
$repository->createQueryBuilder('UserCountry') | |
->where('UserCountry.code=\'IDN\'') | |
->groupBy('UserCountry.code') | |
) | |
); | |
$paginator = new Paginator($adapter); | |
$paginator->setDefaultItemCountPerPage(5); | |
$page = (int) $this->params()->fromQuery('page'); | |
if ($page) { | |
$paginator->setCurrentPageNumber($page); | |
} | |
return ['paginator' => $paginator,'page' => $page]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace UserDetail\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* UserCity | |
* | |
* @ORM\Table(name="user_city", indexes={@ORM\Index(name="CountryCode", columns={"country_code"})}) | |
* @ORM\Entity | |
*/ | |
class UserCity | |
{ | |
/** | |
* @var integer | |
* | |
* @ORM\Column(name="ID", type="integer", nullable=false) | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="IDENTITY") | |
*/ | |
private $id; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="name", type="string", length=35, nullable=false) | |
*/ | |
private $name = ''; | |
/** | |
* @var string | |
* | |
* @ORM\ManyToOne(targetEntity="UserCountry", inversedBy="districts") | |
* @ORM\Column(name="country_code", type="string", length=3, nullable=false) | |
*/ | |
private $countryCode = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="district", type="string", length=20, nullable=false) | |
*/ | |
private $district = ''; | |
/** | |
* @var float | |
* | |
* @ORM\Column(name="latitude", type="float", precision=10, scale=0, nullable=false) | |
*/ | |
private $latitude; | |
/** | |
* @var float | |
* | |
* @ORM\Column(name="longitude", type="float", precision=10, scale=0, nullable=false) | |
*/ | |
private $longitude; | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set name | |
* | |
* @param string $name | |
* @return UserCity | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Get name | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Set countryCode | |
* | |
* @param string $countryCode | |
* @return UserCity | |
*/ | |
public function setCountryCode($countryCode) | |
{ | |
$this->countryCode = $countryCode; | |
return $this; | |
} | |
/** | |
* Get countryCode | |
* | |
* @return string | |
*/ | |
public function getCountryCode() | |
{ | |
return $this->countryCode; | |
} | |
/** | |
* Set district | |
* | |
* @param string $district | |
* @return UserCity | |
*/ | |
public function setDistrict($district) | |
{ | |
$this->district = $district; | |
return $this; | |
} | |
/** | |
* Get district | |
* | |
* @return string | |
*/ | |
public function getDistrict() | |
{ | |
return $this->district; | |
} | |
/** | |
* Set latitude | |
* | |
* @param float $latitude | |
* @return UserCity | |
*/ | |
public function setLatitude($latitude) | |
{ | |
$this->latitude = $latitude; | |
return $this; | |
} | |
/** | |
* Get latitude | |
* | |
* @return float | |
*/ | |
public function getLatitude() | |
{ | |
return $this->latitude; | |
} | |
/** | |
* Set longitude | |
* | |
* @param float $longitude | |
* @return UserCity | |
*/ | |
public function setLongitude($longitude) | |
{ | |
$this->longitude = $longitude; | |
return $this; | |
} | |
/** | |
* Get longitude | |
* | |
* @return float | |
*/ | |
public function getLongitude() | |
{ | |
return $this->longitude; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace UserDetail\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* UserCountry | |
* | |
* @ORM\Table(name="user_country") | |
* @ORM\Entity | |
*/ | |
class UserCountry | |
{ | |
/** | |
* @ORM\OneToMany(targetEntity="UserCity", mappedBy="countryCode") | |
**/ | |
private $districts; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="code", type="string", length=3, nullable=false) | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="IDENTITY") | |
*/ | |
private $code = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="name", type="string", length=52, nullable=false) | |
*/ | |
private $name = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="continent", type="string", length=50, nullable=false) | |
*/ | |
private $continent = 'Asia'; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="region", type="string", length=26, nullable=false) | |
*/ | |
private $region = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="local_name", type="string", length=45, nullable=false) | |
*/ | |
private $localName = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="code2", type="string", length=2, nullable=false) | |
*/ | |
private $code2 = ''; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="currency_code", type="string", length=3, nullable=false) | |
*/ | |
private $currencyCode; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="currency_name", type="string", length=80, nullable=false) | |
*/ | |
private $currencyName; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="currency_exchange_usd", type="decimal", precision=13, scale=4, nullable=false) | |
*/ | |
private $currencyExchangeUsd; | |
public function __construct() | |
{ | |
$this->districts = new ArrayCollection(); | |
} | |
/** | |
* Get districts | |
* | |
* @return Array | |
*/ | |
public function getDistricts() | |
{ | |
return $this->districts; | |
} | |
/** | |
* Get code | |
* | |
* @return string | |
*/ | |
public function getCode() | |
{ | |
return $this->code; | |
} | |
/** | |
* Set name | |
* | |
* @param string $name | |
* @return UserCountry | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Get name | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Set continent | |
* | |
* @param string $continent | |
* @return UserCountry | |
*/ | |
public function setContinent($continent) | |
{ | |
$this->continent = $continent; | |
return $this; | |
} | |
/** | |
* Get continent | |
* | |
* @return string | |
*/ | |
public function getContinent() | |
{ | |
return $this->continent; | |
} | |
/** | |
* Set region | |
* | |
* @param string $region | |
* @return UserCountry | |
*/ | |
public function setRegion($region) | |
{ | |
$this->region = $region; | |
return $this; | |
} | |
/** | |
* Get region | |
* | |
* @return string | |
*/ | |
public function getRegion() | |
{ | |
return $this->region; | |
} | |
/** | |
* Set localName | |
* | |
* @param string $localName | |
* @return UserCountry | |
*/ | |
public function setLocalName($localName) | |
{ | |
$this->localName = $localName; | |
return $this; | |
} | |
/** | |
* Get localName | |
* | |
* @return string | |
*/ | |
public function getLocalName() | |
{ | |
return $this->localName; | |
} | |
/** | |
* Set code2 | |
* | |
* @param string $code2 | |
* @return UserCountry | |
*/ | |
public function setCode2($code2) | |
{ | |
$this->code2 = $code2; | |
return $this; | |
} | |
/** | |
* Get code2 | |
* | |
* @return string | |
*/ | |
public function getCode2() | |
{ | |
return $this->code2; | |
} | |
/** | |
* Set currencyCode | |
* | |
* @param string $currencyCode | |
* @return UserCountry | |
*/ | |
public function setCurrencyCode($currencyCode) | |
{ | |
$this->currencyCode = $currencyCode; | |
return $this; | |
} | |
/** | |
* Get currencyCode | |
* | |
* @return string | |
*/ | |
public function getCurrencyCode() | |
{ | |
return $this->currencyCode; | |
} | |
/** | |
* Set currencyName | |
* | |
* @param string $currencyName | |
* @return UserCountry | |
*/ | |
public function setCurrencyName($currencyName) | |
{ | |
$this->currencyName = $currencyName; | |
return $this; | |
} | |
/** | |
* Get currencyName | |
* | |
* @return string | |
*/ | |
public function getCurrencyName() | |
{ | |
return $this->currencyName; | |
} | |
/** | |
* Set currencyExchangeUsd | |
* | |
* @param string $currencyExchangeUsd | |
* @return UserCountry | |
*/ | |
public function setCurrencyExchangeUsd($currencyExchangeUsd) | |
{ | |
$this->currencyExchangeUsd = $currencyExchangeUsd; | |
return $this; | |
} | |
/** | |
* Get currencyExchangeUsd | |
* | |
* @return string | |
*/ | |
public function getCurrencyExchangeUsd() | |
{ | |
return $this->currencyExchangeUsd; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment