1 | <?php |
||
19 | class Context |
||
20 | { |
||
21 | /** |
||
22 | * @var \Aimeos\MShop\Context\Item\Iface |
||
23 | */ |
||
24 | private static $context; |
||
25 | |||
26 | /** |
||
27 | * @var \Illuminate\Contracts\Config\Repository |
||
28 | */ |
||
29 | private $config; |
||
30 | |||
31 | /** |
||
32 | * @var \Aimeos\MShop\Locale\Item\Iface |
||
33 | */ |
||
34 | private $locale; |
||
35 | |||
36 | /** |
||
37 | * @var \Illuminate\Session\Store |
||
38 | */ |
||
39 | private $session; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * Initializes the object |
||
44 | * |
||
45 | * @param \Illuminate\Contracts\Config\Repository $config Configuration object |
||
46 | * @param \Illuminate\Session\Store $session Laravel session object |
||
47 | */ |
||
48 | public function __construct( \Illuminate\Contracts\Config\Repository $config, \Illuminate\Session\Store $session ) |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Returns the current context |
||
57 | * |
||
58 | * @param boolean $locale True to add locale object to context, false if not |
||
59 | * @return \Aimeos\MShop\Context\Item\Iface Context object |
||
60 | */ |
||
61 | public function get( $locale = true ) |
||
62 | { |
||
63 | if( self::$context === null ) |
||
64 | { |
||
65 | $context = new \Aimeos\MShop\Context\Item\Standard(); |
||
66 | |||
67 | $config = $this->getConfig(); |
||
68 | $context->setConfig( $config ); |
||
69 | |||
70 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $config ); |
||
71 | $context->setDatabaseManager( $dbm ); |
||
72 | |||
73 | $fs = new \Aimeos\MW\Filesystem\Manager\Laravel( app( 'filesystem' ), $config, storage_path( 'aimeos' ) ); |
||
74 | $context->setFilesystemManager( $fs ); |
||
75 | |||
76 | $mail = new \Aimeos\MW\Mail\Swift( function() { return app( 'mailer' )->getSwiftMailer(); } ); |
||
77 | $context->setMail( $mail ); |
||
78 | |||
79 | $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context ); |
||
80 | $context->setLogger( $logger ); |
||
81 | |||
82 | $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context ); |
||
83 | $context->setCache( $cache ); |
||
84 | |||
85 | self::$context = $context; |
||
86 | } |
||
87 | |||
88 | $context = self::$context; |
||
89 | |||
90 | if( $locale === true ) |
||
91 | { |
||
92 | $localeItem = $this->getLocale( $context ); |
||
93 | $langid = $localeItem->getLanguageId(); |
||
94 | |||
95 | $context->setLocale( $localeItem ); |
||
96 | $context->setI18n( app('\Aimeos\Shop\Base\I18n')->get( array( $langid ) ) ); |
||
97 | } |
||
98 | |||
99 | $session = new \Aimeos\MW\Session\Laravel4( $this->session ); |
||
100 | $context->setSession( $session ); |
||
101 | |||
102 | $this->addUser( $context ); |
||
103 | |||
104 | return $context; |
||
105 | } |
||
106 | |||
107 | |||
108 | /** |
||
109 | * Adds the user ID and name if available |
||
110 | * |
||
111 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
||
112 | */ |
||
113 | protected function addUser( \Aimeos\MShop\Context\Item\Iface $context ) |
||
129 | |||
130 | |||
131 | /** |
||
132 | * Creates a new configuration object. |
||
133 | * |
||
134 | * @return \Aimeos\MW\Config\Iface Configuration object |
||
135 | */ |
||
136 | protected function getConfig() |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Returns the locale item for the current request |
||
153 | * |
||
154 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
||
155 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item object |
||
156 | */ |
||
157 | protected function getLocale( \Aimeos\MShop\Context\Item\Iface $context ) |
||
181 | } |
||
182 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: