Add support for metatags
This commit is contained in:
parent
ae440be40c
commit
4564aa9534
25 changed files with 230 additions and 22 deletions
|
|
@ -24,7 +24,7 @@ final class PhotosController extends AbstractController
|
|||
'title' => $photo->getTitle(),
|
||||
'date' => $photo->getDate(),
|
||||
'category' => $photo->getCategory()->getTitle(),
|
||||
'thumbnail' => 'photos/' . strtolower(str_replace(' ', '_', $photo->getTitle())) . '/' . $photo->getThumbnail(),
|
||||
'thumbnail' => 'files/uploads/photos/' . strtolower(str_replace(' ', '_', $photo->getTitle())) . '/' . $photo->getThumbnail(),
|
||||
'url' => $photo->getUrl(),
|
||||
];
|
||||
}
|
||||
|
|
@ -44,12 +44,15 @@ final class PhotosController extends AbstractController
|
|||
'title' => $photos->getTitle(),
|
||||
'category' => $photos->getCategory()->getTitle(),
|
||||
'urlSafeCategory' => $photos->getCategory()->getUrlSafeTitle(),
|
||||
'tags' => $photos->getTags(),
|
||||
'text' => $photos->getText(),
|
||||
'date' => $photos->getDate()
|
||||
'description' => $photos->getDescription(),
|
||||
'date' => $photos->getDate(),
|
||||
'thumbnail' => '/files/uploads/photos/' . strtolower(str_replace(' ', '_', $photos->getTitle())) . '/' . $photos->getThumbnail(),
|
||||
];
|
||||
|
||||
foreach ($uploads as $index => $upload) {
|
||||
$filePath = 'photos/' . strtolower(str_replace(' ', '_', $album['title'])) . '/' . $upload->getFile();
|
||||
$filePath = 'files/uploads/photos/' . strtolower(str_replace(' ', '_', $album['title'])) . '/' . $upload->getFile();
|
||||
|
||||
$album['uploads'][] = [
|
||||
'file' => $filePath,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Entity;
|
|||
use App\Repository\CategoryRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Order;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
|
||||
|
|
@ -22,12 +23,14 @@ class Category
|
|||
* @var Collection<int, Post>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Post::class, mappedBy: 'category')]
|
||||
#[ORM\OrderBy(['date' => 'DESC'])]
|
||||
private Collection $posts;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Photos>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Photos::class, mappedBy: 'category')]
|
||||
#[ORM\OrderBy(['date' => 'DESC'])]
|
||||
private Collection $photos;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class Page
|
|||
#[ORM\Column]
|
||||
private ?bool $published = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
|
@ -78,4 +81,16 @@ class Page
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class Photos
|
|||
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'photos')]
|
||||
private Collection $tags;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->uploads = new ArrayCollection();
|
||||
|
|
@ -182,4 +185,16 @@ class Photos
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ class Post
|
|||
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'posts')]
|
||||
private Collection $tags;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tags = new ArrayCollection();
|
||||
|
|
@ -145,4 +148,16 @@ class Post
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription(?string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,14 @@ class Tag
|
|||
* @var Collection<int, Post>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Post::class, mappedBy: 'tags')]
|
||||
#[ORM\OrderBy(['date' => 'DESC'])]
|
||||
private Collection $posts;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Photos>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Photos::class, mappedBy: 'tags')]
|
||||
#[ORM\OrderBy(['date' => 'DESC'])]
|
||||
private Collection $photos;
|
||||
|
||||
public function __construct()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class PhotoUploader {
|
|||
){}
|
||||
|
||||
public function upload(UploadedFile $file, string $galleryName) : string {
|
||||
$this->setTargetDirectory('photos/' . strtolower(str_replace(' ', '_', $galleryName)));
|
||||
$this->setTargetDirectory('files/uploads/photos/' . strtolower(str_replace(' ', '_', $galleryName)));
|
||||
$originalFilename = pathInfo($file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$safeFilename = $this->slugger->slug($originalFilename);
|
||||
$filename = $safeFilename . '.' . $file->guessExtension();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue