Answer the question
In order to leave comments, you need to log in
What are the practical benefits of such an approach?
While studying the framework, the question arose:
What is the use and what is the practical application of this approach, namely, why create interfaces for entities.
For example
<?php
namespace Acme\BlogBundle\Model;
Interface PageInterface
{
/**
* Set title
*
* @param string $title
* @return PageInterface
*/
public function setTitle($title);
/**
* Get title
*
* @return string
*/
public function getTitle();
/**
* Set body
*
* @param string $body
* @return PageInterface
*/
public function setBody($body);
/**
* Get body
*
* @return string
*/
public function getBody();
}
<?php
namespace Acme\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Acme\BlogBundle\Model\PageInterface;
/**
* Page
*
* @ORM\Table()
* @ORM\Entity()
*/
class Page implements PageInterface
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
* @ORM\Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="body", type="text")
*/
private $body;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
* @return Page
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set body
*
* @param string $body
* @return Page
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body
*
* @return string
*/
public function getBody()
{
return $this->body;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question