diff --git a/env.example b/.env.example similarity index 100% rename from env.example rename to .env.example diff --git a/app/dependencies.php b/app/dependencies.php index 7053416..03960f8 100644 --- a/app/dependencies.php +++ b/app/dependencies.php @@ -2,6 +2,8 @@ // DIC configuration $container = $app->getContainer(); +$injector = new \pavlakis\seaudi\Injector($container); + $container['notFoundHandler'] = function ($c) { return function ($request, $response) use ($c) { @@ -14,9 +16,9 @@ /* ---------- Configs ------------ */ -$container['events.config'] = function ($c) { +$container['PHPMinds\Config\EventsConfig'] = function ($c) { - return new App\Config\EventsConfig($c->get('settings')['events']); + return new PHPMinds\Config\EventsConfig($c->get('settings')['events']); }; @@ -24,7 +26,7 @@ $container['meetup.config'] = function ($c) { $meetup = $c->get('settings')['meetups']; - return new App\Config\MeetupConfig([ + return new PHPMinds\Config\MeetupConfig([ 'apiKey' => $meetup['apiKey'], 'baseUrl' => $meetup['baseUrl'], 'groupUrlName' => $meetup['PHPMinds']['group_urlname'], @@ -36,7 +38,7 @@ $container['joindin.config'] = function ($c) { $joindin = $c->get('settings')['joindin']; - return new App\Config\JoindinConfig([ + return new PHPMinds\Config\JoindinConfig([ 'apiKey' => $joindin['key'], 'baseUrl' => $joindin['baseUrl'], 'frontendBaseUrl' => $joindin['frontendBaseUrl'], @@ -46,40 +48,53 @@ }; $container['meetup.event'] = function ($c) { - return new \App\Model\MeetupEvent($c->get('meetup.config')); + return new \PHPMinds\Model\MeetupEvent($c->get('meetup.config')); }; $container['joindin.event'] = function ($c) { - return new \App\Model\JoindinEvent( - $c->get('joindin.config'), $c->get('file.repository') + return new \PHPMinds\Model\JoindinEvent( + $c->get('joindin.config'), $c->get('PHPMinds\Repository\FileRepository') ); }; + $container['parsedown'] = function($c) { return new Parsedown(); }; $container['service.joindin'] = function ($c) { - return new \App\Service\JoindinService($c->get('http.client'), $c->get('joindin.event')); + return new \PHPMinds\Service\JoindinService($c->get('http.client'), $c->get('joindin.event')); }; $container['service.meetup'] = function ($c) { - return new \App\Service\MeetupService($c->get('http.client'), $c->get('meetup.event')); + + return new \PHPMinds\Service\MeetupService( + \DMS\Service\Meetup\MeetupKeyAuthClient::factory( + [ + 'key' => $c->get('meetup.config')->apiKey, + 'base_url' => $c->get('meetup.config')->baseUrl, + 'group_urlname' => $c->get('meetup.config')->groupUrlName, + 'publish_status' => $c->get('meetup.config')->publishStatus + ] + ), + $c->get('meetup.event'), + $c->get('meetup.config') + ); }; -$container['service.content'] = function ($c) { +$container['PHPMinds\Service\ContentService'] = function ($c) { $content = $c->get('settings')['content-folder']; - return new \App\Service\ContentService($c->get('parsedown'),$content['location']); + return new \PHPMinds\Service\ContentService($c->get('parsedown'),$content['location']); }; -$container['service.event'] = function ($c) { - return new \App\Service\EventsService( +$container['PHPMinds\Service\EventsService'] = function ($c) { + return new \PHPMinds\Service\EventsService( $c->get('service.meetup'), $c->get('service.joindin'), - $c->get('event.manager') + $c->get('PHPMinds\Model\Event\EventManager') ); }; @@ -88,58 +103,47 @@ return new \GuzzleHttp\Client(); }; -$container['cache'] = function () { +$container['Slim\HttpCache\CacheProvider'] = function () { return new \Slim\HttpCache\CacheProvider(); }; -$container ['db'] = function ($c) { +$container ['PHPMinds\Model\Db'] = function ($c) { $db = $c->get('settings')['db']; - return new \App\Model\Db ( + return new \PHPMinds\Model\Db ( 'mysql:host=' . $db['host'] . ';dbname=' . $db['dbname'], $db['username'], $db['password'] ); }; // Repositories -$container['file.repository'] = function ($c) { - return new \App\Repository\FileRepository( +$container['PHPMinds\Repository\FileRepository'] = function ($c) { + return new \PHPMinds\Repository\FileRepository( $c->get('settings')['file_store']['path'] ); }; -$container['users.repository'] = function ($c) { - return new \App\Repository\UsersRepository($c->get('db')); -}; - -$container['speakers.repository'] = function ($c) { - return new \App\Repository\SpeakersRepository($c->get('db')); -}; - -$container['events.repository'] = function ($c) { - return new \App\Repository\EventsRepository($c->get('db')); -}; - -$container['supporters.repository'] = function ($c) { - return new \App\Repository\SupportersRepository($c->get('db')); -}; +$injector->add('PHPMinds\Repository\UsersRepository'); +$injector->add('PHPMinds\Repository\SpeakersRepository'); +$injector->add('PHPMinds\Repository\EventsRepository'); +$injector->add('PHPMinds\Repository\SupportersRepository'); // Managers -$container['event.manager'] = function ($c) { - return new \App\Model\Event\EventManager( - $c->get('events.repository'), - $c->get('speakers.repository'), - $c->get('supporters.repository') +$container['PHPMinds\Model\Event\EventManager'] = function ($c) { + return new PHPMinds\Model\Event\EventManager( + $c->get('PHPMinds\Repository\EventsRepository'), + $c->get('PHPMinds\Repository\SpeakersRepository'), + $c->get('PHPMinds\Repository\SupportersRepository') ); }; -$container['auth.middleware'] = function ($c) { - return new App\Middleware\AuthCheck($_SESSION, 'auth', $c->get('settings')['auth-routes']); +$container['PHPMinds\Middleware\AuthCheck'] = function ($c) { + return new PHPMinds\Middleware\AuthCheck($_SESSION, 'auth', $c->get('settings')['auth-routes']); }; -$container['csrf'] = function ($c) { +$container['Slim\Csrf\Guard'] = function ($c) { $guard = new \Slim\Csrf\Guard(); $guard->setFailureCallable(function ($request, $response, $next) { $request = $request->withAttribute("csrf_status", false); @@ -148,9 +152,9 @@ return $guard; }; -$container['auth.model'] = function ($c) { - return new \App\Model\Auth( - $c->get('users.repository') +$container['PHPMinds\Model\Auth'] = function ($c) { + return new PHPMinds\Model\Auth( + $c->get('PHPMinds\Repository\UsersRepository') ); }; @@ -159,7 +163,7 @@ // ----------------------------------------------------------------------------- // Twig -$container['view'] = function ($c) { +$container['Slim\Views\Twig'] = function ($c) { $settings = $c->get('settings'); $view = new \Slim\Views\Twig($settings['view']['template_path'], $settings['view']['twig']); @@ -171,16 +175,14 @@ }; // Flash messages -$container['flash'] = function ($c) { - return new \Slim\Flash\Messages; -}; +$injector->add('Slim\Flash\Messages'); // ----------------------------------------------------------------------------- // Service factories // ----------------------------------------------------------------------------- // monolog -$container['logger'] = function ($c) { +$container['Psr\Log\LoggerInterface'] = function ($c) { $settings = $c->get('settings'); $logger = new \Monolog\Logger($settings['logger']['name']); $logger->pushProcessor(new \Monolog\Processor\UidProcessor()); @@ -192,74 +194,17 @@ // Action factories // ----------------------------------------------------------------------------- -$container['App\Action\HomeAction'] = function ($c) { - return new App\Action\HomeAction( - $c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('service.content'), $c->get('cache') - ); -}; - -$container['App\Action\AdminDashboardAction'] = function ($c) { - - return new App\Action\AdminDashboardAction( - $c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('event.manager') - ); -}; -$container['App\Action\LoginAction'] = function ($c) { - return new App\Action\LoginAction( - $c->get('view'), $c->get('logger'), $c->get('auth.model'), $c->get('csrf') - ); -}; - -$container['App\Action\CreateSpeakerAction'] = function ($c) { - - return new App\Action\CreateSpeakerAction( - $c->get('view'), $c->get('logger'), $c->get('speakers.repository') - ); -}; -$container['App\Action\LogoutAction'] = function ($c) { - - return new App\Action\LogoutAction( - $c->get('view'), $c->get('logger'), $c->get('auth.model') - ); -}; - -$container['App\Action\NotFoundAction'] = function ($c) { - - return new App\Action\NotFoundAction( - $c->get('view'), $c->get('logger') - ); -}; - - -$container['App\Action\CreateEventAction'] = function ($c) { - - return new App\Action\CreateEventAction( - $c->get('view'), $c->get('logger'), $c->get('service.event'), - $c->get('csrf'), $c->get('event.manager'), $c->get('events.config'), - $c->get('auth.model'), $c->get('flash') - ); -}; - -$container['App\Action\EventDetailsAction'] = function ($c) { - - return new App\Action\EventDetailsAction( - $c->get('view'), $c->get('logger'), $c->get('service.event'), $c->get('flash') - ); -}; - -$container['App\Action\CallbackAction'] = function ($c) { - - return new App\Action\CallbackAction( - $c->get('logger'), $c->get('auth.model'), $c->get('file.repository') - ); -}; - -$container['App\Action\EventStatusAction'] = function ($c) { - - return new App\Action\EventStatusAction( - $c->get('logger'), $c->get('service.event') - ); -}; \ No newline at end of file +$injector->add('PHPMinds\Action\NotFoundAction'); +$injector->add('PHPMinds\Action\HomeAction'); +$injector->add('PHPMinds\Action\LoginAction'); +$injector->add('PHPMinds\Action\LogoutAction'); +$injector->add('PHPMinds\Action\AdminDashboardAction'); +$injector->add('PHPMinds\Action\EventDetailsAction'); +$injector->add('PHPMinds\Action\CreateSpeakerAction'); +$injector->add('PHPMinds\Action\CreateEventAction'); +$injector->add('PHPMinds\Action\CallbackAction'); +$injector->add('PHPMinds\Action\EventStatusAction'); +$injector->add('PHPMinds\Action\PastEventsAction'); \ No newline at end of file diff --git a/app/middleware.php b/app/middleware.php index e1aeb0e..fb20360 100644 --- a/app/middleware.php +++ b/app/middleware.php @@ -5,11 +5,9 @@ $app->add(new \Slim\HttpCache\Cache('public', 86400)); -$app->add($container->get('auth.middleware')); -$app->add($container->get('csrf')); +$app->add($container->get('Slim\Csrf\Guard')); -$app->add($container->get('auth.middleware')); - -$app->add(new App\Middleware\CliRequest()); +$app->add($container->get('PHPMinds\Middleware\AuthCheck')); +$app->add(new \pavlakis\cli\CliRequest()); diff --git a/app/routes.php b/app/routes.php index 8e1e722..0376d06 100644 --- a/app/routes.php +++ b/app/routes.php @@ -1,41 +1,43 @@ get('/', 'App\Action\HomeAction:dispatch') +$app->get('/', 'PHPMinds\Action\HomeAction:dispatch') ->setName('homepage'); -$app->get('/login', 'App\Action\LoginAction:dispatch') +$app->get('/login', 'PHPMinds\Action\LoginAction:dispatch') ->setName('login'); -$app->post('/login', 'App\Action\LoginAction:dispatch') +$app->post('/login', 'PHPMinds\Action\LoginAction:dispatch') ->setName('login-post'); -$app->get('/logout', 'App\Action\LogoutAction:dispatch') +$app->get('/logout', 'PHPMinds\Action\LogoutAction:dispatch') ->setName('logout'); -$app->get('/404', 'App\Action\NotFoundAction:dispatch') +$app->get('/404', 'PHPMinds\Action\NotFoundAction:dispatch') ->setName('notfound'); +$app->get('/event/{year:[0-9]+}/{month:[0-9]+}','PHPMinds\Action\PastEventsAction:eventByYearMonth') + ->setName('pastEvents'); // -- auth -- -$app->get('/admin', 'App\Action\AdminDashboardAction:dispatch') +$app->get('/admin', 'PHPMinds\Action\AdminDashboardAction:dispatch') ->setName('dashboard'); -$app->get('/create-event', 'App\Action\CreateEventAction:dispatch') +$app->get('/create-event', 'PHPMinds\Action\CreateEventAction:dispatch') ->setName('create-event'); -$app->post('/create-event', 'App\Action\CreateEventAction:dispatch') +$app->post('/create-event', 'PHPMinds\Action\CreateEventAction:dispatch') ->setName('create-event-post'); -$app->post('/create-speaker', 'App\Action\CreateSpeakerAction:dispatch') +$app->post('/create-speaker', 'PHPMinds\Action\CreateSpeakerAction:dispatch') ->setName('create-speaker'); -$app->get('/event-details', 'App\Action\EventDetailsAction:dispatch') +$app->get('/event-details', 'PHPMinds\Action\EventDetailsAction:dispatch') ->setName('event-details'); -$app->get('/callback/{callback}', 'App\Action\CallbackAction:dispatch') +$app->get('/callback/{callback}', 'PHPMinds\Action\CallbackAction:dispatch') ->setName('calbacks'); -$app->get('/status', 'App\Action\EventStatusAction:dispatch') +$app->get('/status', 'PHPMinds\Action\EventStatusAction:dispatch') ->setName('status'); diff --git a/app/src/Action/AdminDashboardAction.php b/app/src/Action/AdminDashboardAction.php index fa7a9c4..6bb2ba1 100644 --- a/app/src/Action/AdminDashboardAction.php +++ b/app/src/Action/AdminDashboardAction.php @@ -1,9 +1,9 @@ eventManager->getSpeakerById((int)$request->getParam('speaker')); - $venue = $this->eventService->getVenueById($request->getParam('venue')); - $supporter = $this->eventManager->getSupporterByID($request->getParam('supporter')); + $speaker = $this->eventManager->getSpeakerById((int)$request->getParam('speaker')); + $venue = $this->eventService->getVenueById($request->getParam('venue')); + $supporter = $this->eventManager->getSupporterByID($request->getParam('supporter')); + + $date = \DateTime::createFromFormat( + "Y-m-d H:i", + $request->getParam('start_date') . ' ' + . ($request->getParam('start_time') < 10 ? '0' . $request->getParam('start_time') : $request->getParam('start_time')) + ); - $event = EventFactory::getByRequest( - $request, $speaker, $venue, $supporter, + $event = EventFactory::getEvent( + $request->getParam('talk_title'), $request->getParam('talk_description'), + $date, $speaker, $venue, $supporter, $this->eventsConfig->title, $this->eventsConfig->description ); diff --git a/app/src/Action/CreateSpeakerAction.php b/app/src/Action/CreateSpeakerAction.php index 0330eb1..36e2faa 100644 --- a/app/src/Action/CreateSpeakerAction.php +++ b/app/src/Action/CreateSpeakerAction.php @@ -1,15 +1,15 @@ eventsService->manageApprovedEvents($userID); - $this->logger->info(__CLASS__ . ' :: ' . $result); - echo $result; - echo PHP_EOL; + try { + $result = $this->eventsService->manageApprovedEvents($userID); + $this->logger->info(__CLASS__ . ' :: ' . $result); + echo $result; + echo PHP_EOL; + } catch (\Exception $e) { + echo __CLASS__ . ' :: ERROR :: ' . $e->getMessage() . PHP_EOL; + $this->logger->alert(__CLASS__ . ' :: ' . $e->getMessage()); + } exit; } diff --git a/app/src/Action/HomeAction.php b/app/src/Action/HomeAction.php index 207f339..4c40f42 100644 --- a/app/src/Action/HomeAction.php +++ b/app/src/Action/HomeAction.php @@ -1,8 +1,8 @@ view = $view; $this->logger = $logger; diff --git a/app/src/Action/LogoutAction.php b/app/src/Action/LogoutAction.php index 7afb284..196e6b0 100644 --- a/app/src/Action/LogoutAction.php +++ b/app/src/Action/LogoutAction.php @@ -1,10 +1,10 @@ view = $view; + $this->logger = $logger; + $this->eventService = $eventService; + + $this->eventManager = $eventManager; + $this->cache = $cache; + } + + public function eventByYearMonth(Request $request, Response $response, $args) + { + + $year = intval($args["year"]); + $month = intval($args["month"]); + + $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(); + + + $this->view->render($response, 'event.twig', ['event' => $event,'eventMeta'=>$eventMeta[0],'previousEvents'=>$previousEvents]); + + return $resWithETag; + } +} \ No newline at end of file diff --git a/app/src/Config/ConfigAbstract.php b/app/src/Config/ConfigAbstract.php index 4c6b92f..6c615c3 100644 --- a/app/src/Config/ConfigAbstract.php +++ b/app/src/Config/ConfigAbstract.php @@ -1,6 +1,6 @@ getParam('talk_title'), '


