Skip to content
This repository was archived by the owner on Aug 2, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
// - `*.global.php`
// - `local.php`
// - `*.local.php`
new PhpFileProvider(realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php'),
new PhpFileProvider(realpath(__DIR__).'/autoload/{{,*.}global,{,*.}local}.php'),

// Load development config if it exists
new PhpFileProvider(realpath(__DIR__) . '/development.config.php'),
new PhpFileProvider(realpath(__DIR__).'/development.config.php'),
], $cacheConfig['config_cache_path']);

return $aggregator->getMergedConfig();
3 changes: 1 addition & 2 deletions config/pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
use Zend\Expressive\Router\Middleware\RouteMiddleware;
use Zend\Stratigility\Middleware\ErrorHandler;


/**
/*
* Setup middleware pipeline:
*/
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
Expand Down
2 changes: 1 addition & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Zend\ServiceManager\Config;
use Zend\ServiceManager\ServiceManager;

/**
/*
* Self-called anonymous function that creates its own scope and keep the global namespace clean.
*/
(function () {
Expand Down
6 changes: 3 additions & 3 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace App;

/**
* The configuration provider for the App module
* The configuration provider for the App module.
*
* @see https://docs.zendframework.com/zend-component-installer/
*/
class ConfigProvider
{
/**
* Returns the configuration array
* Returns the configuration array.
*/
public function __invoke() : array
{
Expand All @@ -22,7 +22,7 @@ public function __invoke() : array
}

/**
* Returns the container dependencies
* Returns the container dependencies.
*/
public function getDependencies() : array
{
Expand Down
11 changes: 6 additions & 5 deletions src/Handler/WebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(ServerRequestInterface $request) : ResponseInterface
$this->signature = $headers['x-hub-signature'][0] ?? '';

if (isset($this->config['token']) && !empty($this->config['token'])) {
$sha1 = hash_hmac('sha1', (string)$request->getBody(), $this->config['token']);
$sha1 = hash_hmac('sha1', (string) $request->getBody(), $this->config['token']);

if (hash_equals('sha1='.$sha1, $this->signature) !== true) {
return new TextResponse('ERROR: Invalid signature!', 401);
Expand All @@ -54,15 +54,17 @@ public function handle(ServerRequestInterface $request) : ResponseInterface
}
}

private function ping() {
private function ping()
{
return new TextResponse('pong');
}

private function push() {
private function push()
{
$repository = $this->payload['repository']['full_name'];
$branch = substr($this->payload['ref'], 11);

$out = 'DELIVERY: '.$this->delivery.PHP_EOL;
$out = 'DELIVERY: '.$this->delivery.PHP_EOL;
$out .= 'BY: '.$this->payload['pusher']['name'].PHP_EOL;
$out .= '--------------------------------------------------'.PHP_EOL;

Expand Down Expand Up @@ -95,7 +97,6 @@ private function push() {
$out .= '--------------------------------------------------'.PHP_EOL;
}


return new TextResponse($out, $status);
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/Middleware/ConfigMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace App\Middleware;

use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ConfigAggregator\PhpFileProvider;
use Zend\ConfigAggregator\ZendConfigProvider;


class ConfigMiddleware implements MiddlewareInterface
{
public const CONFIG_ATTRIBUTE = 'config';
Expand All @@ -24,10 +22,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
];

$config = new ConfigAggregator([
new ZendConfigProvider(realpath(dirname(dirname(__DIR__))) . '/composer.json'),
new ZendConfigProvider(realpath(dirname(dirname(__DIR__))) . '/config/application/*.{php,ini,xml,json,yaml}'),
new ZendConfigProvider(realpath(dirname(dirname(__DIR__))).'/composer.json'),
new ZendConfigProvider(realpath(dirname(dirname(__DIR__))).'/config/application/*.{php,ini,xml,json,yaml}'),
], $cacheConfig['config_cache_path']);

return $handler->handle($request->withAttribute(self::CONFIG_ATTRIBUTE, $config->getMergedConfig()));
}
}
}