Adds the ability to set properties on Scene objects.

This commit is contained in:
Vassyli
2021-01-13 19:57:21 +01:00
committed by Basilius Sauter
parent 512d875609
commit 96feb12fb5
2 changed files with 53 additions and 0 deletions
+10
View File
@@ -11,6 +11,7 @@ use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Tools\Model\Creator;
use LotGD\Core\Tools\Model\Deletor;
use LotGD\Core\Tools\Model\PropertyManager;
use LotGD\Core\Tools\Model\SceneBasics;
use Ramsey\Uuid\Uuid;
@@ -26,6 +27,7 @@ class Scene implements CreateableInterface, SceneConnectable
use Creator;
use Deletor;
use SceneBasics;
use PropertyManager;
/** @Id @Column(type="string", length=36, unique=True, name="id", options={"fixed"=true}) */
protected $id;
@@ -45,6 +47,14 @@ class Scene implements CreateableInterface, SceneConnectable
*/
private $incomingConnections = null;
/**
* @OneToMany(targetEntity="SceneProperty", mappedBy="owner", cascade={"persist", "remove"})
*/
private $properties;
// required for PropertyManager to now which class the properties belong to.
private $propertyClass = SceneProperty::class;
/**
* @var array
*/
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Tools\Model\Properties;
use Ramsey\Uuid\Uuid;
/**
* A place for modules to store per-module private data.
* @Entity
* @Table(name="scene_properties")
*/
class SceneProperty
{
use Properties;
/** @Id @ManyToOne(targetEntity="Scene", inversedBy="properties")
* @JoinColumn(name="owner", referencedColumnName="id")
*/
private Scene $owner;
/**
* Returns the owner.
* @return Scene
*/
public function getOwner(): Scene
{
return $this->owner;
}
/**
* Sets the owner.
* @param Scene $owner
*/
public function setOwner(Scene $owner)
{
$this->owner = $owner;
}
}