Skip to content

Commit

Permalink
Merge 60cbb73 into 212e6c2
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Nov 14, 2018
2 parents 212e6c2 + 60cbb73 commit 7e36e90
Show file tree
Hide file tree
Showing 18 changed files with 476 additions and 281 deletions.
3 changes: 1 addition & 2 deletions src/App/DataSource/CallbackDataSource.php
Expand Up @@ -12,6 +12,5 @@
*/
interface CallbackDataSource extends DataSource
{

public function registerRoutes(\Laravel\Lumen\Routing\Router $router);
public static function registerRoutes(\Laravel\Lumen\Routing\Router $router);
}
7 changes: 4 additions & 3 deletions src/App/DataSource/Console/IncomingCommand.php
Expand Up @@ -63,9 +63,9 @@ public function __construct(DataSourceManager $sources, DataSourceStorage $stora
protected function getSources()
{
if ($source = $this->option('source')) {
$sources = array_filter([$source => $this->sources->getSource($source)]);
$sources = [$source];
} elseif ($this->option('all')) {
$sources = $this->sources->getSource();
$sources = $this->sources->getSources();
} else {
$sources = $this->sources->getEnabledSources();
}
Expand All @@ -79,7 +79,8 @@ public function handle()

$totals = [];

foreach ($sources as $sourceId => $source) {
foreach ($sources as $sourceId) {
$source = $this->sources->getSource($sourceId);
if (!($source instanceof IncomingAPIDataSource)) {
// Data source doesn't have an API we can pull messages from
continue;
Expand Down
7 changes: 4 additions & 3 deletions src/App/DataSource/Console/ListCommand.php
Expand Up @@ -49,9 +49,9 @@ public function __construct(\Ushahidi\App\DataSource\DataSourceManager $sources)
protected function getSources()
{
if ($source = $this->option('source')) {
$sources = array_filter([$source => $this->sources->getSource($source)]);
$sources = [$source];
} elseif ($this->option('all')) {
$sources = $this->sources->getSource();
$sources = $this->sources->getSources();
} else {
$sources = $this->sources->getEnabledSources();
}
Expand All @@ -63,7 +63,8 @@ public function handle()
$sources = $this->getSources();

$list = [];
foreach ($sources as $id => $source) {
foreach ($sources as $id) {
$source = $this->sources->getSource($id);
$list[] = [
'Name' => $source->getName(),
'Services' => implode(', ', $source->getServices()),
Expand Down
13 changes: 7 additions & 6 deletions src/App/DataSource/Console/OutgoingCommand.php
Expand Up @@ -63,15 +63,15 @@ public function __construct(DataSourceManager $sources, DataSourceStorage $stora
protected function getSources()
{
if ($source = $this->option('source')) {
$sources = array_filter([$source => $this->sources->getSource($source)]);
$sources = [$source];
} elseif ($this->option('all')) {
$sources = $this->sources->getSource();
$sources = $this->sources->getSources();
} else {
$sources = $this->sources->getEnabledSources();

// Hack: always include email no matter what!
if (!isset($sources['email'])) {
$sources['email'] = $this->sources->getSource('email');
// Always include outgoingemail
if (!in_array('email', $sources) && !in_array('outgoingemail', $sources)) {
$sources[] = 'outgoingemail';
}
}
return $sources;
Expand All @@ -83,7 +83,8 @@ public function handle()

$totals = [];

foreach ($sources as $id => $source) {
foreach ($sources as $id) {
$source = $this->sources->getSource($id);
if (!($source instanceof OutgoingAPIDataSource)) {
// Data source doesn't have an API we can push messages to
continue;
Expand Down
7 changes: 6 additions & 1 deletion src/App/DataSource/DataSourceController.php
Expand Up @@ -26,8 +26,13 @@ abstract class DataSourceController extends Controller

public function __construct(DataSourceManager $manager, DataSourceStorage $storage)
{
$this->source = $manager->getSource($this->source);
$this->storage = $storage;

try {
$this->source = $manager->getEnabledSource($this->source);
} catch (\InvalidArgumentException $e) {
abort(404);
}
}

abstract public function handleRequest(Request $request);
Expand Down

0 comments on commit 7e36e90

Please sign in to comment.