Passed
Pull Request — master (#81)
by
unknown
03:43
created

WishlistExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\Twig;
12
13
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
14
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface;
15
use http\Env\Response;
16
use Twig\Extension\AbstractExtension;
17
use Twig\TwigFunction;
18
19
class WishlistExtension extends AbstractExtension
20
{
21
    private WishlistRepositoryInterface $wishlistRepository;
22
23
    public function __construct(
24
25
        WishlistRepositoryInterface $wishlistRepository
26
    ) {
27
        $this->wishlistRepository = $wishlistRepository;
28
    }
29
30
    public function getFunctions()
31
    {
32
        return [
33
            new TwigFunction('getWishlists', [$this, 'getWishlists']),
34
        ];
35
    }
36
37
    public function getWishlists()
38
    {
39
        /** @var WishlistInterface $wishlists */
40
        $wishlists = $this->wishlistRepository->findAll();
41
42
        return $wishlists;
43
    }
44
}