示例#1
0
文件: Tags.php 项目: nogo/feedbox
 /**
  * Item repository
  *
  * @param AbstractConnection $connection
  *
  * @return TagRepository|Repository
  */
 public function getRepository(AbstractConnection $connection = null)
 {
     if ($this->repository == null) {
         if ($connection == null) {
             $connection = $this->app->db;
         }
         $this->repository = new TagRepository($connection);
         $this->repository->setUserScope($this->app->user['id']);
     }
     return $this->repository;
 }
示例#2
0
文件: update.php 项目: nogo/feedbox
use Nogo\Feedbox\Helper\ConfigLoader;
use Nogo\Feedbox\Helper\DatabaseConnector;
use Nogo\Feedbox\Repository\Item;
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'];