Skip to content

Commit

Permalink
Move open-platform handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyoung committed Jun 9, 2017
1 parent 7685db9 commit 5d4b6ac
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 191 deletions.
39 changes: 0 additions & 39 deletions src/Applications/OpenPlatform/EventHandlers/Authorized.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/Applications/OpenPlatform/EventHandlers/EventHandler.php

This file was deleted.

39 changes: 0 additions & 39 deletions src/Applications/OpenPlatform/EventHandlers/Unauthorized.php

This file was deleted.

39 changes: 0 additions & 39 deletions src/Applications/OpenPlatform/EventHandlers/UpdateAuthorized.php

This file was deleted.

23 changes: 23 additions & 0 deletions src/Applications/OpenPlatform/Server/Handlers/Authorized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Applications\OpenPlatform\Server\Handlers;

class Authorized extends EventHandler
{
/**
* {@inheritdoc}.
*/
public function handle($message)
{
// Do nothing for the time being.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,7 @@
* with this source code in the file LICENSE.
*/

/**
* ComponentVerifyTicket.php.
*
* Part of Overtrue\WeChat.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author mingyoung <[email protected]>
* @author lixiao <[email protected]>
* @copyright 2016
*
* @see https://github.com/overtrue
* @see http://overtrue.me
*/

namespace EasyWeChat\Applications\OpenPlatform\EventHandlers;
namespace EasyWeChat\Applications\OpenPlatform\Server\Handlers;

use EasyWeChat\Applications\OpenPlatform\Core\VerifyTicket;

Expand Down
22 changes: 22 additions & 0 deletions src/Applications/OpenPlatform/Server/Handlers/EventHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Applications\OpenPlatform\Server\Handlers;

abstract class EventHandler
{
/**
* Handle an incoming event message from WeChat server-side.
*
* @param \EasyWeChat\Support\Collection $message
*/
abstract public function handle($message);
}
23 changes: 23 additions & 0 deletions src/Applications/OpenPlatform/Server/Handlers/Unauthorized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Applications\OpenPlatform\Server\Handlers;

class Unauthorized extends EventHandler
{
/**
* {@inheritdoc}.
*/
public function handle($message)
{
// Do nothing for the time being.
}
}
23 changes: 23 additions & 0 deletions src/Applications/OpenPlatform/Server/Handlers/UpdateAuthorized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Applications\OpenPlatform\Server\Handlers;

class UpdateAuthorized extends EventHandler
{
/**
* {@inheritdoc}
*/
public function handle($message)
{
// Do nothing for the time being.
}
}
13 changes: 13 additions & 0 deletions src/Applications/OpenPlatform/Server/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public function register(Container $container)
);
};

$container['open_platform.handlers.component_verify_ticket'] = function ($container) {
return new Handlers\ComponentVerifyTicket($container['open_platform.verify_ticket']);
};
$container['open_platform.handlers.authorized'] = function () {
return new Handlers\Authorized();
};
$container['open_platform.handlers.updateauthorized'] = function () {
return new Handlers\UpdateAuthorized();
};
$container['open_platform.handlers.unauthorized'] = function () {
return new Handlers\Unauthorized();
};

$container['open_platform.server'] = function ($container) {
$server = new Guard($container['config']['open_platform']['token']);
$server->debug($container['config']['debug']);
Expand Down
14 changes: 0 additions & 14 deletions src/Applications/OpenPlatform/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,6 @@ public function register(Container $container)
);
};

// Authorization events handlers.
$container['open_platform.handlers.component_verify_ticket'] = function ($container) {
return new EventHandlers\ComponentVerifyTicket($container['open_platform.verify_ticket']);
};
$container['open_platform.handlers.authorized'] = function () {
return new EventHandlers\Authorized();
};
$container['open_platform.handlers.updateauthorized'] = function () {
return new EventHandlers\UpdateAuthorized();
};
$container['open_platform.handlers.unauthorized'] = function () {
return new EventHandlers\Unauthorized();
};

$container['open_platform.app'] = function ($container) {
return new Application($container['config']->toArray());
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Doctrine\Common\Cache\ArrayCache;
use EasyWeChat\Applications\OpenPlatform\Core\VerifyTicket;
use EasyWeChat\Applications\OpenPlatform\EventHandlers\ComponentVerifyTicket;
use EasyWeChat\Applications\OpenPlatform\Server\Handlers\ComponentVerifyTicket;
use EasyWeChat\Support\Collection;
use EasyWeChat\Tests\TestCase;

Expand Down
8 changes: 4 additions & 4 deletions tests/OpenPlatform/GuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public function testGetHandler()
$server = $this->make();

$handlers = [
Guard::EVENT_AUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\EventHandlers\Authorized',
Guard::EVENT_UNAUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\EventHandlers\Unauthorized',
Guard::EVENT_UPDATE_AUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\EventHandlers\UpdateAuthorized',
Guard::EVENT_COMPONENT_VERIFY_TICKET => 'EasyWeChat\Applications\OpenPlatform\EventHandlers\ComponentVerifyTicket',
Guard::EVENT_AUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\Server\Handlers\Authorized',
Guard::EVENT_UNAUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\Server\Handlers\Unauthorized',
Guard::EVENT_UPDATE_AUTHORIZED => 'EasyWeChat\Applications\OpenPlatform\Server\Handlers\UpdateAuthorized',
Guard::EVENT_COMPONENT_VERIFY_TICKET => 'EasyWeChat\Applications\OpenPlatform\Server\Handlers\ComponentVerifyTicket',
];

foreach ($handlers as $type => $handler) {
Expand Down

0 comments on commit 5d4b6ac

Please sign in to comment.