1. Go to this page and download the library: Download lexxpavlov/pagebundle 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/ */
lexxpavlov / pagebundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Lexxpavlov\PageBundle\LexxpavlovPageBundle(),
// ...
);
}
namespace App\YourBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Lexxpavlov\PageBundle\Entity\Page as BasePage;
/**
* @ORM\Entity()
*/
class Page extends BasePage
{
// Be free to add your fields here
}
$form = $this->createForm('lexxpavlov_page');
{# src/App/YourBundle/Controller/DefaultController.php #}
namespace App\YourBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use App\YourBundle\Entity\Page;
class DefaultController extends Controller
{
/**
* @Route("/page/{id}.html")
* @Template()
*/
public function pageAction(Page $page)
{
}
// or find by slug:
/**
* @Route("/page/{slug}")
* @Template("AppYourBundle:Default:page.html.twig")
*/
public function slugAction(Page $page)
{
}
// or find from repository
/**
* @Route("/page-find/{id}")
* @Template("AppYourBundle:Default:page.html.twig")
*/
public function findAction($id)
{
$repository = $this->getDoctrine()->getRepository('AppYourBundle:Page');
if (is_numeric($id)) {
$page = $repository->find($id);
} else {
$page = $repository->findOneBySlug($id);
}
return array('page' => $page);
}
}
namespace App\YourBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lexxpavlov\PageBundle\Entity\Page as BasePage;
use App\YourBundle\Entity\User;
/**
* @ORM\Entity()
*/
class Page extends BasePage
{
/**
* @var User
*
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="created_by", referencedColumnName="id")
*/
protected $createdBy;
/**
* @var User
*
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="updated_by", referencedColumnName="id")
*/
protected $updatedBy;
/**
* Set user, that updated entity
*
* @param User $updatedBy
* @return Page
*/
public function setUpdatedBy($updatedBy)
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* Get user, that updated entity
*
* @return User
*/
public function getUpdatedBy()
{
return $this->updatedBy;
}
/**
* Set user, that created entity
*
* @param User $createdBy
* @return Page
*/
public function setCreatedBy($createdBy)
{
$this->createdby = $createdBy;
return $this;
}
/**
* Get user, that created entity
*
* @return User
*/
public function getCreatedBy()
{
return $this->createdBy;
}
}