<?php
namespace Medienreaktor\Products\Domain\Model;

use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;


/***
 *
 * This file is part of the "Products" Extension for TYPO3 CMS.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 *  (c) 2017 Daniel Kestler &lt;daniel.kestler@medienreaktor&gt;, medienreaktor GmbH
 *
 ***/

/**
 * ProductGroup
 */
class ProductGroup extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{

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

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

    /**
     * weight_min
     *
     * @var double
     */
    protected $weightMin = '';

    /**
     * weight_max
     *
     * @var double
     */
    protected $weightMax = '';

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

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

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

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

    /**
     * showinsupport
     *
     * @var boolean
     */
    protected $showinsupport;

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


    /**
	 * video
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
	 */
	protected $video = NULL;

    /**
	 * video_mobile
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
	 */
	protected $video_mobile = NULL;

    /**
  * products
  *
  * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product>
  */
 #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
 protected $products = NULL;

    /**
     * propertygroups
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\PropertyGroup>
     */
    #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
    protected $propertygroups = NULL;

    /**
     * productclasses
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductClass>
     */
    #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
    protected $productclasses = NULL;

    /**
     * accessories
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup>
     */
    #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
    protected $accessories = NULL;

    /**
     * accessoryvariants
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product>
     */
    #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
    protected $accessoryvariants = NULL;

    /**
     * related
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup>
     */
    #[\TYPO3\CMS\Extbase\Annotation\ORM\Cascade(['value' => 'remove'])]
    protected $related = NULL;

    /**
	 * image
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
	 */
	protected $image = NULL;

    /**
	 * background
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
	 */
	protected $background = NULL;

    /**
	 * videos
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
	 */
	protected $videos = NULL;

    /**
     * documentation
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $documentation = NULL;

    /**
     * whitepaper
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $whitepaper = NULL;

    /**
     * flyer
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $flyer = NULL;

    /**
     * license
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $license = NULL;

    /**
     * software
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $software = NULL;

    /**
     * drivers
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $drivers = NULL;

    /**
     * planningaids
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $planningaids = NULL;

    /**
     * distributor
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
     */
    protected $distributor = NULL;

    /**
     * news
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\News>
     */
    protected $news = NULL;

    /**
     * faq
     *
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Faq>
     */
    protected $faq = NULL;

    /**
     * __construct
     */
    public function __construct() {
        //Do not remove the next line: It would break the functionality
        $this->initStorageObjects();
    }

    /**
     * Initializes all ObjectStorage properties
     * Do not modify this method!
     * It will be rewritten on each save in the extension builder
     * You may modify the constructor of this class instead
     *
     * @return void
     */
    protected function initStorageObjects() {
        $this->products = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->propertyGroups = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->productclasses = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->accessories = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->accessoryvariants = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->documentation = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->whitepaper = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->flyer = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->license = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->software = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->drivers = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->planningaids = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->distributor = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->news = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->faq = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->image = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->background = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->videos = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->video = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        $this->video_mobile = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
    }

    /**
     * Returns the name
     *
     * @return string $name
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Sets the name
     *
     * @param string $name
     * @return void
     */
    public function setName($name): void
    {
        $this->name = $name;
    }

    /**
     * Returns the subtitle
     *
     * @return string $subtitle
     */
    public function getSubtitle()
    {
        return $this->subtitle;
    }

    /**
     * Sets the subtitle
     *
     * @param string $subtitle
     * @return void
     */
    public function setSubtitle($subtitle): void
    {
        $this->subtitle = $subtitle;
    }

    /**
     * Returns the weight_min
     *
     * @return string $weightMin
     */
    public function getWeightMin()
    {
        return $this->weightMin / 1000;
    }

    /**
     * Sets the weight_min
     *
     * @param string $weightMin
     * @return void
     */
    public function setWeightMin($weightMin): void
    {
        $this->weightMin = $weightMin;
    }

    /**
     * Returns the weight_min
     *
     * @return string $weightMin
     */
    public function getWeightMax()
    {
        return $this->weightMax / 1000;
    }