'), - strip_tags($request->getParam('talk_description'), '


'), + strip_tags($talkTitle, '


'), + strip_tags($talkDescription, '


'), $speaker ); $event = new Event( $talk, - \DateTime::createFromFormat( - "d/m/Y H:i", - $request->getParam('start_date') . ' ' - . ($request->getParam('start_time') < 10 ? '0' . $request->getParam('start_time') : $request->getParam('start_time')) - - ), + $date, $venue, $supporter ); diff --git a/app/src/Middleware/AuthCheck.php b/app/src/Middleware/AuthCheck.php index 904cc82..b0cd862 100644 --- a/app/src/Middleware/AuthCheck.php +++ b/app/src/Middleware/AuthCheck.php @@ -1,6 +1,6 @@ 'GET', - 'REQUEST_URI' => $path . '?' . $params, - 'QUERY_STRING' => $params - ])); - } - - unset($argv); - } - - return $next($request, $response); - } -} \ No newline at end of file diff --git a/app/src/Model/Auth.php b/app/src/Model/Auth.php index f7c7e39..bec7b56 100644 --- a/app/src/Model/Auth.php +++ b/app/src/Model/Auth.php @@ -1,8 +1,8 @@ eventsRepo->getEventByYearAndMonth($year,$month); + + return $event; + } } \ No newline at end of file diff --git a/app/src/Model/JoindinEvent.php b/app/src/Model/JoindinEvent.php index b0f629b..0448a11 100644 --- a/app/src/Model/JoindinEvent.php +++ b/app/src/Model/JoindinEvent.php @@ -1,10 +1,10 @@ publishStatus = $config->publishStatus; } - public function getUrl($action = 'events', $auth = true,$additionalApiParams = ['status'=>'past,upcoming']) + public function getUrl($action = 'events', $auth = true, $additionalApiParams = ['status'=>'past,upcoming']) { $authStr = ''; if ($auth) { @@ -50,7 +50,19 @@ public function getGroupUrlName() public function getAuthString($params = []) { - $params = array_merge(['group_urlname'=>$this->groupUrlName,"key"=>$this->apiKey,"order"=>"time","desc"=>"true"],$params); + $defaults = []; + if (!empty($params)) { + $defaults = [ 'order' => 'time', 'desc' => 'true']; + } + + $params = array_merge( + [ + 'group_urlname' => $this->groupUrlName, + "key" => $this->apiKey + ], + $defaults, + $params + ); $queryString = http_build_query($params); return '?'.$queryString; @@ -63,7 +75,7 @@ public function getEventUrl() public function getVenuesUrl() { - return $this->getUrl('venues'); + return $this->getUrl('venues', true, []); } public function formatResponse(array $event = []) @@ -81,7 +93,7 @@ public function formatResponse(array $event = []) $eventDate = date('l jS F Y', $event['time'] / 1000); $eventTime = date('g:ia', $event['time'] / 1000); $eventCache = date('my', $event['time'] / 1000); - + $mindsUrl = date('Y').'/'.date('m') ?? '/'; $venue = isset($event['venue']) ? $event['venue'] : ''; $eventLocation = ''; @@ -99,7 +111,8 @@ public function formatResponse(array $event = []) 'location' => $eventLocation, 'venue_id' => $venue['id'] ?? '', 'event_url' => $eventUrl, - 'description' => $eventDescription + 'description' => $eventDescription, + 'minds_url'=>$mindsUrl ]; } diff --git a/app/src/Model/Twitter.php b/app/src/Model/Twitter.php index 14df6ba..fc358e7 100644 --- a/app/src/Model/Twitter.php +++ b/app/src/Model/Twitter.php @@ -1,8 +1,8 @@ columns; - array_walk($aliasedCols, function(&$value, $key, $alias){ - $value = $alias. '.'.$value; + array_walk($aliasedCols, function (&$value, $key, $alias) { + $value = $alias . '.' . $value; }, 'ev'); @@ -104,8 +104,8 @@ public function getByMeetupID($meetupID) public function eventExists($eventName) { $sql = 'SELECT COUNT(*)' - . ' FROM '. $this->table - . ' WHERE joindin_event_name = :event_name'; + . ' FROM ' . $this->table + . ' WHERE joindin_event_name = :event_name'; $stmt = $this->db->prepare($sql); $stmt->bindParam(":event_name", $eventName, \PDO::PARAM_STR); @@ -118,6 +118,7 @@ public function eventExists($eventName) return (int)$result[0] > 0; } + /** * @return array */ @@ -125,9 +126,73 @@ public function getAllPending() { // a pending event has a joindin_talk_id of ZERO $sql = 'SELECT meetup_id, joindin_event_name, speaker_id, supporter_id' - . ' FROM '. $this->table + . ' FROM ' . $this->table . ' WHERE joindin_talk_id = 0 '; return $this->db->query($sql, \PDO::FETCH_OBJ)->fetchAll(); } + + /** + * Get Event by Date for past events + * @param int $year + * @param int $month + * @return array + */ + public function getEventByYearAndMonth(int $year, int $month) + { + + $sql = 'SELECT meetup_id,' + . 'joindin_talk_id,' + . 'joindin_url,' + . 'meetup_date,' + . 'first_name,' + . 'last_name,' + . 'twitter,' + . 'email' + . ' FROM '. $this->table + . ' LEFT JOIN speakers ON speaker_id=speakers.id' + . ' WHERE year(meetup_date) =:year' + . ' AND month(meetup_date)=:month'; + + $stmt = $this->db->prepare($sql); + //exit(var_dump($stmt)); + $stmt->bindParam(":year",$year, \PDO::PARAM_INT); + $stmt->bindParam(":month",$month, \PDO::PARAM_INT); + $stmt->execute(); + $stmt->setFetchMode(\PDO::FETCH_ASSOC); + + return $stmt->fetchAll(); + } + + + /** + * Get event by speaker for past events + * @param string $firstName + * @param string $lastName + * @return array + */ + public function getEventBySpeaker(string $firstName, string $lastName ) + { + $sql = 'SELECT meetup_id,' + . 'joindin_talk_id,' + . 'joindin_url,' + . 'meetup_date,' + . 'first_name,' + . 'last_name,' + . 'twitter,' + . 'email' + . 'FROM '. $this->table + . 'LEFT JOIN speakers ON speaker_id=speakers.id' + . 'WHERE first_name =:firstName' + . 'AND last_name =:lastName'; + + $stmt = $this->db->prepare($sql); + $stmt->bindParam(":firstName",$firstName, \PDO::PARAM_STR); + $stmt->bindParam(":lastName",$lastName, \PDO::PARAM_STR); + $stmt->execute(); + $stmt->setFetchMode(\PDO::FETCH_ASSOC); + + return $stmt->fetchAll(); + } + } \ No newline at end of file diff --git a/app/src/Repository/FileRepository.php b/app/src/Repository/FileRepository.php index d4317df..c1aaf38 100644 --- a/app/src/Repository/FileRepository.php +++ b/app/src/Repository/FileRepository.php @@ -1,6 +1,6 @@ db = $db; } diff --git a/app/src/Repository/SpeakersRepository.php b/app/src/Repository/SpeakersRepository.php index c55ca48..449a06c 100644 --- a/app/src/Repository/SpeakersRepository.php +++ b/app/src/Repository/SpeakersRepository.php @@ -1,10 +1,10 @@ meetupService->getPastEvents(); } + + /** * @param $eventID * @return array @@ -156,13 +158,20 @@ public function getVenues() /** * @param $venueID - * @return \App\Model\Event\Entity\Venue + * @return \PHPMinds\Model\Event\Entity\Venue */ public function getVenueById($venueID) { return $this->meetupService->getVenueById($venueID); } + /** + * @param Event $event + * @param $userID + * @param null $meetupID + * @return array + * @throws \Exception + */ public function createMainEvents(Event $event, $userID, $meetupID = null) { $this->createEvent($event); @@ -203,13 +212,13 @@ public function createEvent(Event $event) * Save event references to the DB * * @param string $eventName If null, use it through the event object - * @return \App\Model\Event\Entity\Event + * @return \PHPMinds\Model\Event\Entity\Event */ public function updateEvents($eventName = null) { $eventName = $eventName ?? $this->event->getName(); - $eventEntity = new \App\Model\Event\Entity\Event( + $eventEntity = new \PHPMinds\Model\Event\Entity\Event( $this->meetupService->getMeetupEvent()->getMeetupEventID(), $this->event->getVenue()->getId(), $eventName, @@ -269,10 +278,10 @@ public function getEventInfo($meetupID) : array /** * @param $userID * @return string + * @throws \Exception */ public function manageApprovedEvents($userID) { - $events = $this->eventManager->getAllPendingEvents(); if (count($events) > 0) { @@ -296,17 +305,21 @@ public function manageApprovedEvents($userID) 'duration' => 'PT2H' // default to 2 hours ]); - $startDate = \DateTime::createFromFormat("F jS Y", $meetupEvent['date']); - $startTime = \DateTime::createFromFormat("g:ia", $meetupEvent['time']); - - $this->event = new Event( - $talk, $startDate->format('d/m/Y'), $startTime->format('H:i'), $venue, $supporter + $talk, + \DateTime::createFromFormat( + "F jS Y g:ia", + $meetupEvent['date'] . ' ' . $meetupEvent['time'] + ), + $venue, + $supporter ); - $this->joindinEventService->getJoindinEvent()->setEventLocation($event->uri); - $this->createJoindinTalk($userID); + if ($this->createJoindinTalk($userID)->getStatusCode() !== 201) { + throw new \Exception('Could not create Joindin Talk'); + } + $this->updateEvents($eventName); } diff --git a/app/src/Service/JoindinService.php b/app/src/Service/JoindinService.php index 7d1e786..96f2fc9 100644 --- a/app/src/Service/JoindinService.php +++ b/app/src/Service/JoindinService.php @@ -1,10 +1,10 @@ httpClient = $httpClient; - $this->meetupEvent = $meetupEvent; + $this->client = $meetupClient; + $this->meetupEvent = $meetupEvent; + $this->config = $config; } public function getMeetupEvent() @@ -30,13 +39,10 @@ public function getMeetupEvent() return $this->meetupEvent; } - protected function getEvents() + protected function getEvents($args = ['status' => 'past,upcoming']) { - $eventUrl = $this->meetupEvent->getEventUrl(); - - $response = $this->httpClient->get($eventUrl); - - return json_decode($response->getBody()->getContents(), true); + $eventArgs = array_merge(['group_urlname' => $this->config->groupUrlName], $args); + return $this->client->getEvents($eventArgs)->getData(); } /** @@ -47,7 +53,8 @@ public function getAll() $result = $this->getEvents(); $events = []; - foreach ($result['results'] as $event) { + foreach ($result as $event) { + $eventInfo = $this->meetupEvent->formatResponse($event); $events[$eventInfo['id']] = $eventInfo; } @@ -60,9 +67,9 @@ public function getAll() */ public function getLatestEvent() { - $events = $this->getEvents(); + $events = $this->getEvents(['status' => 'upcoming']); - return $this->meetupEvent->formatResponse($events['results'][0] ?? []); + return $this->meetupEvent->formatResponse($events[0] ?? []); } /** @@ -73,11 +80,9 @@ public function getPastEvents() { $pastEvents = []; - $events = $this->getEvents(); + $events = $this->getEvents(['status' => 'past']); - array_shift($events["results"]); - - foreach($events["results"] as $event){ + foreach($events as $event){ $pastEvents[] = $this->meetupEvent->formatResponse($event); } @@ -89,39 +94,20 @@ public function getPastEvents() */ public function createMeetup(Event $event) { - $response = $this->httpClient->post( - $this->meetupEvent->getUrl('event'), [ - 'form_params' => $this->meetupEvent->getCreateEventPayload($event) - ] + $eventArgs = array_merge([ + 'group_urlname' => $this->config->groupUrlName], + $this->meetupEvent->getCreateEventPayload($event) ); + $response = $this->client->createEvent($eventArgs); - $this->meetupEvent->setEventLocation($response->getHeader('location')[0]); + $this->meetupEvent->setEventLocation($response->getLocation()); return $response; } public function getEventById($eventID) { - $eventUrl = sprintf( - 'https://api.meetup.com/%s/events/%s', - $this->meetupEvent->getGroupUrlName(), - $eventID - ); - - try { - $response = $this->httpClient->get( - $eventUrl, - [ - 'headers' => [ - 'Accept' => 'application/json' - ] - ] - ); - } catch (\Exception $e) { - return []; - } - - $result = json_decode($response->getBody()->getContents(), true); + $result = $this->client->getEvent(['id' => $eventID, 'group_urlname' => $this->config->groupUrlName])->getData(); return $this->meetupEvent->formatResponse($result ?? []); } @@ -131,13 +117,7 @@ public function getEventById($eventID) */ public function getVenues() { - $venuesUrl = $this->meetupEvent->getVenuesUrl(); - - $result = json_decode( - $this->httpClient->get($venuesUrl)->getBody()->getContents(), - true - )['results']; - + $result = $this->client->getVenues(['group_urlname' => $this->config->groupUrlName])->getData(); $venues = []; foreach ($result as $venue) { diff --git a/app/src/Validator/EventValidator.php b/app/src/Validator/EventValidator.php index 80e582c..e280903 100644 --- a/app/src/Validator/EventValidator.php +++ b/app/src/Validator/EventValidator.php @@ -1,10 +1,10 @@
© phpminds.org {{ now |date("Y") }} - built with built with php7 + built with built with php7 Contribute on github

