Skip to content

Instantly share code, notes, and snippets.

@mdpatrick
Created August 18, 2011 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdpatrick/1155276 to your computer and use it in GitHub Desktop.
Save mdpatrick/1155276 to your computer and use it in GitHub Desktop.
Business.php entity with VichGeographicalBundle Annotations
<?php
namespace CityTorch\PublicBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Vich\GeographicalBundle\Annotation as Vich;
/**
* CityTorch\PublicBundle\Entity\Business
*
* @ORM\Table()
* @ORM\Entity
* @Vich\Geographical(on="update")
*/
class Business
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #ORM\ManyToOne(targetEntity="Neighborhood", inversedBy="businesses")
*/
// Implement this later
//private $neighborhood;
/**
* @ORM\ManyToOne(targetEntity="BusinessCategory", inversedBy="businesses")
*/
private $businesscategory;
/**
* #ORM\Column(name="picture", type="string", length=255)
* Add this feature in soon.
*/
//private $picture;
/**
* @var text $hoursopen
*
* @ORM\Column(name="hoursopen", type="text", nullable=true)
*/
private $hoursopen;
/**
* @var string $phone
*
* @ORM\Column(name="phone", type="string", length=30, nullable=true)
*/
private $phone;
/**
* @var string $streetaddress
*
* @ORM\Column(name="streetaddress", type="string", length=255, nullable=true)
*/
private $streetaddress;
/**
* @var integer $zipcode
*
* @ORM\Column(name="zipcode", type="integer", nullable=true)
*/
private $zipcode;
/**
* @ORM\Column(type="decimal", scale="7")
*/
protected $latitude;
/**
* @ORM\Column(type="decimal", scale="7")
*/
protected $longitude;
/**
* @var string $email
*
* @ORM\Column(name="email", type="string", length=70, nullable=true)
*/
private $email;
/**
* @var string $website
*
* @ORM\Column(name="website", type="string", length=255, nullable=true)
*/
private $website;
/**
* @var string $twitterurl
*
* @ORM\Column(name="twitterurl", type="string", length=255, nullable=true)
*/
private $twitterurl;
/**
* @var string $facebookurl
*
* @ORM\Column(name="facebookurl", type="string", length=255, nullable=true)
*/
private $facebookurl;
/**
* @var string $youtubeurl
*
* @ORM\Column(name="youtubeurl", type="string", length=255, nullable=true)
*/
private $youtubeurl;
/**
* @var text $description
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set hoursopen
*
* @param text $hoursopen
*/
public function setHoursopen($hoursopen)
{
$this->hoursopen = $hoursopen;
}
/**
* Get hoursopen
*
* @return text
*/
public function getHoursopen()
{
return $this->hoursopen;
}
/**
* Set description
*
* @param text $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* @return text
*/
public function getDescription()
{
return $this->description;
}
/**
* Set businesscategory
*
* @param CityTorch\PublicBundle\Entity\BusinessCategory $businesscategory
*/
public function setBusinesscategory(\CityTorch\PublicBundle\Entity\BusinessCategory $businesscategory)
{
$this->businesscategory = $businesscategory;
}
/**
* Get businesscategory
*
* @return CityTorch\PublicBundle\Entity\BusinessCategory
*/
public function getBusinesscategory()
{
return $this->businesscategory;
}
/**
* Set streetaddress
*
* @param string $streetaddress
*/
public function setStreetaddress($streetaddress)
{
$this->streetaddress = $streetaddress;
}
/**
* Get streetaddress
*
* @return string
*/
public function getStreetaddress()
{
return $this->streetaddress;
}
/**
* Set zipcode
*
* @param integer $zipcode
*/
public function setZipcode($zipcode)
{
$this->zipcode = $zipcode;
}
/**
* Get zipcode
*
* @return integer
*/
public function getZipcode()
{
return $this->zipcode;
}
/**
* Set email
*
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set twitterurl
*
* @param string $twitterurl
*/
public function setTwitterurl($twitterurl)
{
$this->twitterurl = $twitterurl;
}
/**
* Get twitterurl
*
* @return string
*/
public function getTwitterurl()
{
return $this->twitterurl;
}
/**
* Set facebookurl
*
* @param string $facebookurl
*/
public function setFacebookurl($facebookurl)
{
$this->facebookurl = $facebookurl;
}
/**
* Get facebookurl
*
* @return string
*/
public function getFacebookurl()
{
return $this->facebookurl;
}
/**
* Set phone
*
* @param string $phone
*/
public function setPhone($phone)
{
$phone = str_replace(array('(', ')', '-', ' '), '', $phone);
$this->phone = $phone;
}
/**
* Get phone
*
* @return integer
*/
public function getPhone()
{
if ($this->phone === 0)
return false;
else
return $this->phone;
}
/**
* Set website
*
* @param string $website
*/
public function setWebsite($website)
{
$this->website = $website;
}
/**
* Get website
*
* @return string
*/
public function getWebsite()
{
return $this->website;
}
/**
* Set youtubeurl
*
* @param string $youtubeurl
*/
public function setYoutubeurl($youtubeurl)
{
$this->youtubeurl = $youtubeurl;
}
/**
* Get youtubeurl
*
* @return string
*/
public function getYoutubeurl()
{
return $this->youtubeurl;
}
/**
* Set latitude
* Note: Might be redundant. Consider removal.
* @param decimal $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* Get latitude
* Note: Might be redundant. Consider removal.
* @return decimal
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Set longitude
*
* @param decimal $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* Get longitude
*
* @return decimal
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @Vich\GeographicalQuery
*
* This method builds the full address to query for coordinates.
*/
public function getAddress()
{
return sprintf(
'%s, %s, %s %s',
$this->streetaddress,
'Memphis',
'TN',
//$this->city,
//$this->state,
$this->zipcode
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment