Skip to content

Commit

Permalink
Merge pull request #36 from phpminds/develop
Browse files Browse the repository at this point in the history
Added new supporter and showing Speaker info.
  • Loading branch information
pavlakis committed Jan 5, 2016
2 parents 7b01bbc + 4a69dcb commit 512cf49
Show file tree
Hide file tree
Showing 26 changed files with 754 additions and 85 deletions.
5 changes: 1 addition & 4 deletions app/src/Action/AdminDashboardAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ public function __construct(Twig $view, LoggerInterface $logger, EventsService $

public function dispatch($request, $response, $args)
{
$events = $this->eventService->getAll();
$speakers = $this->eventManager->getSpeakers();
$venues = $this->eventService->getVenues();

$this->eventService->mergeEvents($events, $speakers, $venues);
$events = $this->eventService->getAll();

$this->view->render($response, 'admin/dashboard.twig', [
'events' => $events
Expand Down
2 changes: 1 addition & 1 deletion app/src/Action/HomeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function dispatch($request, $response, $args)



$resWithETag = $this->cache->withETag($response, $event['id']);
$resWithETag = $this->cache->withETag($response, $event->getMeetupID());

$this->view->render($response, 'home.twig', ['event' => $event,'previousEvents'=>$previousEvents]);
return $resWithETag;
Expand Down
1 change: 1 addition & 0 deletions app/src/Action/PastEventsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function eventByYearMonth(Request $request, Response $response, $args)

$eventMeta = $this->eventManager->getByYearMonth($year,$month);
$event = $this->eventService->getEventById($eventMeta[0]['meetup_id']);

$resWithETag = $this->cache->withETag($response, $eventMeta[0]['meetup_id']);
$previousEvents= $this->eventService->getPastEvents();

Expand Down
49 changes: 46 additions & 3 deletions app/src/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

namespace PHPMinds\Factory;

use PHPMinds\Model\Email;
use PHPMinds\Model\Event\Entity\Speaker;
use PHPMinds\Model\Event\Entity\Supporter;
use PHPMinds\Model\Event\Entity\Talk;
use PHPMinds\Model\Event\Event;
use PHPMinds\Model\Event\Entity\Venue;
use PHPMinds\Model\Event\EventModel;
use PHPMinds\Model\Twitter;
use Slim\Http\Request;

class EventFactory
Expand All @@ -16,7 +21,7 @@ public static function getEvent($talkTitle, $talkDescription, $date, $speaker, $
$speaker
);

$event = new Event(
$event = new EventModel(
$talk,
$date,
$venue,
Expand All @@ -28,4 +33,42 @@ public static function getEvent($talkTitle, $talkDescription, $date, $speaker, $

return $event;
}
}

public static function getMergedFromArrays(array $meetupEvent = [], array $dbEvent = [])
{
$speaker = new Speaker(
$dbEvent['first_name'], $dbEvent['last_name'],
new Email($dbEvent['email']),
new Twitter($dbEvent['twitter']),
$dbEvent['avatar']
);


$talk = new Talk($meetupEvent['subject'], $meetupEvent['description'], $speaker);

$venue = new Venue($meetupEvent['venue_name'], $meetupEvent['venue_address']);

$date = \DateTime::createFromFormat('F jS Y', $meetupEvent['date']);

$supporter = new Supporter(
$dbEvent['supporter_name'], $dbEvent['supporter_url'],
new Twitter($dbEvent['supporter_twitter']),
new Email($dbEvent['supporter_email']),
$dbEvent['supporter_logo']
);

$event = new EventModel(
$talk,
$date,
$venue,
$supporter
);

$event->setName($meetupEvent['group']);
$event->setMindsUrl($meetupEvent['minds_url']);
$event->setMeetupID($meetupEvent['id']);
$event->setMeetupURL($meetupEvent['event_url']);

return $event;
}
}
18 changes: 16 additions & 2 deletions app/src/Model/Event/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class Event

private $supporterID;

public function __construct($meetupID, $meetupVenueID, $joindinEventName, $joindinTalkID, $joindinURL, $speakerID, $supporterID)
private $meetupDate;

public function __construct($meetupID, $meetupVenueID, $joindinEventName, $joindinTalkID, $joindinURL, $speakerID, $supporterID, \DateTime $meetupDate)
{
$this->meetupID = $meetupID;
$this->meetupVenueID = $meetupVenueID;
Expand All @@ -29,6 +31,7 @@ public function __construct($meetupID, $meetupVenueID, $joindinEventName, $joind
$this->joindinURL = $joindinURL;
$this->speakerID = $speakerID;
$this->supporterID = $supporterID;
$this->meetupDate = $meetupDate;
}

/**
Expand Down Expand Up @@ -112,6 +115,16 @@ public function getSupporterID()
return $this->supporterID;
}

/**
* @return \DateTime
*/
public function getMeetupDate()
{
return $this->meetupDate;
}



public static function create(array $params = []) : Event
{
$class = new self(
Expand All @@ -121,7 +134,8 @@ public static function create(array $params = []) : Event
$params['joindin_talk_id'] ?? null,
$params['joindin_url'] ?? null,
$params['speaker_id'] ?? null,
$params['supporter_id'] ?? null
$params['supporter_id'] ?? null,
$params['meetup_date'] ?? null
);

$class->setId($params['id'] ?? null);
Expand Down
8 changes: 8 additions & 0 deletions app/src/Model/Event/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public function getDetailsByMeetupID($meetupID)
return $this->eventsRepo->getByMeetupID($meetupID);
}

/**
* @return mixed
*/
public function getAllEventDetails()
{
return $this->eventsRepo->getAllEventDetails();
}

/**
* @param EventEntity $event
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHPMinds\Model\Event\Entity\Venue;
use PHPMinds\Model\Event\Entity\Talk;

class Event
class EventModel
{
private $name;

Expand All @@ -31,6 +31,20 @@ class Event
*/
private $supporter;

/**
* @var string
*/
private $mindsUrl;

/**
* @var
*/
private $meetupID;

/**
* @var
*/
private $meetupURL;

public function __construct(Talk $talk, \DateTime $date, Venue $venue, Supporter $supporter)
{
Expand Down Expand Up @@ -93,6 +107,14 @@ public function getEndDate()
return $this->date->add($this->talk->getDuration());
}

/**
* @return string
*/
public function getDateTimeAsString()
{
return $this->date->format('F jS Y');
}

/**
* @return Venue
*/
Expand All @@ -108,4 +130,52 @@ public function getSupporter() : Supporter
{
return $this->supporter;
}

/**
* @return string
*/
public function getMindsUrl()
{
return $this->mindsUrl;
}

/**
* @param string $mindsUrl
*/
public function setMindsUrl($mindsUrl)
{
$this->mindsUrl = $mindsUrl;
}

/**
* @return mixed
*/
public function getMeetupID()
{
return $this->meetupID;
}

/**
* @param mixed $meetupID
*/
public function setMeetupID($meetupID)
{
$this->meetupID = $meetupID;
}

/**
* @return mixed
*/
public function getMeetupURL()
{
return $this->meetupURL;
}

/**
* @param mixed $meetupURL
*/
public function setMeetupURL($meetupURL)
{
$this->meetupURL = $meetupURL;
}
}
10 changes: 5 additions & 5 deletions app/src/Model/JoindinEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace PHPMinds\Model;

use PHPMinds\Config\JoindinConfig;
use PHPMinds\Model\Event\Event;
use PHPMinds\Model\Event\EventModel;
use PHPMinds\Repository\FileRepository;

class JoindinEvent
Expand Down Expand Up @@ -96,10 +96,10 @@ public function getUrl($action = 'events', $end = '/')
}

/**
* @param Event $event
* @param EventModel $event
* @return array
*/
public function getCreateEventPayload(Event $event)
public function getCreateEventPayload(EventModel $event)
{
return [
'name' => $event->getName(),
Expand All @@ -113,11 +113,11 @@ public function getCreateEventPayload(Event $event)
}

/**
* @param Event $event
* @param EventModel $event
* @param string $language
* @return array
*/
public function getCreateEventTitlePayload(Event $event, $language = 'English - UK')
public function getCreateEventTitlePayload(EventModel $event, $language = 'English - UK')
{
$speakers = [$event->getTalk()->getSpeaker()->getFirstName() . ' ' . $event->getTalk()->getSpeaker()->getLastName()];

Expand Down
14 changes: 8 additions & 6 deletions app/src/Model/MeetupEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use PHPMinds\Config\MeetupConfig;
use PHPMinds\Model\Event\Entity\Talk;
use PHPMinds\Model\Event\Entity\Venue;
use PHPMinds\Model\Event\Event;
use PHPMinds\Model\Event\EventModel;

class MeetupEvent
{
Expand Down Expand Up @@ -110,17 +110,19 @@ public function formatResponse(array $event = [])
'time' => $eventTime,
'location' => $eventLocation,
'venue_id' => $venue['id'] ?? '',
'event_url' => $eventUrl,
'description' => $eventDescription,
'minds_url'=>$mindsUrl
'venue_name' => $venue['name'] ?? '',
'venue_address' => $venue['address_1'] ?? '',
'event_url' => $eventUrl,
'description' => $eventDescription,
'minds_url' => $mindsUrl
];
}

/**
* @param Event $event
* @param EventModel $event
* @return array
*/
public function getCreateEventPayload(Event $event)
public function getCreateEventPayload(EventModel $event)
{
// x-www-form-urlencoded
// have not tried using json
Expand Down
Loading

0 comments on commit 512cf49

Please sign in to comment.