Created
May 28, 2018 07:51
-
-
Save covex-nn/2e9a5f872eb008b7bb4bae52eb11a882 to your computer and use it in GitHub Desktop.
MongoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment