Skip to content

Commit

Permalink
修正: 兼容到laravel5.5以下版本
Browse files Browse the repository at this point in the history
  • Loading branch information
feeloho committed Nov 2, 2018
1 parent 9dc0048 commit 5dfd63e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 78 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
],
"require": {
"php": ">=5.5.9",
"laravel/framework": ">=5.1 <5.6",
"ext-pdo": "*"
"laravel/framework": ">=5.1 <=5.4"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Events/EnsureCleanUpExecuted.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace feeloho\MultiServerEvent\Events;
namespace Feeloho\MultiServerEvent\Events;

use Illuminate\Queue\SerializesModels;
/**
Expand Down
61 changes: 0 additions & 61 deletions src/Scheduling/CacheMutex.php

This file was deleted.

13 changes: 6 additions & 7 deletions src/Scheduling/Event.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php
namespace feeloho\MultiServerEvent\Scheduling;
namespace Feeloho\MultiServerEvent\Scheduling;

use Carbon\Carbon;
use Illuminate\Console\Scheduling\CacheMutex;
use Illuminate\Console\Scheduling\Event as NativeEvent;
use Illuminate\Support\Facades\Cache;
use feeloho\MultiServerEvent\Events\EnsureCleanUpExecuted;
use Illuminate\Contracts\Cache\Repository as Cache;
use Feeloho\MultiServerEvent\Events\EnsureCleanUpExecuted;

class Event extends NativeEvent
{
Expand All @@ -26,13 +25,13 @@ class Event extends NativeEvent
/**
* 创建事件实例
*
* @param CacheMutex $cacheMutex
* @param Cache $cache
* @param string $command
* @throws \RuntimeException
*/
public function __construct(CacheMutex $cacheMutex, $command)
public function __construct(Cache $cache, $command)
{
parent::__construct($cacheMutex, $command);
parent::__construct($cache, $command);
$this->key = $this->getKey();
$this->then(function() {
$this->clearMultiserver();
Expand Down
2 changes: 1 addition & 1 deletion src/Scheduling/Mutex.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace feeloho\MultiServerEvent\Scheduling;
namespace Feeloho\MultiServerEvent\Scheduling;

interface Mutex
{
Expand Down
8 changes: 4 additions & 4 deletions src/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
namespace feeloho\MultiServerEvent\Scheduling;
namespace Feeloho\MultiServerEvent\Scheduling;

use Illuminate\Console\Scheduling\CacheMutex;
use Illuminate\Console\Scheduling\Schedule as NativeSchedule;
use Illuminate\Contracts\Cache\Repository as Cache;

class Schedule extends NativeSchedule
{

/**
* Add a new command event to the schedule.
* 添加新的命令
*
* @param string $command
* @param array $parameters
Expand All @@ -19,7 +19,7 @@ public function exec($command, array $parameters = [])
if (count($parameters)) {
$command .= ' '.$this->compileParameters($parameters);
}
$this->events[] = $event = new Event(app()->make(CacheMutex::class), $command);
$this->events[] = $event = new Event(app()->make(Cache::class), $command);
return $event;
}
}
4 changes: 2 additions & 2 deletions tests/MultiServerEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class MultiServerEventTest extends TestCase {
*/
public function it_initializes_the_schedule()
{
$schedule = new feeloho\MultiServerEvent\Scheduling\Schedule(app()[Illuminate\Contracts\Cache\Repository::class]);
$this->assertTrue($schedule instanceof feeloho\MultiServerEvent\Scheduling\Schedule);
$schedule = new Feeloho\MultiServerEvent\Scheduling\Schedule(app()[Illuminate\Contracts\Cache\Repository::class]);
$this->assertTrue($schedule instanceof Feeloho\MultiServerEvent\Scheduling\Schedule);

$result = $schedule->command('inspire')
->daily()
Expand Down

0 comments on commit 5dfd63e

Please sign in to comment.