* initial commit

This commit is contained in:
Dávid Danyi
2017-02-17 15:48:05 +01:00
commit ed29fb7f97
48 changed files with 6008 additions and 0 deletions

2
config/autoload/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
local.php
*.local.php

View File

@@ -0,0 +1,28 @@
<?php
use Zend\Expressive\Application;
use Zend\Expressive\Container\ApplicationFactory;
use Zend\Expressive\Helper;
return [
// Provides application-wide services.
// We recommend using fully-qualified class names whenever possible as
// service names.
'dependencies' => [
// Use 'invokables' for constructor-less services, or services that do
// not require arguments to the constructor. Map a service name to the
// class name.
'invokables' => [
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
Helper\ServerUrlHelper::class => Helper\ServerUrlHelper::class,
],
// Use 'factories' for services provided by callbacks/factory classes.
'factories' => [
Application::class => ApplicationFactory::class,
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
'doctrine.entity_manager.orm_default' => \ContainerInteropDoctrine\EntityManagerFactory::class,
'doctrine.hydrator' => \App\Hydrator\DoctrineObjectFactory::class,
\App\Service\CiConfigService::class => \App\Service\CiConfigServiceFactory::class,
],
],
];

View File

@@ -0,0 +1,68 @@
<?php
return [
'doctrine' => [
'driver' => [
'orm_default' => [
'class' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
'drivers' => [
'App\Entity' => 'my_entity',
],
],
'my_entity' => [
'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class,
'cache' => 'array',
'paths' => __DIR__ . '/../../src/App/Entity',
],
],
'configuration' => [
'orm_default' => [
// 'datetime_functions' => [
// 'date' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'time' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'timestamp' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'convert_tz' => Oro\ORM\Query\AST\Functions\DateTime\ConvertTz::class,
// ],
'numeric_functions' => [
// 'timestampdiff' => Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff::class,
// 'dayofyear' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'dayofmonth' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'dayofweek' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'week' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'day' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'hour' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'minute' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'month' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'quarter' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'second' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'year' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'sign' => Oro\ORM\Query\AST\Functions\Numeric\Sign::class,
// 'pow' => Oro\ORM\Query\AST\Functions\Numeric\Pow::class,
],
// 'string_functions' => [
// 'md5' => Oro\ORM\Query\AST\Functions\SimpleFunction::class,
// 'group_concat' => Oro\ORM\Query\AST\Functions\String\GroupConcat::class,
// 'cast' => Oro\ORM\Query\AST\Functions\Cast::class,
// 'concat_ws' => Oro\ORM\Query\AST\Functions\String\ConcatWs::class
// ]
// 'filters' => [
// 'soft-deleteable' => Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter::class,
// ],
],
],
'event_manager' => [
'orm_default' => [
'subscribers' => [
// Gedmo\Timestampable\TimestampableListener::class,
// 'Gedmo\Tree\TreeListener',
// 'Gedmo\SoftDeleteable\SoftDeleteableListener',
// 'Gedmo\Translatable\TranslatableListener',
// 'Gedmo\Blameable\BlameableListener',
// 'Gedmo\Loggable\LoggableListener',
// 'Gedmo\Sortable\SortableListener',
// 'Gedmo\Sluggable\SluggableListener',
],
],
],
],
];

View File

@@ -0,0 +1,14 @@
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'params' => [
'url' => 'mysqli://user:passwd@host/database',
'charset' => 'UTF8',
],
],
],
],
];

View File

@@ -0,0 +1,7 @@
<?php
return [
'debug' => true,
'config_cache_enabled' => false,
];

View File

