Skip to content

Commit

Permalink
Merge pull request #42 from heiglandreas/addSessionize
Browse files Browse the repository at this point in the history
Last touch on Sessionize
  • Loading branch information
heiglandreas authored Feb 3, 2020
2 parents e3e8624 + c081334 commit b1f2971
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/Subcommands/Sessionize/Parser/EntryParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Exception;
use GuzzleHttp\Client;
use InvalidArgumentException;
use Throwable;

class EntryParser
{
Expand All @@ -34,7 +35,7 @@ public function __construct(Cfp $cfp, ServiceContainer $container)
$this->geolocationService = $container->getGeolocationService();
}

public function parse($uri)
public function parse($uri): Cfp
{
$cfp = clone($this->cfp);
try {
Expand Down Expand Up @@ -97,8 +98,12 @@ public function parse($uri)
$cfp->eventEndDate = $cfp->eventStartDate;
}

$iconUri = new IconUri($uri);
$cfp->iconUri = $iconUri->parse($dom, $xpath);
try {
$iconUri = new IconUri($uri);
$cfp->iconUri = $iconUri->parse($dom, $xpath);
} catch (Throwable $e) {
$cfp->iconUri = '';
}

return $cfp;
} catch (Exception $e) {
Expand Down
6 changes: 3 additions & 3 deletions src/Subcommands/Sessionize/Parser/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(DOMDocument $dom, DOMXPath $xpath) : string
if (! $locations || $locations->length == 0) {
throw new \InvalidArgumentException('The Event does not seem to have a location');
}
$location = [];
$locationArray = [];
foreach ($locations as $item) {
$location = trim($item->textContent);
if ($location === '') {
Expand All @@ -37,9 +37,9 @@ public function parse(DOMDocument $dom, DOMXPath $xpath) : string

return $location;

$location[] = $location;
$locationArray[] = $location;
}

return implode(', ', array_unique($location));
return implode(', ', array_unique($locationArray));
}
}
10 changes: 6 additions & 4 deletions src/Subcommands/Sessionize/Parser/Sessionize.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function parse(WriterInterface $writer)
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->load($uri);
$dom->preserveWhiteSpace = false;

$xpath = new DOMXPath($dom);
$nodes = $xpath->query("//url");
$xpath->registerNamespace('x', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$nodes = $xpath->query("//x:url");
if ($nodes->length < 1) {
return $cfpList;
}
Expand All @@ -62,9 +62,11 @@ public function parse(WriterInterface $writer)
}

try {
$cfpList->append($this->parser->parse($loc->textContent));
$cfp = $this->parser->parse($loc->textContent);
$writer->write($cfp, 'Sessionize');
$cfpList->append($cfp);
} catch (\Exception $e) {
error_log($e->getMEssage());
//error_log($e->getMEssage());
}
}

Expand Down

0 comments on commit b1f2971

Please sign in to comment.