ja.son-williams.ca/www/plugins/jasonwilliams/feed/controllers/Feed.php
Jason Williams 2026e4a872 Closing #47 with completed manual trigger for social updates.
Moving update/import functionality back to the feed controller (removing the import controller previously created), added an option to the backend that triggers the update from the custom SocialApis class.
2020-12-30 20:05:29 -07:00

58 lines
1.3 KiB
PHP

<?php namespace jasonwilliams\feed\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
use JasonWilliams\Feed\Classes\SocialApis;
class Feed extends Controller
{
public $implement = [
'Backend\Behaviors\ListController',
'Backend\Behaviors\FormController'
];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('jasonwilliams.feed', 'main-menu-item');
}
public function import()
{
$this->pageTitle = 'Fetch posts';
}
public function onImportTwitter()
{
SocialApis::updateTwitter();
return $this->makePartial('import', [
'importType' => 'Twitter',
'content' => 'Done'
]);
}
public function onImportInstagram()
{
SocialApis::updateInstagram();
return $this->makePartial('import', [
'importType' => 'Instagram',
'content' => 'Done'
]);
}
public function onImportFoursquare()
{
SocialApis::updateFoursquare();
return $this->makePartial('import', [
'importType' => 'Foursquare',
'content' => 'Done'
]);
}
}