@@ -0,0 +1,70 @@
<?php
use Zend\Expressive\Container\ApplicationFactory;
use Zend\Expressive\Helper;
return [
'dependencies' => [
'factories' => [
Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class,
Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class,
],
],
// This can be used to seed pre- and/or post-routing middleware
'middleware_pipeline' => [
// An array of middleware to register. Each item is of the following
// specification:
//
// [
// Required:
// 'middleware' => 'Name or array of names of middleware services and/or callables',
// Optional:
// 'path' => '/path/to/match', // string; literal path prefix to match
// // middleware will not execute
// // if path does not match!
// 'error' => true, // boolean; true for error middleware
// 'priority' => 1, // int; higher values == register early;
// // lower/negative == register last;
// // default is 1, if none is provided.
// ],
//
// While the ApplicationFactory ignores the keys associated with
// specifications, they can be used to allow merging related values
// defined in multiple configuration files/locations. This file defines
// some conventional keys for middleware to execute early, routing
// middleware, and error middleware.
'always' => [
'middleware' => [
// Add more middleware here that you want to execute on
// every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses
Helper\ServerUrlMiddleware::class,
\App\Middleware\PreFlightMiddleware::class,
],
'priority' => 10000,
],
'routing' => [
'middleware' => [
ApplicationFactory::ROUTING_MIDDLEWARE,
Helper\UrlHelperMiddleware::class,
// Add more middleware here that needs to introspect the routing
// results; this might include:
// - route-based authentication
// - route-based validation
// - etc.
ApplicationFactory::DISPATCH_MIDDLEWARE,
],
'priority' => 1,
],
'error' => [
'middleware' => [
// Add error middleware here.
],
'error' => true,
'priority' => -10000,
],
],
];

View File

@@ -0,0 +1,55 @@
<?php
return [
'dependencies' => [
'invokables' => [
Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\FastRouteRouter::class,
App\Action\PingAction::class => App\Action\PingAction::class,
],
'factories' => [
App\Action\CiConfigAction::class => App\Action\CiConfigFactory::class,
App\Action\CiConfigItemAction::class => App\Action\CiConfigItemFactory::class,
App\Action\HomePageAction::class => App\Action\HomePageFactory::class,
],
],
'routes' => [
[
'name' => 'home',
'path' => '/',
'middleware' => App\Action\HomePageAction::class,
'allowed_methods' => ['GET'],
],
[
'name' => 'api.ping',
'path' => '/api/ping',
'middleware' => App\Action\PingAction::class,
'allowed_methods' => ['GET'],
],
[
'name' => 'api.ci-config',
'path' => '/api/ci-config',
'middleware' => App\Action\CiConfigAction::class,
'allowed_methods' => ['GET','POST'],
],
[
'name' => 'api.ci-config-id',
'path' => '/api/ci-config/{id:\d+}',
'middleware' => App\Action\CiConfigAction::class,
'allowed_methods' => ['GET','DELETE'],
],
// [
// 'name' => 'api.ci-config-item',
// 'path' => '/api/ci-config-item',
// 'middleware' => App\Action\CiConfigItemAction::class,
// 'allowed_methods' => ['GET','POST'],
// ],
[
'name' => 'api.ci-config-item-id',
'path' => '/api/ci-config-item/{id:\d+}',
'middleware' => App\Action\CiConfigItemAction::class,
'allowed_methods' => ['DELETE'],
// 'allowed_methods' => ['GET','DELETE'],
],
],
];

View File

@@ -0,0 +1,14 @@
<?php
return [
'debug' => false,
'config_cache_enabled' => false,
'zend-expressive' => [
'error_handler' => [
'template_404' => 'error::404',
'template_error' => 'error::error',
],
],
];

35
config/config.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\Glob;
/**
* Configuration files are loaded in a specific order. First ``global.php``, then ``*.global.php``.
* then ``local.php`` and finally ``*.local.php``. This way local settings overwrite global settings.
*
* The configuration can be cached. This can be done by setting ``config_cache_enabled`` to ``true``.
*
* Obviously, if you use closures in your config you can't cache it.
*/
$cachedConfigFile = 'data/cache/app_config.php';
$config = [];
if (is_file($cachedConfigFile)) {
// Try to load the cached config
$config = include $cachedConfigFile;
} else {
// Load configuration from autoload path
foreach (Glob::glob('config/autoload/{{,*.}global,{,*.}local}.php', Glob::GLOB_BRACE) as $file) {
$config = ArrayUtils::merge($config, include $file);
}
// Cache config if enabled
if (isset($config['config_cache_enabled']) && $config['config_cache_enabled'] === true) {
file_put_contents($cachedConfigFile, '<?php return ' . var_export($config, true) . ';');
}
}
// Return an ArrayObject so we can inject the config as a service in Aura.Di
// and still use array checks like ``is_array``.
return new ArrayObject($config, ArrayObject::ARRAY_AS_PROPS);

16
config/container.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
use Zend\ServiceManager\Config;
use Zend\ServiceManager\ServiceManager;
// Load configuration
$config = require __DIR__ . '/config.php';
// Build container
$container = new ServiceManager();
(new Config($config['dependencies']))->configureServiceManager($container);
// Inject config
$container->setService('config', $config);
return $container;