Example #1
0
 public function getRepository(AbstractConnection $connection = null)
 {
     if ($this->repository == null) {
         if ($connection == null) {
             $connection = $this->app->db;
         }
         $this->repository = new SourceRepository($connection);
         $this->repository->setUserScope($this->app->user['id']);
     }
     return $this->repository;
 }
Example #2
0
 protected function before()
 {
     $this->sourceRepository->setUserScope($this->app->user['id']);
     $this->tagRepository->setUserScope($this->app->user['id']);
     $this->itemRepository->setUserScope($this->app->user['id']);
 }
Example #3
0
             }
             $source['last_update'] = date('Y-m-d H:i:s');
             if (empty($source['period'])) {
                 $source['period'] = $worker->getUpdateInterval();
             }
         }
         $source['errors'] = $worker->getErrors();
     } else {
         $error = true;
         $source['errors'] = $fetcher->getError();
     }
 }
 // update source unread counter
 $count = $source['unread'];
 $source['unread'] = $itemRepository->countSourceUnread([$source['id']]);
 $sourceRepository->setUserScope($user_id);
 $sourceRepository->persist($source);
 // update tag unread counter
 if (!empty($source['tag_id'])) {
     $tag = $tagRepository->find($source['tag_id']);
     if ($tag) {
         $tag['unread'] = $sourceRepository->countTagUnread([$tag['id']]);
         $tagRepository->setUserScope($user_id);
         $tagRepository->persist($tag);
     }
 }
 if ($config['debug']) {
     if ($error) {
         echo sprintf("%s\n", $source['errors']);
     } else {
         echo sprintf("%d new items.\n", abs($source['unread'] - $count));