<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\EditablePageRepository")
 */
class EditablePage {
	/**
	 * @ORM\Id
	 * @ORM\GeneratedValue
	 * @ORM\Column(type="integer")
	 */
	protected $id;

	public function setId($id) {
		$this->id = $id;
	}

	public function getId() {
		return $this->id;
	}

	/**
	 * @ORM\Column(type="string", length=255)
	 */
	protected $name;

	public function setName($name) {
		$this->name = $name;
	}

	public function getName() {
		return $this->name;
	}

	public function getSlug() {
		$rule = 'NFD; [:Nonspacing Mark:] Remove; NFC';
		$transliterator = \Transliterator::create($rule);
		$string = $transliterator->transliterate($this->name);

		return preg_replace(
			'/[^a-z0-9]/',
			'-',
			strtolower(trim(strip_tags($string)))
		);
	}

	public function getUrl() {
		return '/' . $this->getSlug();
	}

	/**
	 * @ORM\Column(type="text")
	 */
	protected $content;

	public function setContent($content) {
		$this->content = $content;
	}

	public function getContent() {
		return $this->content;
	}
}