mirror of
https://github.com/symfony/recipes-contrib.git
synced 2026-09-17 01:56:28 +03:00
Add sonata-project/media-odm-pack recipe
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
sonata_media:
|
||||
class:
|
||||
media: App\Document\SonataMediaMedia
|
||||
gallery: App\Document\SonataMediaGallery
|
||||
gallery_has_media: App\Document\SonataMediaGalleryHasMedia
|
||||
db_driver: doctrine_mongodb
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"copy-from-recipe": {
|
||||
"config/": "%CONFIG_DIR%/",
|
||||
"src/": "%SRC_DIR%/"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Document;
|
||||
|
||||
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use Sonata\MediaBundle\Document\BaseGallery;
|
||||
|
||||
/**
|
||||
* @MongoDB\Document
|
||||
* @MongoDB\HasLifecycleCallbacks
|
||||
*/
|
||||
class SonataMediaGallery extends BaseGallery
|
||||
{
|
||||
/**
|
||||
* @MongoDB\Id()
|
||||
* @Serializer\Groups(groups={"sonata_api_read", "sonata_api_write", "sonata_search"})
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @MongoDB\ReferenceMany(
|
||||
* targetDocument="App\Document\SonataMediaGalleryHasMedia",
|
||||
* mappedBy="gallery", cascade={"persist"}, orphanRemoval=false, sort={"position" = "ASC"}
|
||||
* )
|
||||
*/
|
||||
protected $galleryHasMedias;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PrePersist
|
||||
*/
|
||||
public function prePersist(): void
|
||||
{
|
||||
parent::prePersist();
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PreUpdate
|
||||
*/
|
||||
public function preUpdate(): void
|
||||
{
|
||||
parent::preUpdate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Document;
|
||||
|
||||
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use Sonata\MediaBundle\Document\BaseGalleryHasMedia;
|
||||
|
||||
/**
|
||||
* @MongoDB\Document
|
||||
* @MongoDB\HasLifecycleCallbacks
|
||||
*/
|
||||
class SonataMediaGalleryHasMedia extends BaseGalleryHasMedia
|
||||
{
|
||||
/**
|
||||
* @MongoDB\Id()
|
||||
* @Serializer\Groups(groups={"sonata_api_read", "sonata_api_write", "sonata_search"})
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @MongoDB\ReferenceOne(
|
||||
* targetDocument="App\Document\SonataMediaMedia",
|
||||
* inversedBy="galleryHasMedias", cascade={"persist"}
|
||||
* )
|
||||
*/
|
||||
protected $media;
|
||||
|
||||
/**
|
||||
* @MongoDB\ReferenceOne(
|
||||
* targetDocument="App\Document\SonataMediaGallery",
|
||||
* inversedBy="galleryHasMedias", cascade={"persist"}
|
||||
* )
|
||||
*/
|
||||
protected $gallery;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PrePersist
|
||||
*/
|
||||
public function prePersist(): void
|
||||
{
|
||||
parent::prePersist();
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PreUpdate
|
||||
*/
|
||||
public function preUpdate(): void
|
||||
{
|
||||
parent::preUpdate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Document;
|
||||
|
||||
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use Sonata\MediaBundle\Document\BaseMedia;
|
||||
|
||||
/**
|
||||
* @MongoDB\Document
|
||||
* @MongoDB\HasLifecycleCallbacks
|
||||
*/
|
||||
class SonataMediaMedia extends BaseMedia
|
||||
{
|
||||
/**
|
||||
* @MongoDB\Id()
|
||||
* @Serializer\Groups(groups={"sonata_api_read", "sonata_api_write", "sonata_search"})
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @MongoDB\ReferenceMany(
|
||||
* targetDocument="App\Document\SonataMediaGalleryHasMedia",
|
||||
* mappedBy="media", cascade={"persist"}, orphanRemoval=false, sort={"position" = "ASC"}
|
||||
* )
|
||||
*/
|
||||
protected $galleryHasMedias;
|
||||
|
||||
/**
|
||||
* @MongoDB\Field(type="string", nullable=true)
|
||||
*/
|
||||
protected $authorName;
|
||||
|
||||
/**
|
||||
* @MongoDB\Field(type="boolean", nullable=true)
|
||||
*/
|
||||
protected $cdnIsFlushable;
|
||||
|
||||
/**
|
||||
* @MongoDB\Field(type="string", nullable=true)
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @MongoDB\Field(type="string", nullable=true)
|
||||
*/
|
||||
protected $copyright;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PrePersist
|
||||
*/
|
||||
public function prePersist(): void
|
||||
{
|
||||
parent::prePersist();
|
||||
}
|
||||
|
||||
/**
|
||||
* @MongoDB\PreUpdate
|
||||
*/
|
||||
public function preUpdate(): void
|
||||
{
|
||||
parent::preUpdate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user