Skip to content

Commit

Permalink
EV-318: Added editable to entities
Browse files Browse the repository at this point in the history
  • Loading branch information
cableman committed Nov 27, 2023
1 parent a47fd64 commit 39e1d6a
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 6 deletions.
41 changes: 41 additions & 0 deletions migrations/Version20231127121531.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231127121531 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE address ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE event ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE image ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE location ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE occurrence ADD editable TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE tag ADD editable TINYINT(1) NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE occurrence DROP editable');
$this->addSql('ALTER TABLE location DROP editable');
$this->addSql('ALTER TABLE event DROP editable');
$this->addSql('ALTER TABLE tag DROP editable');
$this->addSql('ALTER TABLE address DROP editable');
$this->addSql('ALTER TABLE image DROP editable');
}
}
3 changes: 2 additions & 1 deletion src/DataFixtures/AddressFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function load(ObjectManager $manager): void
->setCountry('Danmark')
->setCity('Aarhus')
->setLatitude(56.1507645)
->setLongitude(10.2112699);
->setLongitude(10.2112699)
->setEditable(true);
$manager->persist($address);
$this->addReference(self::ITKDEV, $address);

Expand Down
4 changes: 3 additions & 1 deletion src/DataFixtures/EventFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function load(ObjectManager $manager): void
->setLocation($this->getReference(LocationFixture::ITKDEV))
->addTag($this->getReference(TagsFixtures::AROS))
->addTag($this->getReference(TagsFixtures::RACE))
->setHash('4936efebda146f6775fb7e429d884fef');
->setEditable(true)
->setHash('4936efebda146f6775fb7e429d884fef');
$manager->persist($event);
$this->addReference(self::EVENT2, $event);

Expand All @@ -45,6 +46,7 @@ public function load(ObjectManager $manager): void
->setLocation($this->getReference(LocationFixture::ITKDEV))
->addTag($this->getReference(TagsFixtures::CONCERT))
->addTag($this->getReference(TagsFixtures::AROS))
->setEditable(true)
->setHash('16d48c26d38f6d59b3d081e596b4d0e8');
$manager->persist($event);
$this->addReference(self::EVENT1, $event);
Expand Down
3 changes: 2 additions & 1 deletion src/DataFixtures/LocationFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function load(ObjectManager $manager): void
->setMail('itkdev@mkb.aarhus.dk')
->setUrl('https://itk.aarhus.dk/om-itk/afdelinger/development/')
->setAddress($this->getReference(AddressFixture::ITKDEV))
->setDisabilityAccess(true);
->setDisabilityAccess(true)
->setEditable(true);
$manager->persist($location);
$this->addReference(self::ITKDEV, $location);

Expand Down
10 changes: 7 additions & 3 deletions src/DataFixtures/OccurrenceFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ public function load(ObjectManager $manager): void
->setStart(new \DateTimeImmutable('2024-12-07T14:30:00+02:00'))
->setEnd(new \DateTimeImmutable('2024-12-07T15:30:00+02:00'))
->setTicketPriceRange('10.000 Kr.')
->setRoom('M2-5');
->setRoom('M2-5')
->setEditable(true);
$manager->persist($occurrence);

$occurrence = new Occurrence();
$occurrence->setEvent($this->getReference(EventFixture::EVENT1))
->setStart(new \DateTimeImmutable('2024-11-08T10:30:00+02:00'))
->setEnd(new \DateTimeImmutable('2024-11-08T16:30:00+02:00'))
->setTicketPriceRange('Free or 100')
->setRoom('M2-6');
->setRoom('M2-6')
->setEditable(true);
$manager->persist($occurrence);

$occurrence = new Occurrence();
$occurrence->setEvent($this->getReference(EventFixture::EVENT2))
->setStart(new \DateTimeImmutable('2024-12-08T12:30:00+02:00'))
->setEnd(new \DateTimeImmutable('2024-12-08T14:30:00+02:00'))
->setTicketPriceRange('Free in December')
->setRoom('M2-5');
->setRoom('M2-5')
->setEditable(true);
$manager->persist($occurrence);

// Make it stick.
Expand Down
9 changes: 9 additions & 0 deletions src/DataFixtures/TagsFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class TagsFixtures extends Fixture implements DependentFixtureInterface
public const KIDS = 'tags_kids';
public const RACE = 'tags_race';
public const AROS = 'tags_aros';
public const ITKDEV = 'tags_itkdev';

public function load(ObjectManager $manager): void
{
Expand Down Expand Up @@ -40,6 +41,14 @@ public function load(ObjectManager $manager): void
$manager->persist($tag);
$this->addReference(self::CONCERT, $tag);

$tag = new Tag();
$tag->setName('ITKDev')
->addVocabulary($this->getReference(VocabularyFixtures::MANAGED))

Check failure on line 46 in src/DataFixtures/TagsFixtures.php

View workflow job for this annotation

GitHub Actions / Psalm static analysis (8.2)

ArgumentTypeCoercion

src/DataFixtures/TagsFixtures.php:46:29: ArgumentTypeCoercion: Argument 1 of App\Entity\Tag::addVocabulary expects App\Entity\Vocabulary, but parent type object provided (see https://psalm.dev/193)
->setEditable(true);
$manager->persist($tag);
$this->addReference(self::ITKDEV, $tag);


// Make it stick.
$manager->flush();
}
Expand Down
15 changes: 15 additions & 0 deletions src/Entity/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Address
#[ORM\OneToMany(mappedBy: 'address', targetEntity: Location::class)]
private Collection $locations;

#[ORM\Column]
private bool $editable = false;

public function __construct()
{
$this->locations = new ArrayCollection();
Expand Down Expand Up @@ -197,4 +200,16 @@ public function removeLocation(Location $location): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class Event implements IndexItemInterface
#[SerializedPath('[updated]')]
protected $updatedAt;

#[ORM\Column]
private bool $editable = false;

public function __construct()
{
$this->occurrences = new ArrayCollection();
Expand Down Expand Up @@ -346,4 +349,16 @@ public function setImage(?Image $image): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Image
#[ORM\Column(length: 255)]
private ?string $title = null;

#[ORM\Column]
private bool $editable = false;

public function __toString(): string
{
return sprintf('%s (%d)', $this->title ?? 'Missing', $this->id ?? -1);
Expand Down Expand Up @@ -105,4 +108,16 @@ public function setTitle(string $title): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class Location implements IndexItemInterface
#[ORM\OneToMany(mappedBy: 'location', targetEntity: Event::class)]
private Collection $events;

#[ORM\Column]
private bool $editable = false;

public function __construct()
{
$this->events = new ArrayCollection();
Expand Down Expand Up @@ -187,4 +190,16 @@ public function removeEvent(Event $event): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Occurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Occurrence implements IndexItemInterface
#[Groups([IndexNames::Events->value])]
private ?string $status = null;

#[ORM\Column]
private bool $editable = false;

public function __construct()
{
$this->dailyOccurrences = new ArrayCollection();
Expand Down Expand Up @@ -164,4 +167,16 @@ public function setStatus(?string $status): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Tag
#[ORM\ManyToMany(targetEntity: Event::class, mappedBy: 'tags')]
private Collection $events;

#[ORM\Column]
private bool $editable = false;

public function __construct()
{
$this->vocabularies = new ArrayCollection();
Expand Down Expand Up @@ -113,4 +116,16 @@ public function removeEvent(Event $event): static

return $this;
}

public function isEditable(): bool
{
return $this->editable;
}

public function setEditable(bool $editable): static
{
$this->editable = $editable;

return $this;
}
}

0 comments on commit 39e1d6a

Please sign in to comment.