vendor/shopware/core/Content/Media/MediaEntity.php line 29

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Media;
  3. use Shopware\Core\Checkout\Document\Aggregate\DocumentBaseConfig\DocumentBaseConfigCollection;
  4. use Shopware\Core\Checkout\Document\DocumentCollection;
  5. use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemCollection;
  6. use Shopware\Core\Checkout\Payment\PaymentMethodCollection;
  7. use Shopware\Core\Checkout\Shipping\ShippingMethodCollection;
  8. use Shopware\Core\Content\Category\CategoryCollection;
  9. use Shopware\Core\Content\Cms\Aggregate\CmsBlock\CmsBlockCollection;
  10. use Shopware\Core\Content\Cms\Aggregate\CmsSection\CmsSectionCollection;
  11. use Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateMedia\MailTemplateMediaCollection;
  12. use Shopware\Core\Content\Media\Aggregate\MediaFolder\MediaFolderEntity;
  13. use Shopware\Core\Content\Media\Aggregate\MediaThumbnail\MediaThumbnailCollection;
  14. use Shopware\Core\Content\Media\Aggregate\MediaTranslation\MediaTranslationCollection;
  15. use Shopware\Core\Content\Media\MediaType\MediaType;
  16. use Shopware\Core\Content\Product\Aggregate\ProductConfiguratorSetting\ProductConfiguratorSettingCollection;
  17. use Shopware\Core\Content\Product\Aggregate\ProductManufacturer\ProductManufacturerCollection;
  18. use Shopware\Core\Content\Product\Aggregate\ProductMedia\ProductMediaCollection;
  19. use Shopware\Core\Content\Property\Aggregate\PropertyGroupOption\PropertyGroupOptionCollection;
  20. use Shopware\Core\Framework\App\Aggregate\AppPaymentMethod\AppPaymentMethodCollection;
  21. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  22. use Shopware\Core\Framework\DataAbstractionLayer\EntityCustomFieldsTrait;
  23. use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
  24. use Shopware\Core\System\Tag\TagCollection;
  25. use Shopware\Core\System\User\UserEntity;
  26. class MediaEntity extends Entity
  27. {
  28.     use EntityIdTrait;
  29.     use EntityCustomFieldsTrait;
  30.     /**
  31.      * @var string|null
  32.      */
  33.     protected $userId;
  34.     /**
  35.      * @var string|null
  36.      */
  37.     protected $mimeType;
  38.     /**
  39.      * @var string|null
  40.      */
  41.     protected $fileExtension;
  42.     /**
  43.      * @var int|null
  44.      */
  45.     protected $fileSize;
  46.     /**
  47.      * @var string|null
  48.      */
  49.     protected $title;
  50.     /**
  51.      * @var string|null
  52.      */
  53.     protected $metaDataRaw;
  54.     /**
  55.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  56.      *
  57.      * @var string|null
  58.      */
  59.     protected $mediaTypeRaw;
  60.     /**
  61.      * @var array|null
  62.      */
  63.     protected $metaData;
  64.     /**
  65.      * @var MediaType|null
  66.      */
  67.     protected $mediaType;
  68.     /**
  69.      * @var \DateTimeInterface|null
  70.      */
  71.     protected $uploadedAt;
  72.     /**
  73.      * @var string|null
  74.      */
  75.     protected $alt;
  76.     /**
  77.      * @var string
  78.      */
  79.     protected $url '';
  80.     /**
  81.      * @var string|null
  82.      */
  83.     protected $fileName;
  84.     /**
  85.      * @var UserEntity|null
  86.      */
  87.     protected $user;
  88.     /**
  89.      * @var MediaTranslationCollection|null
  90.      */
  91.     protected $translations;
  92.     /**
  93.      * @var CategoryCollection|null
  94.      */
  95.     protected $categories;
  96.     /**
  97.      * @var ProductManufacturerCollection|null
  98.      */
  99.     protected $productManufacturers;
  100.     /**
  101.      * @var ProductMediaCollection|null
  102.      */
  103.     protected $productMedia;
  104.     /**
  105.      * @var UserEntity|null
  106.      */
  107.     protected $avatarUser;
  108.     /**
  109.      * @var MediaThumbnailCollection|null
  110.      */
  111.     protected $thumbnails;
  112.     /**
  113.      * @var string|null
  114.      */
  115.     protected $mediaFolderId;
  116.     /**
  117.      * @var MediaFolderEntity|null
  118.      */
  119.     protected $mediaFolder;
  120.     /**
  121.      * @var bool
  122.      */
  123.     protected $hasFile false;
  124.     /**
  125.      * @var bool
  126.      */
  127.     protected $private false;
  128.     /**
  129.      * @var PropertyGroupOptionCollection|null
  130.      */
  131.     protected $propertyGroupOptions;
  132.     /**
  133.      * @var MailTemplateMediaCollection|null
  134.      */
  135.     protected $mailTemplateMedia;
  136.     /**
  137.      * @var TagCollection|null
  138.      */
  139.     protected $tags;
  140.     /**
  141.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  142.      *
  143.      * @var string|null
  144.      */
  145.     protected $thumbnailsRo;
  146.     /**
  147.      * @var DocumentBaseConfigCollection|null
  148.      */
  149.     protected $documentBaseConfigs;
  150.     /**
  151.      * @var ShippingMethodCollection|null
  152.      */
  153.     protected $shippingMethods;
  154.     /**
  155.      * @var PaymentMethodCollection|null
  156.      */
  157.     protected $paymentMethods;
  158.     /**
  159.      * @var ProductConfiguratorSettingCollection|null
  160.      */
  161.     protected $productConfiguratorSettings;
  162.     /**
  163.      * @var OrderLineItemCollection|null
  164.      */
  165.     protected $orderLineItems;
  166.     /**
  167.      * @var CmsBlockCollection|null
  168.      */
  169.     protected $cmsBlocks;
  170.     /**
  171.      * @var CmsSectionCollection|null
  172.      */
  173.     protected $cmsSections;
  174.     /**
  175.      * @var CmsBlockCollection|null
  176.      */
  177.     protected $cmsPages;
  178.     /**
  179.      * @var DocumentCollection|null
  180.      */
  181.     protected $documents;
  182.     /**
  183.      * @var AppPaymentMethodCollection|null
  184.      */
  185.     protected $appPaymentMethods;
  186.     public function get(string $property)
  187.     {
  188.         if ($property === 'hasFile') {
  189.             return $this->hasFile();
  190.         }
  191.         return parent::get($property);
  192.     }
  193.     public function getUserId(): ?string
  194.     {
  195.         return $this->userId;
  196.     }
  197.     public function setUserId(string $userId): void
  198.     {
  199.         $this->userId $userId;
  200.     }
  201.     public function getMimeType(): ?string
  202.     {
  203.         return $this->mimeType;
  204.     }
  205.     public function setMimeType(string $mimeType): void
  206.     {
  207.         $this->mimeType $mimeType;
  208.     }
  209.     public function getFileExtension(): ?string
  210.     {
  211.         return $this->fileExtension;
  212.     }
  213.     public function setFileExtension(string $fileExtension): void
  214.     {
  215.         $this->fileExtension $fileExtension;
  216.     }
  217.     public function getFileSize(): ?int
  218.     {
  219.         return $this->fileSize;
  220.     }
  221.     public function setFileSize(int $fileSize): void
  222.     {
  223.         $this->fileSize $fileSize;
  224.     }
  225.     public function getTitle(): ?string
  226.     {
  227.         return $this->title;
  228.     }
  229.     public function setTitle(string $title): void
  230.     {
  231.         $this->title $title;
  232.     }
  233.     public function getMetaData(): ?array
  234.     {
  235.         return $this->metaData;
  236.     }
  237.     public function setMetaData(array $metaData): void
  238.     {
  239.         $this->metaData $metaData;
  240.     }
  241.     public function getMediaType(): ?MediaType
  242.     {
  243.         return $this->mediaType;
  244.     }
  245.     public function setMediaType(MediaType $mediaType): void
  246.     {
  247.         $this->mediaType $mediaType;
  248.     }
  249.     public function getUploadedAt(): ?\DateTimeInterface
  250.     {
  251.         return $this->uploadedAt;
  252.     }
  253.     public function setUploadedAt(\DateTimeInterface $uploadedAt): void
  254.     {
  255.         $this->uploadedAt $uploadedAt;
  256.     }
  257.     public function getAlt(): ?string
  258.     {
  259.         return $this->alt;
  260.     }
  261.     public function setAlt(string $alt): void
  262.     {
  263.         $this->alt $alt;
  264.     }
  265.     public function getUser(): ?UserEntity
  266.     {
  267.         return $this->user;
  268.     }
  269.     public function setUser(UserEntity $user): void
  270.     {
  271.         $this->user $user;
  272.     }
  273.     public function getTranslations(): ?MediaTranslationCollection
  274.     {
  275.         return $this->translations;
  276.     }
  277.     public function setTranslations(MediaTranslationCollection $translations): void
  278.     {
  279.         $this->translations $translations;
  280.     }
  281.     public function getCategories(): ?CategoryCollection
  282.     {
  283.         return $this->categories;
  284.     }
  285.     public function setCategories(CategoryCollection $categories): void
  286.     {
  287.         $this->categories $categories;
  288.     }
  289.     public function getProductManufacturers(): ?ProductManufacturerCollection
  290.     {
  291.         return $this->productManufacturers;
  292.     }
  293.     public function setProductManufacturers(ProductManufacturerCollection $productManufacturers): void
  294.     {
  295.         $this->productManufacturers $productManufacturers;
  296.     }
  297.     public function getProductMedia(): ?ProductMediaCollection
  298.     {
  299.         return $this->productMedia;
  300.     }
  301.     public function setProductMedia(ProductMediaCollection $productMedia): void
  302.     {
  303.         $this->productMedia $productMedia;
  304.     }
  305.     public function getAvatarUser(): ?UserEntity
  306.     {
  307.         return $this->avatarUser;
  308.     }
  309.     public function setAvatarUser(UserEntity $avatarUser): void
  310.     {
  311.         $this->avatarUser $avatarUser;
  312.     }
  313.     public function getThumbnails(): ?MediaThumbnailCollection
  314.     {
  315.         return $this->thumbnails;
  316.     }
  317.     public function setThumbnails(MediaThumbnailCollection $thumbnailCollection): void
  318.     {
  319.         $this->thumbnails $thumbnailCollection;
  320.     }
  321.     public function getUrl(): string
  322.     {
  323.         return $this->url;
  324.     }
  325.     public function setUrl(string $url): void
  326.     {
  327.         $this->url $url;
  328.     }
  329.     public function hasFile(): bool
  330.     {
  331.         $hasFile $this->mimeType !== null && $this->fileExtension !== null && $this->fileName !== null;
  332.         return $this->hasFile $hasFile;
  333.     }
  334.     public function getFileName(): ?string
  335.     {
  336.         return $this->fileName;
  337.     }
  338.     public function setFileName(string $fileName): void
  339.     {
  340.         $this->fileName $fileName;
  341.     }
  342.     public function getMediaFolderId(): ?string
  343.     {
  344.         return $this->mediaFolderId;
  345.     }
  346.     public function setMediaFolderId(string $mediaFolderId): void
  347.     {
  348.         $this->mediaFolderId $mediaFolderId;
  349.     }
  350.     public function getMediaFolder(): ?MediaFolderEntity
  351.     {
  352.         return $this->mediaFolder;
  353.     }
  354.     public function setMediaFolder(MediaFolderEntity $mediaFolder): void
  355.     {
  356.         $this->mediaFolder $mediaFolder;
  357.     }
  358.     public function getPropertyGroupOptions(): ?PropertyGroupOptionCollection
  359.     {
  360.         return $this->propertyGroupOptions;
  361.     }
  362.     public function setPropertyGroupOptions(PropertyGroupOptionCollection $propertyGroupOptions): void
  363.     {
  364.         $this->propertyGroupOptions $propertyGroupOptions;
  365.     }
  366.     public function getMetaDataRaw(): ?string
  367.     {
  368.         return $this->metaDataRaw;
  369.     }
  370.     public function setMetaDataRaw(string $metaDataRaw): void
  371.     {
  372.         $this->metaDataRaw $metaDataRaw;
  373.     }
  374.     /**
  375.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  376.      */
  377.     public function getMediaTypeRaw(): ?string
  378.     {
  379.         $this->checkIfPropertyAccessIsAllowed('mediaTypeRaw');
  380.         return $this->mediaTypeRaw;
  381.     }
  382.     /**
  383.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  384.      */
  385.     public function setMediaTypeRaw(string $mediaTypeRaw): void
  386.     {
  387.         $this->mediaTypeRaw $mediaTypeRaw;
  388.     }
  389.     public function getMailTemplateMedia(): ?MailTemplateMediaCollection
  390.     {
  391.         return $this->mailTemplateMedia;
  392.     }
  393.     public function setMailTemplateMedia(MailTemplateMediaCollection $mailTemplateMedia): void
  394.     {
  395.         $this->mailTemplateMedia $mailTemplateMedia;
  396.     }
  397.     public function getTags(): ?TagCollection
  398.     {
  399.         return $this->tags;
  400.     }
  401.     public function setTags(TagCollection $tags): void
  402.     {
  403.         $this->tags $tags;
  404.     }
  405.     /**
  406.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  407.      */
  408.     public function getThumbnailsRo(): ?string
  409.     {
  410.         $this->checkIfPropertyAccessIsAllowed('thumbnailsRo');
  411.         return $this->thumbnailsRo;
  412.     }
  413.     /**
  414.      * @deprecated tag:v6.5.0 - Will be internal from 6.5.0 onward
  415.      */
  416.     public function setThumbnailsRo(string $thumbnailsRo): void
  417.     {
  418.         $this->thumbnailsRo $thumbnailsRo;
  419.     }
  420.     public function getDocumentBaseConfigs(): ?DocumentBaseConfigCollection
  421.     {
  422.         return $this->documentBaseConfigs;
  423.     }
  424.     public function setDocumentBaseConfigs(DocumentBaseConfigCollection $documentBaseConfigs): void
  425.     {
  426.         $this->documentBaseConfigs $documentBaseConfigs;
  427.     }
  428.     public function getShippingMethods(): ?ShippingMethodCollection
  429.     {
  430.         return $this->shippingMethods;
  431.     }
  432.     public function setShippingMethods(ShippingMethodCollection $shippingMethods): void
  433.     {
  434.         $this->shippingMethods $shippingMethods;
  435.     }
  436.     public function getPaymentMethods(): ?PaymentMethodCollection
  437.     {
  438.         return $this->paymentMethods;
  439.     }
  440.     public function setPaymentMethods(PaymentMethodCollection $paymentMethods): void
  441.     {
  442.         $this->paymentMethods $paymentMethods;
  443.     }
  444.     public function jsonSerialize(): array
  445.     {
  446.         $data parent::jsonSerialize();
  447.         unset($data['metaDataRaw'], $data['mediaTypeRaw']);
  448.         return $data;
  449.     }
  450.     public function getProductConfiguratorSettings(): ?ProductConfiguratorSettingCollection
  451.     {
  452.         return $this->productConfiguratorSettings;
  453.     }
  454.     public function setProductConfiguratorSettings(ProductConfiguratorSettingCollection $productConfiguratorSettings): void
  455.     {
  456.         $this->productConfiguratorSettings $productConfiguratorSettings;
  457.     }
  458.     public function getOrderLineItems(): ?OrderLineItemCollection
  459.     {
  460.         return $this->orderLineItems;
  461.     }
  462.     public function setOrderLineItems(OrderLineItemCollection $orderLineItems): void
  463.     {
  464.         $this->orderLineItems $orderLineItems;
  465.     }
  466.     public function getCmsBlocks(): ?CmsBlockCollection
  467.     {
  468.         return $this->cmsBlocks;
  469.     }
  470.     public function setCmsBlocks(CmsBlockCollection $cmsBlocks): void
  471.     {
  472.         $this->cmsBlocks $cmsBlocks;
  473.     }
  474.     public function getCmsSections(): ?CmsSectionCollection
  475.     {
  476.         return $this->cmsSections;
  477.     }
  478.     public function setCmsSections(CmsSectionCollection $cmsSections): void
  479.     {
  480.         $this->cmsSections $cmsSections;
  481.     }
  482.     public function getCmsPages(): ?CmsBlockCollection
  483.     {
  484.         return $this->cmsPages;
  485.     }
  486.     public function setCmsPages(CmsBlockCollection $cmsPages): void
  487.     {
  488.         $this->cmsPages $cmsPages;
  489.     }
  490.     public function isPrivate(): bool
  491.     {
  492.         return $this->private;
  493.     }
  494.     public function setPrivate(bool $private): void
  495.     {
  496.         $this->private $private;
  497.     }
  498.     public function getDocuments(): ?DocumentCollection
  499.     {
  500.         return $this->documents;
  501.     }
  502.     public function setDocuments(DocumentCollection $documents): void
  503.     {
  504.         $this->documents $documents;
  505.     }
  506.     public function getAppPaymentMethods(): ?AppPaymentMethodCollection
  507.     {
  508.         return $this->appPaymentMethods;
  509.     }
  510.     public function setAppPaymentMethods(AppPaymentMethodCollection $appPaymentMethods): void
  511.     {
  512.         $this->appPaymentMethods $appPaymentMethods;
  513.     }
  514. }