Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ abstract class AbstractEvent
/** @var Collection<EventParticipation> Participations registered to this event */
protected $participations;

/** @var Collection<Attachment> Attachments to this event */
protected $attachments;

public function __construct(AbstractCalendar $calendar, User $owner, $name, Datetime $start, Datetime $end)
{
$this->name = $name;
$this->owner = $owner;
$this->calendar = $calendar;

$this->participations = new ArrayCollection;
$this->attachments = new ArrayCollection;

if ($start > $end) {
throw new InvalidArgumentException('An event cannot start after it was ended');
Expand Down Expand Up @@ -221,5 +225,23 @@ public function removeParticipation(EventParticipation $participation)

return $this;
}
}

/** @return Collection<Attachment> */
public function getAttachments()
{
return $this->attachments;
}

/** @return $this */
public function addAttachment(Attachment $attachment)
{
$this->attachments->add($attachment);

return $this;
}

public function hasAttachments()
{
return $this->attachments->count() > 0;
}
}
29 changes: 29 additions & 0 deletions src/Attachment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* This file is part of the CalendArt package
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*
* @copyright Wisembly
* @license http://www.opensource.org/licenses/MIT-License MIT License
*/

namespace CalendArt;

/**
* Represents an Attachment in a Event
*
* Like all generic objects, this object should be extended by the adapter
*/
interface Attachment
{
/** @return mixed */
public function getId();

/** @return string */
public function getName();

/** @return string */
public function getContents();
}
23 changes: 23 additions & 0 deletions src/UriAttachment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* This file is part of the CalendArt package
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*
* @copyright Wisembly
* @license http://www.opensource.org/licenses/MIT-License MIT License
*/

namespace CalendArt;

/**
* Represents an Attachment in a Event
*
* Like all generic objects, this object should be extended by the adapter
*/
interface UriAttachment extends Attachment
{
/** @return string */
public function getUri();
}