Merge branch '327_pinned_comment' into issue321_layout_improvements_actionForm

This commit is contained in:
2021-12-16 21:41:22 +01:00
57 changed files with 1115 additions and 512 deletions

View File

@@ -219,10 +219,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
private ?string $telephone = null;
/**
* @var array|null
* @ORM\Column(name="types", type="json", nullable=true)
*/
private $types;
private ?array $thirdPartyTypes = [];
/**
* @ORM\Column(name="updated_at", type="datetime_immutable", nullable=true)
@@ -303,18 +302,18 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function addType(?string $type): self
public function addThirdPartyTypes(?string $type): self
{
if (null === $type) {
return $this;
}
if (!in_array($type, $this->types ?? [], true)) {
$this->types[] = $type;
if (!in_array($type, $this->thirdPartyTypes ?? [], true)) {
$this->thirdPartyTypes[] = $type;
}
foreach ($this->children as $child) {
$child->addType($type);
$child->addThirdPartyTypes($type);
}
return $this;
@@ -329,7 +328,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
}
if (is_string($typeAndCategory)) {
$this->addType($typeAndCategory);
$this->addThirdPartyTypes($typeAndCategory);
return $this;
}
@@ -473,16 +472,16 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
*
* @return array|null
*/
public function getTypes()
public function getThirdPartyTypes()
{
return $this->types;
return $this->thirdPartyTypes ?? [];
}
public function getTypesAndCategories(): array
{
return array_merge(
$this->getCategories()->toArray(),
$this->getTypes() ?? []
$this->getThirdPartyTypes() ?? []
);
}
@@ -574,18 +573,18 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function removeType(?string $type): self
public function removeThirdPartyTypes(?string $type): self
{
if (null === $type) {
return $this;
}
if (in_array($type, $this->types ?? [], true)) {
$this->types = array_filter($this->types, fn ($e) => !in_array($e, $this->types, true));
if (in_array($type, $this->thirdPartyTypes ?? [], true)) {
$this->thirdPartyTypes = array_filter($this->thirdPartyTypes, fn ($e) => !in_array($e, $this->thirdPartyTypes, true));
}
foreach ($this->children as $child) {
$child->removeType($type);
$child->removeThirdPartyTypes($type);
}
return $this;
@@ -600,7 +599,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
}
if (is_string($typeAndCategory)) {
$this->removeType($typeAndCategory);
$this->removeThirdPartyTypes($typeAndCategory);
return $this;
}
@@ -799,13 +798,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
*
* @return ThirdParty
*/
public function setTypes(?array $type = null)
public function setThirdPartyTypes(?array $type = [])
{
// remove all keys from the input data
$this->types = array_values($type);
$this->thirdPartyTypes = array_values($type);
foreach ($this->children as $child) {
$child->setTypes($type);
$child->setThirdPartyTypes($type);
}
return $this;
@@ -814,7 +813,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
public function setTypesAndCategories(array $typesAndCategories): self
{
$types = array_filter($typesAndCategories, static fn ($item) => !$item instanceof ThirdPartyCategory);
$this->setTypes($types);
$this->setThirdPartyTypes($types);
// handle categories
foreach ($typesAndCategories as $t) {