Adds improvements to the SceneTemplate object, and integrates them into the console command.
This commit is contained in:
@@ -72,7 +72,7 @@ class SceneAddCommand extends BaseCommand
|
||||
$template = $em->getRepository(SceneTemplate::class)->find($templateClass);
|
||||
|
||||
if (!$template) {
|
||||
$io->warning("Template '$template' has not been found. Set to NULL instead.")
|
||||
$io->warning("Template '$template' has not been found. Set to NULL instead.");
|
||||
}
|
||||
} else {
|
||||
$template = $templateClass;
|
||||
|
||||
@@ -34,10 +34,14 @@ class SceneTemplateListCommand extends BaseCommand
|
||||
/** @var SceneTemplate[] $templates */
|
||||
$templates = $em->getRepository(SceneTemplate::class)->findAll();
|
||||
|
||||
$table = [["class"], []];
|
||||
$table = [["class", "module", "assignable", "# scenes", "# viewpoints"], []];
|
||||
foreach ($templates as $template) {
|
||||
$table[1][] = [
|
||||
$template->getClass(),
|
||||
$template->getModule(),
|
||||
$template->isUserAssignable()?"X":"-",
|
||||
count($template->getOwningScenes()),
|
||||
count($template->getOwningViewpoints()),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping\Column;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\Id;
|
||||
@@ -19,13 +20,25 @@ use LotGD\Core\SceneTemplates\SceneTemplateInterface;
|
||||
class SceneTemplate
|
||||
{
|
||||
/** @Id @Column(type="string", length=255, unique=True, name="class") */
|
||||
protected $class;
|
||||
protected string $class;
|
||||
|
||||
/** @Column(type="string", length=255, name="module") */
|
||||
protected $module;
|
||||
protected string $module;
|
||||
|
||||
/** @Column(type="boolean", options={"default"=true}) */
|
||||
protected $userAssignable = true;
|
||||
protected bool $userAssignable = true;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Scene", mappedBy="template")
|
||||
* @var Collection<Scene>
|
||||
*/
|
||||
private Collection $owningScenes;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Viewpoint", mappedBy="template", fetch="EXTRA_LAZY")
|
||||
* @var Collection<Viewpoint>
|
||||
*/
|
||||
private Collection $owningViewpoints;
|
||||
|
||||
/**
|
||||
* SceneTemplates constructor.
|
||||
@@ -54,6 +67,14 @@ class SceneTemplate
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getModule(): string
|
||||
{
|
||||
return $this->module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether the template should be able to get manually assigned to a template or not.
|
||||
* @param bool $flag
|
||||
@@ -62,4 +83,28 @@ class SceneTemplate
|
||||
{
|
||||
$this->userAssignable = $flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isUserAssignable(): bool
|
||||
{
|
||||
return $this->userAssignable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getOwningScenes(): Collection
|
||||
{
|
||||
return $this->owningScenes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getOwningViewpoints(): Collection
|
||||
{
|
||||
return $this->owningViewpoints;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user