diff --git a/app/templates/event.twig b/app/templates/event.twig new file mode 100644 index 0000000..3fd4b0f --- /dev/null +++ b/app/templates/event.twig @@ -0,0 +1,37 @@ +{% extends "base.twig" %} +{% block content %} +
+
+
+

{{ event.date_time }} saw

+

{{ event.subject }}

+ +
+

{{ event.description | raw }}

+ +

Give Feedback

+
+ +
+
+
+
+

Full list of Past Events

+ + + + +
+ + +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/app/templates/home.twig b/app/templates/home.twig index d03493d..3c8806c 100644 --- a/app/templates/home.twig +++ b/app/templates/home.twig @@ -33,7 +33,7 @@ diff --git a/composer.json b/composer.json index 5ed00ac..fa80ac2 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,13 @@ ], "autoload": { "psr-4": { - "App\\Tests\\" : "tests/phpunit", - "App\\": "app/src" + "PHPMinds\\Tests\\" : "tests/phpunit", + "PHPMinds\\": "app/src" } }, + "minimum-stability" : "stable", "require": { + "php": "~7.0", "slim/slim": "^3.0", "slim/twig-view": "^1.1", "slim/flash": "^0.1.0", @@ -32,7 +34,11 @@ "aura/sql": "^2.4", "slim/csrf": "^0.4.0", "erusev/parsedown": "^1.6", - "robmorgan/phinx": "^0.4.6" + "robmorgan/phinx": "^0.5.0", + "pavlakis/slim-cli" : "~1.0", + "dms/meetup-api-client": "^2.0", + "pavlakis/seaudi": "~0.1" + }, "require-dev": { "squizlabs/php_codesniffer": "2.*", diff --git a/composer.lock b/composer.lock index f04aea7..fc4c497 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1fb58ec8a6426b3bd473f8f7c1e84a8f", - "content-hash": "b55138a6d23a50516a7a8fcdf6f5668c", + "hash": "833843bab2015f783b41148fb7a456d8", + "content-hash": "e5ba16aa23be694034310a4aee0aff50", "packages": [ { "name": "aura/sql", @@ -87,6 +87,65 @@ "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", "time": "2014-12-30 15:22:37" }, + { + "name": "dms/meetup-api-client", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/rdohms/meetup-api-client.git", + "reference": "478a20547446e2f01fbf3cdd44a38fc003f0fa32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rdohms/meetup-api-client/zipball/478a20547446e2f01fbf3cdd44a38fc003f0fa32", + "reference": "478a20547446e2f01fbf3cdd44a38fc003f0fa32", + "shasum": "" + }, + "require": { + "guzzle/guzzle": "~3.7", + "php": "^5.3.10 | ^7.0" + }, + "require-dev": { + "mathiasgrimm/arraypath": "~1.3", + "phpunit/phpunit": "^4.8", + "symfony/console": "~2.2", + "symfony/css-selector": "~2.2", + "symfony/dom-crawler": "~2.2", + "symfony/var-dumper": "~2.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "DMS": [ + "src/", + "tests/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rafael Dohms", + "homepage": "http://doh.ms" + } + ], + "description": "Meetup.com API client written on top of Guzzle. This supports all API operations.", + "keywords": [ + "Guzzle", + "api", + "dms", + "meetup.com" + ], + "time": "2015-12-23 13:54:00" + }, { "name": "erusev/parsedown", "version": "1.6.0", @@ -126,6 +185,101 @@ ], "time": "2015-10-04 16:44:32" }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, { "name": "guzzlehttp/guzzle", "version": "6.1.1", @@ -417,6 +571,105 @@ ], "time": "2015-06-18 19:15:47" }, + { + "name": "pavlakis/seaudi", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/pavlakis/seaudi.git", + "reference": "1767bdb9a6880dfac98f7e041e4265d5bee210fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pavlakis/seaudi/zipball/1767bdb9a6880dfac98f7e041e4265d5bee210fa", + "reference": "1767bdb9a6880dfac98f7e041e4265d5bee210fa", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "~1.1", + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "pavlakis\\seaudi\\tests\\": "tests/phpunit", + "pavlakis\\seaudi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Antonis Pavlakis", + "email": "adoni@pavlakis.info", + "homepage": "http://pavlakis.info" + } + ], + "description": "A semi-automatic DI resolver retrieving dependencies through a container.", + "homepage": "http://github.com/pavlakis/seaudi", + "keywords": [ + "container", + "di", + "ioc", + "reflection", + "slim" + ], + "time": "2015-12-27 13:58:58" + }, + { + "name": "pavlakis/slim-cli", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/pavlakis/slim-cli.git", + "reference": "ccd65e0b200cd7be7a906024b20c69b9eeb48cd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pavlakis/slim-cli/zipball/ccd65e0b200cd7be7a906024b20c69b9eeb48cd3", + "reference": "ccd65e0b200cd7be7a906024b20c69b9eeb48cd3", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0", + "slim/slim": "~3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "pavlakis\\cli\\tests\\": "tests/phpunit", + "pavlakis\\cli\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Antonis Pavlakis", + "email": "adoni@pavlakis.info", + "homepage": "http://pavlakis.info" + } + ], + "description": "Making a mock GET request through the CLI and enabling the same application entry point on CLI scripts.", + "homepage": "http://github.com/pavlakis/slim-cli", + "keywords": [ + "cli", + "framework", + "middleware", + "slim" + ], + "time": "2015-12-28 17:28:50" + }, { "name": "pimple/pimple", "version": "v3.0.2", @@ -552,16 +805,16 @@ }, { "name": "robmorgan/phinx", - "version": "v0.4.6", + "version": "v0.5.0", "source": { "type": "git", "url": "https://github.com/robmorgan/phinx.git", - "reference": "1351ca36dd2419d7de02afd1aaa415929112d7f1" + "reference": "df8933786806848fbf330f88d69998f29c29d8c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/robmorgan/phinx/zipball/1351ca36dd2419d7de02afd1aaa415929112d7f1", - "reference": "1351ca36dd2419d7de02afd1aaa415929112d7f1", + "url": "https://api.github.com/repos/robmorgan/phinx/zipball/df8933786806848fbf330f88d69998f29c29d8c4", + "reference": "df8933786806848fbf330f88d69998f29c29d8c4", "shasum": "" }, "require": { @@ -610,7 +863,7 @@ "migrations", "phinx" ], - "time": "2015-09-11 15:44:41" + "time": "2015-11-30 15:21:12" }, { "name": "slim/csrf", @@ -874,16 +1127,16 @@ }, { "name": "symfony/config", - "version": "v2.8.0", + "version": "v2.8.1", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae" + "reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae", - "reference": "f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae", + "url": "https://api.github.com/repos/symfony/config/zipball/17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2", + "reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2", "shasum": "" }, "require": { @@ -920,20 +1173,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2015-11-23 20:38:01" + "time": "2015-12-26 13:37:56" }, { "name": "symfony/console", - "version": "v2.8.0", + "version": "v2.8.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d232bfc100dfd32b18ccbcab4bcc8f28697b7e41" + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d232bfc100dfd32b18ccbcab4bcc8f28697b7e41", - "reference": "d232bfc100dfd32b18ccbcab4bcc8f28697b7e41", + "url": "https://api.github.com/repos/symfony/console/zipball/2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", "shasum": "" }, "require": { @@ -980,20 +1233,80 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-11-30 12:35:10" + "time": "2015-12-22 10:25:57" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5eb815363c0388e83247e7e9853e5dbc14999cc", + "reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/dependency-injection": "~2.6|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.3|~3.0.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 20:15:42" }, { "name": "symfony/filesystem", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884" + "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/692d98d813e4ef314b9c22775c86ddbeb0f44884", - "reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c2e59d11dccd135dc8f00ee97f34fe1de842e70c", + "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c", "shasum": "" }, "require": { @@ -1029,25 +1342,28 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-11-23 10:41:47" + "time": "2015-12-22 10:39:06" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.0.0", + "version": "v1.0.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0b6a8940385311a24e060ec1fe35680e17c74497" + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497", - "reference": "0b6a8940385311a24e060ec1fe35680e17c74497", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/49ff736bd5d41f45240cec77b44967d76e0c3d25", + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "suggest": { + "ext-mbstring": "For best performance" + }, "type": "library", "extra": { "branch-alias": { @@ -1085,20 +1401,20 @@ "portable", "shim" ], - "time": "2015-11-04 20:28:58" + "time": "2015-11-20 09:19:13" }, { "name": "symfony/yaml", - "version": "v2.8.0", + "version": "v2.8.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f79824187de95064a2f5038904c4d7f0227fedb5" + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f79824187de95064a2f5038904c4d7f0227fedb5", - "reference": "f79824187de95064a2f5038904c4d7f0227fedb5", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", "shasum": "" }, "require": { @@ -1134,7 +1450,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-11-30 12:35:10" + "time": "2015-12-26 13:37:56" }, { "name": "twig/twig", @@ -2380,6 +2696,8 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": "~7.0" + }, "platform-dev": [] } diff --git a/migrations/20151220173520_event_date_field.php b/migrations/20151220173520_event_date_field.php new file mode 100644 index 0000000..cad0997 --- /dev/null +++ b/migrations/20151220173520_event_date_field.php @@ -0,0 +1,18 @@ +table('events'); + $events->addColumn('meetup_date', 'datetime', array('after' => 'supporter_id')) + ->update(); + + } + + +} diff --git a/phinx.yml b/phinx.yml index 9b58e36..e42258d 100644 --- a/phinx.yml +++ b/phinx.yml @@ -1,6 +1,6 @@ paths: migrations: %%PHINX_CONFIG_DIR%%/migrations - + seeds: %%PHINX_CONFIG_DIR%%/seeds environments: default_migration_table: phinxlog default_database: phpminds diff --git a/seeds/EventSeeder.php b/seeds/EventSeeder.php new file mode 100644 index 0000000..892636f --- /dev/null +++ b/seeds/EventSeeder.php @@ -0,0 +1,27 @@ + '226158970', + 'meetup_venue_id' =>'24159763', + 'joindin_event_name'=>'PHPMiNDS December 2015', + 'joindin_talk_id'=>'16610', + 'joindin_url'=>'https://m.joind.in/talk/view/16610', + 'speaker_id'=>'1', + 'supporter_id'=>'1', + 'meetup_date'=>date('Y-m-d H:i:s',strtotime('2015-12-17 19:00:00')) + ) + ); + $events = $this->table('events'); + $events->insert($data) + ->save(); + + } +} diff --git a/seeds/SpeakerSeeder.php b/seeds/SpeakerSeeder.php new file mode 100644 index 0000000..9adc3dc --- /dev/null +++ b/seeds/SpeakerSeeder.php @@ -0,0 +1,40 @@ +'Rob', + 'last_name'=>'Allen', + 'email'=>'rob@akrabat.com', + 'twitter'=>'@akrabat', + 'avatar'=>null + ), + array( + 'first_name' =>'James', + 'last_name'=>'Titcumb', + 'email'=>'james@asgrim.com', + 'twitter'=>'@asgrim', + 'avatar'=>null + )); + $table = $this->table('speakers'); + $table->insert($data)->save(); + + } +} diff --git a/seeds/SupporterSeeder.php b/seeds/SupporterSeeder.php new file mode 100644 index 0000000..531e54b --- /dev/null +++ b/seeds/SupporterSeeder.php @@ -0,0 +1,32 @@ +'PHPMinds Organiser', + 'url'=>'http://phpminds.org', + 'email'=>'phpminds.org@gmail.com', + 'twitter'=>'@phpminds', + 'logo'=>null + )); + $table = $this->table('supporters'); + $table->insert($data)->save(); + + } +} diff --git a/tests/phpunit/Helper.php b/tests/phpunit/Helper.php index 97a925e..1fca2c0 100644 --- a/tests/phpunit/Helper.php +++ b/tests/phpunit/Helper.php @@ -1,15 +1,15 @@ assertInstanceOf('App\Model\Email', $email); + $this->assertInstanceOf('PHPMinds\Model\Email', $email); } /** - * @expectedException App\Exception\Model\InvalidEmailException + * @expectedException PHPMinds\Exception\Model\InvalidEmailException */ public function testInvalidEmailThrowsException() { diff --git a/tests/phpunit/Model/Event/Entity/SpeakerTest.php b/tests/phpunit/Model/Event/Entity/SpeakerTest.php index e2fc6e5..0d83d98 100644 --- a/tests/phpunit/Model/Event/Entity/SpeakerTest.php +++ b/tests/phpunit/Model/Event/Entity/SpeakerTest.php @@ -1,10 +1,10 @@ assertInstanceOf('App\Model\Event\Entity\Speaker', $this->speaker); + $this->assertInstanceOf('PHPMinds\Model\Event\Entity\Speaker', $this->speaker); } public function testCanGetFirstName() diff --git a/tests/phpunit/Model/Event/Entity/SupporterTest.php b/tests/phpunit/Model/Event/Entity/SupporterTest.php index 4c15996..f809a95 100644 --- a/tests/phpunit/Model/Event/Entity/SupporterTest.php +++ b/tests/phpunit/Model/Event/Entity/SupporterTest.php @@ -1,10 +1,10 @@ assertInstanceOf('App\Model\Event\Entity\Supporter', $this->supporter); + $this->assertInstanceOf('PHPMinds\Model\Event\Entity\Supporter', $this->supporter); } public function testGetSupporterName() @@ -36,7 +36,7 @@ public function testGetSupporterName() } /** - * @expectedException App\Exception\Model\InvalidTwitterHandleException + * @expectedException PHPMinds\Exception\Model\InvalidTwitterHandleException */ public function testCreateInstanceWithNullTwitterThrowsException() { diff --git a/tests/phpunit/Model/Event/Entity/TalkTest.php b/tests/phpunit/Model/Event/Entity/TalkTest.php index ba86315..8d2d0b3 100644 --- a/tests/phpunit/Model/Event/Entity/TalkTest.php +++ b/tests/phpunit/Model/Event/Entity/TalkTest.php @@ -1,12 +1,12 @@ speaker ); - $this->assertInstanceOf('App\Model\Event\Entity\Talk', $talk); + $this->assertInstanceOf('PHPMinds\Model\Event\Entity\Talk', $talk); } } \ No newline at end of file diff --git a/tests/phpunit/Model/JoindinEventTest.php b/tests/phpunit/Model/JoindinEventTest.php index 4519a05..8aa1e70 100644 --- a/tests/phpunit/Model/JoindinEventTest.php +++ b/tests/phpunit/Model/JoindinEventTest.php @@ -1,13 +1,13 @@ $joindin['key'], 'baseUrl' => $joindin['baseUrl'], 'frontendBaseUrl' => $joindin['frontendBaseUrl'], @@ -33,7 +33,7 @@ public function setUp() 'username' => $joindin['username'] ]); - $fileRepository = new \App\Repository\FileRepository( + $fileRepository = new \PHPMinds\Repository\FileRepository( $settings['settings']['file_store']['path'] ); diff --git a/tests/phpunit/Model/MeetupEventTest.php b/tests/phpunit/Model/MeetupEventTest.php index 48614ff..81e054b 100644 --- a/tests/phpunit/Model/MeetupEventTest.php +++ b/tests/phpunit/Model/MeetupEventTest.php @@ -1,11 +1,11 @@ $meetup['apiKey'], 'baseUrl' => $meetup['baseUrl'], @@ -33,7 +33,7 @@ public function setUp() ] ); - $this->meetupEvent = new \App\Model\MeetupEvent($meetupConfig); + $this->meetupEvent = new \PHPMinds\Model\MeetupEvent($meetupConfig); $this->event = $this->getEvent(); } diff --git a/tests/phpunit/Model/TwitterTest.php b/tests/phpunit/Model/TwitterTest.php index f063024..577da1d 100644 --- a/tests/phpunit/Model/TwitterTest.php +++ b/tests/phpunit/Model/TwitterTest.php @@ -1,9 +1,9 @@ assertInstanceOf('App\Model\Twitter', $twitter); + $this->assertInstanceOf('PHPMinds\Model\Twitter', $twitter); } /** - * @expectedException App\Exception\Model\InvalidTwitterHandleException + * @expectedException PHPMinds\Exception\Model\InvalidTwitterHandleException */ public function testInvalidTwitterHandleThrowsException() { @@ -24,7 +24,7 @@ public function testInvalidTwitterHandleThrowsException() } /** - * @expectedException App\Exception\Model\InvalidTwitterHandleException + * @expectedException PHPMinds\Exception\Model\InvalidTwitterHandleException */ public function testTooLongTwitterHandleThrowsException() { diff --git a/tests/phpunit/Service/ContentServiceTest.php b/tests/phpunit/Service/ContentServiceTest.php index 0047803..8f0f2e5 100644 --- a/tests/phpunit/Service/ContentServiceTest.php +++ b/tests/phpunit/Service/ContentServiceTest.php @@ -1,8 +1,8 @@ service = new EventsService( new \GuzzleHttp\Client(), - new \App\Model\MeetupEvent($meetup['apiKey'], $meetup['baseUrl'], $meetup['publish_status'], $meetup['PHPMinds']['group_urlname']), - new \App\Model\JoindinEvent($joindin['key'], $joindin['baseUrl'], $joindin['frontendBaseUrl'], $joindin['callback'], $joindin['token']), - new \App\Repository\EventsRepository( - new \App\Model\Db ( + new \PHPMinds\Model\MeetupEvent($meetup['apiKey'], $meetup['baseUrl'], $meetup['publish_status'], $meetup['PHPMinds']['group_urlname']), + new \PHPMinds\Model\JoindinEvent($joindin['key'], $joindin['baseUrl'], $joindin['frontendBaseUrl'], $joindin['callback'], $joindin['token']), + new \PHPMinds\Repository\EventsRepository( + new \PHPMinds\Model\Db ( 'mysql:host=' . $db['host'] . ';dbname=' . $db['dbname'], $db['username'], $db['password'] ) )