1. Go to this page and download the library: Download ev/ev-copy-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ev / ev-copy-bundle example snippets
public function registerBundles()
{
return array(
// ...
new EV\CopyBundle\EVCopyBundle(),
// ...
);
}
namespace EV\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use EV\CopyBundle\Annotation as Copy;
class Article
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="title", type="string", length=255)
* @Copy\Variable(name="articleTitle")
*/
private $title;
/**
* @ORM\Column(name="content", type="text")
* @Copy\Simple
*/
private $content;
/**
* @ORM\Column(name="date", type="datetime")
*/
private $date;
/**
* @ORM\OneToOne(targetEntity="EV\BlogBundle\Entity\Options", cascade={"persist","remove"})
* @ORM\JoinColumn(name="optionsId", referencedColumnName="id")
* @Copy\Entity
*/
private $options;
/**
* @ORM\ManyToOne(targetEntity="EV\BlogBundle\Entity\Author", inversedBy="articles")
* @ORM\JoinColumn(name="authorId", referencedColumnName="id", nullable=false)
* @Copy\Simple
*/
private $author;
/**
* @ORM\OneToMany(targetEntity="EV\BlogBundle\Entity\Comment", mappedBy="article", cascade={"persist"})
* @Copy\Collection
*/
private $comments
/**
* @ORM\ManyToOne(targetEntity="EV\BlogBundle\Entity\Blog", inversedBy="articles")
* @ORM\JoinColumn(name="blogId", referencedColumnName="id", onDelete="cascade")
*/
protected $blog;
/**
* @Copy\Construct(variables={"blog"})
*/
public function __construct(Blog $blog)
{
$this->blog = $blog;
$this->date = new \DateTime('now');
}
// Getters, Setters and Adders methods...
public function addComment(\EV\BlogBundle\Entity\Comment $comment)
{
$this->comments[] = $comment;
// IMPORTANT : without this line, the copy won't work
$comment->setArticle($this);
return $this;
}
}
namespace EV\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use EV\CopyBundle\Annotation as Copy;
class Comment
{
/**
* @ORM\Column(name="pseudo", type="string", length=255)
* @Copy\Simple
*/
$pseudo;
/**
* @ORM\Column(name="content", type="text")
* @Copy\Simple
*/
$content;
/**
* @ORM\ManyToOne(targetEntity="EV\BlogBundle\Entity\Article", inversedBy="comments")
* @ORM\JoinColumn(name="articleId", referencedColumnName="id", nullable=false)
*/
protected $article;
// Getters, Setters and Adders methods...
}