hey
parent
d84a7595fc
commit
ad4c4e49a2
@ -1,28 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repository\PadRepository")
|
||||
*/
|
||||
class Pad
|
||||
{
|
||||
protected $content;
|
||||
protected $id;
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private $create_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $is_clear = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $is_published = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $expires = true;
|
||||
|
||||
public function getContent()
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->create_date = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
public function setContent( string $content )
|
||||
|
||||
public function setContent(?string $content): self
|
||||
{
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function getId()
|
||||
|
||||
public function getCreateDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->id;
|
||||
return $this->create_date;
|
||||
}
|
||||
|
||||
public function setCreateDate(\DateTimeInterface $create_date): self
|
||||
{
|
||||
$this->create_date = $create_date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsClear(): ?bool
|
||||
{
|
||||
return $this->is_clear;
|
||||
}
|
||||
|
||||
public function setIsClear(bool $is_clear): self
|
||||
{
|
||||
$this->is_clear = $is_clear;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setId( string $id )
|
||||
|
||||
public function getIsPublished(): ?bool
|
||||
{
|
||||
return $this->is_published;
|
||||
}
|
||||
|
||||
public function setIsPublished(bool $is_published): self
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->is_published = $is_published;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
public function getExpires(): ?bool
|
||||
{
|
||||
return $this->expires;
|
||||
}
|
||||
|
||||
public function setExpires(bool $expires): self
|
||||
{
|
||||
$this->expires = $expires;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20191214175405 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE name (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE pad (id INT AUTO_INCREMENT NOT NULL, content LONGTEXT DEFAULT NULL, create_date DATETIME NOT NULL, is_clear TINYINT(1) NOT NULL, is_published TINYINT(1) NOT NULL, expires TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE name');
|
||||
$this->addSql('DROP TABLE pad');
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20191214194119 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('DROP TABLE name');
|
||||
$this->addSql('ALTER TABLE pad ADD name VARCHAR(255) NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('CREATE TABLE name (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
|
||||
$this->addSql('ALTER TABLE pad DROP name');
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Name;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Name|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Name|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Name[] findAll()
|
||||
* @method Name[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class NameRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Name::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Name[] Returns an array of Name objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->andWhere('n.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('n.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Name
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->andWhere('n.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Pad;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Pad|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Pad|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Pad[] findAll()
|
||||
* @method Pad[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PadRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Pad::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Pad[] Returns an array of Pad objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('p.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?Pad
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title> {{page_title|e('html')}}</title>
|
||||
{% block stylesheets %}
|
||||
<link href="{{ asset('/css/style.css') }}" type="text/css" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{head_title|e('html')}} </h1>
|
||||
<pre>
|
||||
{{ pad_content|e('html') }}
|
||||
</pre>
|
||||
<p><a href="/">Créer un nouveau Pad</a></p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue