Esempio n. 1
0
 public function updateAllAction()
 {
     $this->before();
     $sources = $this->sourceRepository->findAllActiveWithUri();
     $result = array();
     foreach ($sources as $source) {
         if (isset($source['uri'])) {
             $result[] = $this->fetchSource($source);
         }
     }
     // output updated sources
     $this->renderJson($result);
 }
Esempio n. 2
0
use Nogo\Feedbox\Repository\Source;
use Nogo\Feedbox\Repository\Tag;
define('ROOT_DIR', dirname(__FILE__));
require ROOT_DIR . '/vendor/autoload.php';
// load API config
$configLoader = new ConfigLoader(ROOT_DIR . '/src/Nogo/Feedbox/Resources/config/default.yml', ROOT_DIR . '/data/config.yml');
$config = $configLoader->getConfig();
// database connection with pdo
$connector = new DatabaseConnector($config['database_adapter'], $config['database_dsn'], $config['database_username'], $config['database_password']);
$connection = $connector->getInstance();
// create repositories
$sourceRepository = new Source($connection);
$tagRepository = new Tag($connection);
$itemRepository = new Item($connection);
// fetch active sources with uri
$sources = $sourceRepository->findAllActiveWithUri();
// get the feed runner
$defaultWorkerClass = $config['worker.default'];
$sanitizer = new \Nogo\Feedbox\Helper\HtmlPurifierSanitizer();
$fetcher = new Fetcher();
$fetcher->setClient(new Client());
$fetcher->setTimeout($config['fetcher.timeout']);
$now = new \DateTime();
$user_id = null;
foreach ($sources as $source) {
    $error = false;
    if (!empty($source['uri'])) {
        $user_id = $source['user_id'];
        // periodic update
        if ($source['last_update'] != null) {
            $last_update = new \DateTime($source['last_update']);