    /**
     * Sets the weight_max
     *
     * @param string $weightMax
     * @return void
     */
    public function setWeightMax($weightMax): void
    {
        $this->weightMax = $weightMax;
    }

    /**
     * Returns the short
     *
     * @return string $short
     */
    public function getShort()
    {
        return $this->short;
    }

    /**
     * Sets the short
     *
     * @param string $short
     * @return void
     */
    public function setShort($short): void
    {
        $this->short = $short;
    }

    /**
     * Returns the description
     *
     * @return string $description
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Sets the description
     *
     * @param string $description
     * @return void
     */
    public function setDescription($description): void
    {
        $this->description = $description;
    }

    /**
     * Returns the features
     *
     * @return string $features
     */
    public function getFeatures()
    {
        return explode(LF, $this->features);
    }

    /**
     * Sets the features
     *
     * @param string $features
     * @return void
     */
    public function setFeatures($features): void
    {
        $this->features = $features;
    }

    /**
     * Returns the delivery
     *
     * @return string $delivery
     */
    public function getDelivery()
    {
        return $this->delivery;
    }

    /**
     * Sets the delivery
     *
     * @param string $delivery
     * @return void
     */
    public function setDelivery($delivery): void
    {
        $this->delivery = $delivery;
    }

    /**
     * Returns showinsupport
     *
     * @return boolean $showinsupport
     */
    public function getShowinsupport()
    {
        return $this->showinsupport;
    }

    /**
     * Sets showinsupport
     *
     * @param boolean $showinsupport
     * @return void
     */
    public function setShowinsupport($showinsupport): void
    {
        $this->showinsupport = $showinsupport;
    }

    /**
	 * Returns the products
	 *
	 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product> $products
	 */
	public function getProducts() {
		return $this->products;
	}

