/var/www/html/wp-content/plugins/woocommerce/lib/packages/League/Container/ContainerAwareTrait.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php declare(strict_types=1);

namespace 
Automattic\WooCommerce\Vendor\League\Container;

use 
Automattic\WooCommerce\Vendor\League\Container\Exception\ContainerException;
use 
Automattic\WooCommerce\Vendor\Psr\Container\ContainerInterface;

trait 
ContainerAwareTrait
{
    
/**
     * @var ContainerInterface
     */
    
protected $container;

    
/**
     * @var Container
     */
    
protected $leagueContainer;

    
/**
     * Set a container.
     *
     * @param ContainerInterface $container
     *
     * @return ContainerAwareInterface
     */
    
public function setContainer(ContainerInterface $container) : ContainerAwareInterface
    
{
        
$this->container $container;

        return 
$this;
    }

    
/**
     * Get the container.
     *
     * @return ContainerInterface
     */
    
public function getContainer() : ContainerInterface
    
{
        if (
$this->container instanceof ContainerInterface) {
            return 
$this->container;
        }

        throw new 
ContainerException('No container implementation has been set.');
    }

    
/**
     * Set a container.
     *
     * @param Container $container
     *
     * @return self
     */
    
public function setLeagueContainer(Container $container) : ContainerAwareInterface
    
{
        
$this->container $container;
        
$this->leagueContainer $container;

        return 
$this;
    }

    
/**
     * Get the container.
     *
     * @return Container
     */
    
public function getLeagueContainer() : Container
    
{
        if (
$this->leagueContainer instanceof Container) {
            return 
$this->leagueContainer;
        }

        throw new 
ContainerException('No container implementation has been set.');
    }
}