return 1;
}
} else {
- $users = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findAll();
+ $users = $this->get('wallabag_user.user_repository')->findAll();
$output->writeln(sprintf('Cleaning through %d user accounts', count($users)));
private function cleanDuplicates(User $user)
{
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
- $repo = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
+ $repo = $this->get('wallabag_core.entry_repository');
$entries = $repo->getAllEntriesIdAndUrl($user->getId());
*/
private function getUser($username)
{
- return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
+ return $this->get('wallabag_user.user_repository')->findOneByUserName($username);
}
private function getDoctrine()
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
- $user = $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($input->getArgument('username'));
+ $user = $this->get('wallabag_user.user_repository')->findOneByUserName($input->getArgument('username'));
} catch (NoResultException $e) {
$output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username')));
return 1;
}
- $entries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
+ $entries = $this->get('wallabag_core.entry_repository')
->getBuilderForAllByUser($user->getId())
->getQuery()
->getResult();
*/
private function getUser($username)
{
- return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
+ return $this->get('wallabag_user.user_repository')->findOneByUserName($username);
}
private function getDoctrine()
*/
private function getUser($username)
{
- return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
+ return $this->get('wallabag_user.user_repository')->findOneByUserName($username);
}
private function getDoctrine()
],
'twofactor_auth' => $this->getParameter('twofactor_auth'),
'wallabag_url' => $this->getParameter('domain_name'),
- 'enabled_users' => $this->getDoctrine()
- ->getRepository('WallabagUserBundle:User')
+ 'enabled_users' => $this->get('wallabag_user.user_repository')
->getSumEnabledUsers(),
]);
}
// manually remove tags to avoid orphan tag
$this->removeAllTagsByUserId($this->getUser()->getId());
- $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->removeAllByUserId($this->getUser()->getId());
+ $this->get('wallabag_core.entry_repository')->removeAllByUserId($this->getUser()->getId());
break;
case 'archived':
if ($this->get('doctrine')->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
// manually remove tags to avoid orphan tag
$this->removeTagsForArchivedByUserId($this->getUser()->getId());
- $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->removeArchivedByUserId($this->getUser()->getId());
+ $this->get('wallabag_core.entry_repository')->removeArchivedByUserId($this->getUser()->getId());
break;
}
return;
}
- $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
+ $this->get('wallabag_core.entry_repository')
->removeTags($userId, $tags);
// cleanup orphan tags
*/
private function removeAllTagsByUserId($userId)
{
- $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($userId);
+ $tags = $this->get('wallabag_core.tag_repository')->findAllTags($userId);
$this->removeAllTagsByStatusAndUserId($tags, $userId);
}
*/
private function removeTagsForArchivedByUserId($userId)
{
- $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findForArchivedArticlesByUser($userId);
+ $tags = $this->get('wallabag_core.tag_repository')->findForArchivedArticlesByUser($userId);
$this->removeAllTagsByStatusAndUserId($tags, $userId);
}
*/
public function deleteAccountAction(Request $request)
{
- $enabledUsers = $this->getDoctrine()
- ->getRepository('WallabagUserBundle:User')
+ $enabledUsers = $this->get('wallabag_user.user_repository')
->getSumEnabledUsers();
if ($enabledUsers <= 1) {
{
$method = ucfirst($category);
$methodBuilder = 'getBuilderFor'.$method.'ByUser';
+ $epository = $this->get('wallabag_core.entry_repository');
if ($category == 'tag_entries') {
- $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneBySlug($request->query->get('tag'));
+ $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
- $entries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findAllByTagId($this->getUser()->getId(), $tag->getId());
+ $entries = $epository->findAllByTagId(
+ $this->getUser()->getId(),
+ $tag->getId()
+ );
} else {
- $entries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
+ $entries = $epository
->$methodBuilder($this->getUser()->getId())
->getQuery()
->getResult();
*/
private function showEntries($type, User $user, $page = 1)
{
- $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
+ $repository = $this->get('wallabag_core.entry_repository');
switch ($type) {
case 'starred':
*/
public function showTagAction()
{
- $tags = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Tag')
+ $repository = $this->get('wallabag_core.entry_repository');
+ $tags = $this->get('wallabag_core.tag_repository')
->findAllTags($this->getUser()->getId());
$flatTags = [];
foreach ($tags as $tag) {
- $nbEntries = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag->getId());
+ $nbEntries = $repository->countAllEntriesByUserIdAndTagId(
+ $this->getUser()->getId(),
+ $tag->getId()
+ );
$flatTags[] = [
'id' => $tag->getId(),
*/
public function showEntriesForTagAction(Tag $tag, $page, Request $request)
{
- $entriesByTag = $this->getDoctrine()
- ->getRepository('WallabagCoreBundle:Entry')
- ->findAllByTagId($this->getUser()->getId(), $tag->getId());
+ $entriesByTag = $this->get('wallabag_core.entry_repository')->findAllByTagId(
+ $this->getUser()->getId(),
+ $tag->getId()
+ );
$pagerAdapter = new ArrayAdapter($entriesByTag);