Project

General

Profile

Bug #95899 » File.php

Example model - Marvin Buchmann, 2022-12-21 08:45

 
<?php
declare(strict_types=1);

namespace CYBOB\KroneDownloads\Domain\Model;

use CYBOB\KroneDownloads\Serialization\SerializableEntityInterface;
use CYBOB\KroneDownloads\Serialization\SerializableEntityTrait;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

/**
* @package \CYBOB\KroneDownloads\Domain\Model
*/
class File extends \TYPO3\CMS\Extbase\Domain\Model\File implements SerializableEntityInterface
{
use SerializableEntityTrait;

/**
* @var string
*/
protected string $languageIso = '';

/**
* @var ObjectStorage<FileType>
* @Extbase\ORM\Lazy
*/
protected ObjectStorage $types;

/**
* @var ObjectStorage<OtherSubcategory>
* @Extbase\ORM\Lazy
*/
protected ObjectStorage $subcategories;

/**
* @var ObjectStorage<Product>
* @Extbase\ORM\Lazy
*/
protected ObjectStorage $products;

/**
* @param string $languageIso
*/
public function __construct(string $languageIso)
{
$this->languageIso = $languageIso;
$this->types = new ObjectStorage();
$this->subcategories = new ObjectStorage();
$this->products = new ObjectStorage();
}

/**
* @return void
*/
public function initializeObject(): void
{
$this->types = $this->types ?? new ObjectStorage();
$this->subcategories = $this->subcategories ?? new ObjectStorage();
$this->products = $this->products ?? new ObjectStorage();
}

/**
* @return string
*/
public function getLanguageIso(): string
{
return $this->languageIso;
}

/**
* @param string $languageIso
*/
public function setLanguageIso(string $languageIso): void
{
$this->languageIso = $languageIso;
}

/**
* @return ObjectStorage
*/
public function getTypes(): ObjectStorage
{
return $this->types;
}

/**
* @param ObjectStorage $types
*/
public function setTypes(ObjectStorage $types): void
{
$this->types = $types;
}

/**
* @param FileType $type
*
* @return void
*/
public function addType(FileType $type): void
{
$this->types->attach($type);
}

/**
* @param FileType $type
*
* @return void
*/
public function removeType(FileType $type): void
{
$this->types->detach($type);
}

/**
* @return ObjectStorage
*/
public function getSubcategories(): ObjectStorage
{
return $this->subcategories;
}

/**
* @param ObjectStorage $subcategories
*/
public function setSubcategories(ObjectStorage $subcategories): void
{
$this->subcategories = $subcategories;
}

/**
* @param OtherSubcategory $subcategory
*
* @return void
*/
public function addSubcategory(OtherSubcategory $subcategory): void
{
$this->subcategories->attach($subcategory);
}

/**
* @param OtherSubcategory $subcategory
*
* @return void
*/
public function removeSubcategory(OtherSubcategory $subcategory): void
{
$this->subcategories->detach($subcategory);
}

/**
* @return ObjectStorage
*/
public function getProducts(): ObjectStorage
{
return $this->products;
}

/**
* @param ObjectStorage $products
*/
public function setProducts(ObjectStorage $products): void
{
$this->products = $products;
}

/**
* @param Product $product
*
* @return void
*/
public function addProduct(Product $product): void
{
$this->products->attach($product);
}

/**
* @param Product $product
*
* @return void
*/
public function removeProduct(Product $product): void
{
$this->products->detach($product);
}
}
(2-2/4)