Skip to content

Commit a8385b5

Browse files
authored
Merge pull request #1 from papppeter/make_it_laravel_8_compatible
Make it laravel ^8 compatible
2 parents bff9af6 + b02e8f5 commit a8385b5

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
{
22
"name": "papppeter/yii2-laravel",
3-
"license": "MTI",
3+
"license": "MIT",
4+
"type": "yii2-extension",
5+
"authors": [
6+
{
7+
"name": "Papp Péter",
8+
"email": "[email protected]"
9+
}
10+
],
411
"repositories": [
512

613
],
714
"require": {
8-
"php": ">=7.0"
15+
"php": ">=7.4",
16+
"illuminate/support": "^8.83.11"
917
},
1018
"autoload": {
1119
"psr-4": {
12-
"papppeter\\yii2Laravel\\": ""
20+
"papppeter\\yii2Laravel\\": "src/"
1321
}
1422
}
1523
}

Illuminate/Events/Dispatcher.php renamed to src/Illuminate/Events/Dispatcher.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Dispatcher extends Event {
1919
public function listen($events, $listener)
2020
{
2121
foreach ((array) $events as $event) {
22-
app()->on($event, $listener);
22+
\Yii::$app->on($event, $listener);
2323
}
2424
}
2525

@@ -31,7 +31,7 @@ public function listen($events, $listener)
3131
*/
3232
public function hasListeners($eventName)
3333
{
34-
return app()->hasEventHandlers($eventName);
34+
return \Yii::$app->hasEventHandlers($eventName);
3535
}
3636

3737
/**
@@ -68,7 +68,7 @@ public function until($event, $payload = [])
6868
public function dispatch($event, $payload = [], $halt = false)
6969
{
7070
if($event instanceof Event) {
71-
return app()->trigger($event->name, $event);
71+
return \Yii::$app->trigger($event->name, $event);
7272
}
7373

7474
list($event, $payload) = $this->parseEventAndPayload(
@@ -81,7 +81,7 @@ public function dispatch($event, $payload = [], $halt = false)
8181
$event->sender = $payload[1];
8282
$event->handled = $halt;
8383

84-
return app()->trigger($name, $event);
84+
return \Yii::$app->trigger($name, $event);
8585
}
8686

8787
/**
@@ -115,7 +115,7 @@ public function flush($event)
115115
*/
116116
public function forget($event)
117117
{
118-
app()->off($event);
118+
\Yii::$app->off($event);
119119
}
120120

121121
/**

Illuminate/Session/Store.php renamed to src/Illuminate/Session/Store.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Illuminate\Contracts\Session\Session;
55
use Illuminate\Support\Arr;
6+
use yii\base\NotSupportedException;
67

78
/**
89
*
@@ -166,7 +167,6 @@ public function getHandler()
166167
public function handlerNeedsRequest()
167168
{
168169
return false;
169-
// return $this->handler instanceof CookieSessionHandler;
170170
}
171171

172172
/**
@@ -181,4 +181,29 @@ public function setRequestOnHandler($request)
181181
$this->handler->setRequest($request);
182182
}
183183
}
184+
185+
public function pull($key, $default = null)
186+
{
187+
$value = $this->get($key, $default);
188+
$this->offsetUnset($key);
189+
return $value;
190+
}
191+
192+
public function regenerateToken()
193+
{
194+
throw new NotSupportedException("pull is not supported.");
195+
}
196+
197+
public function invalidate()
198+
{
199+
$success = $this->getIsActive();
200+
$this->destroy();
201+
return $success;
202+
}
203+
204+
public function regenerate($destroy = false)
205+
{
206+
$this->regenerateID($destroy);
207+
return $this->getId();
208+
}
184209
}

0 commit comments

Comments
 (0)