	/**
	 * Sets the products
	 *
	 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product> $products
	 * @return void
	 */
	public function setProducts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $products): void {
		$this->products = $products;
	}

    /**
     * Returns the propertyGroups
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\PropertyGroup> $propertygroups
     */
    public function getPropertyGroups() {
        return $this->propertygroups;
    }

    /**
     * Sets the propertyGroups
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\PropertyGroup> $propertygroups
     * @return void
     */
    public function setPropertyGroups(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $propertygroups): void {
        $this->propertygroups = $propertygroups;
    }

    /**
     * Returns the productClasses
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductClass> $productclasses
     */
    public function getProductClasses() {
        return $this->productclasses;
    }

    /**
     * Sets the productClasses
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductClass> $productclasses
     * @return void
     */
    public function setProductClasses(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $productclasses): void {
        $this->productclasses = $productclasses;
    }

    /**
     * Returns the accessories
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup> $accessories
     */
    public function getAccessories() {
        return $this->accessories;
    }

    /**
     * Sets the accessories
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup> $accessories
     * @return void
     */
    public function setAccessories(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $accessories): void {
        $this->accessories = $accessories;
    }

    /**
     * Returns the accessoryvariants
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product> $accessoryvariants
     */
    public function getAccessoryvariants() {
        return $this->accessoryvariants;
    }

    /**
     * Sets the accessoryvariants
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Product> $accessoryvariants
     * @return void
     */
    public function setAccessoryvariants(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $accessoryvariants): void {
        $this->accessoryvariants = $accessoryvariants;
    }

    /**
     * Returns the related products
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup> $related
     */
    public function getRelated() {
        return $this->related;
    }

    /**
     * Sets the related products
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\ProductGroup> $related
     * @return void
     */
    public function setRelated(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $related): void {
        $this->related = $related;
    }

    /**
     * Returns the image
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image
     */
    public function getImage() {
        return $this->image;
    }

    /**
     * Sets the image
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image
     * @return void
     */
    public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image): void {
        $this->image = $image;
    }

    /**
     * Returns the background
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $background
     */
    public function getBackground() {
        return $this->background;
    }

    /**
     * Sets the background
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $background
     * @return void
     */
    public function setBackground(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $background): void {
        $this->background = $background;
    }

    /**
     * Returns the videos
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $videos
     */
    public function getVideos() {
        return $this->videos;
    }

    /**
     * Sets the videos
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $videos
     * @return void
     */
    public function setVideos(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $videos): void {
        $this->videos = $videos;
    }

    /**
     * Returns the video
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $video
     */
    public function getVideo() {
        if($this->video->toArray()) {
            return $this->video->toArray()[0]->getOriginalResource()->getOriginalFile();
        }
        else {
            return $this->video;
        }
    }

    /**
     * Sets the video
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $video
     * @return void
     */
    public function setVideo(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $video): void {
        $this->video = $video;
    }

    /**
     * Returns the video_mobile
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $video_mobile
     */
    public function getVideoMobile() {
        return $this->video_mobile;
    }

    /**
     * Sets the video_mobile
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $video_mobile
     * @return void
     */
    public function setVideoMobile(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $video_mobile): void {
        $this->video_mobile = $video_mobile;
    }

    /**
     * Returns the documentation
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $documentation
     */
    public function getDocumentation() {
        return $this->documentation;
    }

    /**
     * Sets the documentation
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $documentation
     * @return void
     */
    public function setDocumentation(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $documentation): void {
        $this->documentation = $documentation;
    }

    /**
     * Returns the whitepaper
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $whitepaper
     */
    public function getWhitepaper() {
        return $this->whitepaper;
    }

    /**
     * Sets the whitepaper
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $whitepaper
     * @return void
     */
    public function setWhitepaper(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $whitepaper): void {
        $this->whitepaper = $whitepaper;
    }

    /**
     * Returns the flyer
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $flyer
     */
    public function getFlyer() {
        return $this->flyer;
    }

    /**
     * Sets the flyer
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $flyer
     * @return void
     */
    public function setFlyer(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $flyer): void {
        $this->flyer = $flyer;
    }

    /**
     * Returns the license
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $license
     */
    public function getLicense() {
        return $this->license;
    }

    /**
     * Sets the license
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $license
     * @return void
     */
    public function setLicense(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $license): void {
        $this->license = $license;
    }

    /**
     * Returns the software
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $software
     */
    public function getSoftware() {
        return $this->software;
    }

    /**
     * Sets the software
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $software
     * @return void
     */
    public function setSoftware(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $software): void {
        $this->software = $software;
    }

    /**
     * Returns the drivers
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $drivers
     */
    public function getDrivers() {
        return $this->drivers;
    }

    /**
     * Sets the drivers
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $drivers
     * @return void
     */
    public function setDrivers(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $drivers): void {
        $this->drivers = $drivers;
    }

    /**
     * Returns the planningaids
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $planningaids
     */
    public function getPlanningaids() {
        return $this->planningaids;
    }

    /**
     * Sets the planningaids
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $planningaids
     * @return void
     */
    public function setPlanningaids(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $planningaids): void {
        $this->planningaids = $planningaids;
    }

    /**
     * Returns the distributor
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $distributor
     */
    public function getDistributor() {
        return $this->distributor;
    }

    /**
     * Sets the distributor
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $distributor
     * @return void
     */
    public function setDistributor(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $distributor): void {
        $this->distributor = $distributor;
    }

    /**
     * Returns the news
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\News> $news
     */
    public function getNews()
    {
        return $this->news;
    }

    /**
     * Sets the news
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\News> $news
     * @return void
     */
    public function setNews($news): void
    {
        $this->news = $news;
    }

    /**
	 * Returns the faq
	 *
	 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Faq> $faq
	 */
	public function getFaq() {
		return $this->faq;
	}

	/**
	 * Sets the faq
	 *
	 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Medienreaktor\Products\Domain\Model\Faq> $faq
	 * @return void
	 */
	public function setFaq(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $faq): void {
		$this->faq = $faq;
	}

    public function getDynamicProperties() {
        $flexFormContent = $this->piFlexform;
        /** @var FlexFormService $flexFormService */
        $flexFormService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(FlexFormService::class);
        $fields = $flexFormService->convertFlexFormContentToArray($flexFormContent);

        return $fields;
    }
}
