WIP: Symfony 6 project remake #2

Draft
skobkin wants to merge 103 commits from symfony6_remake into master
4 changed files with 70 additions and 58 deletions
Showing only changes of commit fa9a84f2a7 - Show all commits

View file

@ -1,44 +0,0 @@
<?php
namespace src\PointToolsBundle\Entity\Blogs;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="files", schema="posts")
* @ORM\Entity(repositoryClass="Skobkin\Bundle\PointToolsBundle\Repository\Blogs\FileRepository", readOnly=true)
*/
class File
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="remote_url", type="text", unique=true)
*/
private $remoteUrl;
public function __construct($remoteUrl)
{
$this->remoteUrl = $remoteUrl;
}
public function getId(): int
{
return $this->id;
}
public function getRemoteUrl(): string
{
return $this->remoteUrl;
}
}

View file

@ -1,14 +0,0 @@
<?php
namespace src\PointToolsBundle\Repository\Blogs;
use Doctrine\ORM\EntityRepository;
use src\PointToolsBundle\Entity\Blogs\File;
class FileRepository extends EntityRepository
{
public function add(File $entity): void
{
$this->getEntityManager()->persist($entity);
}
}

37
src/Entity/Blog/File.php Normal file
View file

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Entity\Blog;
use App\Entity\Blog\Post;
use App\Repository\Blog\FileRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FileRepository::class)]
#[ORM\Table(name: 'files', schema: 'posts')]
class File
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
#[ORM\Column(name: 'id', type: 'integer')]
private ?int $id;
#[ORM\Column(name: 'remote_url', type: 'text', unique: true)]
private string $remoteUrl;
public function __construct($remoteUrl)
{
$this->remoteUrl = $remoteUrl;
}
public function getId(): int
{
return $this->id;
}
public function getRemoteUrl(): string
{
return $this->remoteUrl;
}
}

View file

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Repository\Blog;
use App\Entity\Blog\File;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<File>
*
* @method File|null find($id, $lockMode = null, $lockVersion = null)
* @method File|null findOneBy(array $criteria, array $orderBy = null)
* @method File[] findAll()
* @method File[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class FileRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, File::class);
}
public function save(File $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
}