* initial commit

This commit is contained in:
Danyi Dávid
2018-11-11 12:01:18 +01:00
commit 17ec066110
165 changed files with 20529 additions and 0 deletions

1
config/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
development.config.php

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

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

View File

@@ -0,0 +1,93 @@
<?php
/**
* Authorization, authentication config
*/
return [
'acl_config' => [
'unguarded_routes' => [
'api.auth.login',
'api.ping',
'api.xlsx',
'show-attachment',
'hibajegy-pdf',
'karbantartasjegy-pdf',
'havi-riport-pdf',
],
'route_guard' => [
'roles' => [
/**
* child role => parents[]
* parentrole has all child roles permissions
* order of roles DO matter, referenced parents MUST exist, so should be defined first
*/
// karbantartó oldal
'uzemeltetesi_vezeto' => [
'ufo',
],
'betekinto' => [
'uzemeltetesi_vezeto',
],
// ügyfél oldal
'karbantarto' => [
'projektvezeto'
],
'user' => [
'betekinto',
'karbantarto',
],
],
'permissions' => [
// 'admin' role has full access
'uzemeltetesi_vezeto' => [
'api.fault.post',
'api.fault.put',
'api.report.post',
'api.fault-attachment.post',
'api.fault-comment.post',
'api.fault-reject.post',
'api.maintenance',
'api.maintenance.upcoming'
],
'ufo' => [
'api.fault.put',
'api.fault-attachment.post',
'api.fault-comment.post',
'api.fault-reject.post',
],
// 'betekinto' => [
// 'api.fault.get',
// ],
'projektvezeto' => [
'api.fault.put',
'api.report.post',
'api.fault-attachment.post',
'api.fault-comment.post',
'api.maintenance',
'api.maintenance.put',
'api.maintenance.upcoming',
],
'karbantarto' => [
],
// anybody logged in has the 'user' meta role, its not assignable otherwise
// api endpoints defined here are accessible to all authenticated users
'user' => [
'api.auth.renew',
'api.user.list',
'api.user.profile',
'api.user.password',
// 'api.settings.post',
'api.error-category.get',
'api.error-origin.get',
'api.facility-location.get',
'api.solution-time-interval.get',
'api.fault.get',
'show-attachment',
],
],
],
],
];

View File

@@ -0,0 +1,19 @@
<?php
return [
'dependencies' => [
'invokables' => [],
'factories' => [
App\Command\InitializeFixtureCommand::class => App\Command\InitializeFixtureCommandFactory::class,
// App\Command\ConvertMaintenanceHashCommand::class => App\Command\ConvertMaintenanceHashCommandFactory::class,
// App\Command\MailTestCommand::class => App\Command\MailTestCommandFactory::class,
],
],
'console' => [
'commands' => [
App\Command\InitializeFixtureCommand::class,
// App\Command\ConvertMaintenanceHashCommand::class,
// App\Command\MailTestCommand::class,
],
],
];

View File

@@ -0,0 +1,43 @@
<?php
use Zend\Expressive\Application;
use Zend\Expressive\Container;
use Zend\Expressive\Delegate;
use Zend\Expressive\Helper;
use Zend\Expressive\Middleware;
return [
// Provides application-wide services.
// We recommend using fully-qualified class names whenever possible as
// service names.
'dependencies' => [
// Use 'aliases' to alias a service name to another service. The
// key is the alias name, the value is the service to which it points.
'aliases' => [
'Zend\Expressive\Delegate\DefaultDelegate' => Delegate\NotFoundDelegate::class,
],
// 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 => Container\ApplicationFactory::class,
Delegate\NotFoundDelegate::class => Container\NotFoundDelegateFactory::class,
Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class,
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class,
Zend\Stratigility\Middleware\ErrorHandler::class => Container\ErrorHandlerFactory::class,
Middleware\ErrorResponseGenerator::class => Container\ErrorResponseGeneratorFactory::class,
Middleware\NotFoundHandler::class => Container\NotFoundHandlerFactory::class,
Slim\Middleware\JwtAuthentication::class => App\Middleware\JwtAuthenticationFactory::class,
Tuupola\Middleware\Cors::class => App\Middleware\CorsMiddlewareFactory::class,
App\Middleware\RouteAuthorization::class => App\Middleware\RouteAuthorizationFactory::class,
],
],
];

View File

@@ -0,0 +1,34 @@
<?php
/**
* Development-only configuration.
*
* Put settings you want enabled when under development mode in this file, and
* check it into your repository.
*
* Developers on your team will then automatically enable them by calling on
* `composer development-enable`.
*/
use Zend\Expressive\Container;
use Zend\Expressive\Middleware\ErrorResponseGenerator;
return [
'dependencies' => [
'invokables' => [
],
'factories' => [
ErrorResponseGenerator::class => Container\WhoopsErrorResponseGeneratorFactory::class,
'Zend\Expressive\Whoops' => Container\WhoopsFactory::class,
'Zend\Expressive\WhoopsPageHandler' => Container\WhoopsPageHandlerFactory::class,
],
],
'whoops' => [
'json_exceptions' => [
'display' => true,
'show_trace' => true,
'ajax_only' => true,
],
],
];

View File

@@ -0,0 +1,74 @@
<?php
return [
'dependencies' => [
'factories' => [
'doctrine.entity_manager.orm_default' => ContainerInteropDoctrine\EntityManagerFactory::class,
'doctrine.hydrator' => App\Hydrator\DoctrineObjectFactory::class,
],
],
'doctrine' => [
'driver' => [
'orm_default' => [
'class' => Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
'drivers' => [
'App\Entity' => 'app_entity',
],
],
'app_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::class,
// Gedmo\SoftDeleteable\SoftDeleteableListener::class,
// Gedmo\Translatable\TranslatableListener::class,
// Gedmo\Blameable\BlameableListener::class,
// Gedmo\Loggable\LoggableListener::class,
// Gedmo\Sortable\SortableListener::class,
// Gedmo\Sluggable\SluggableListener::class,
],
],
],
],
];

View File

@@ -0,0 +1,14 @@
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'params' => [
'url' => 'sqlite:///data/app.db',
'charset' => 'UTF8',
],
],
],
],
];

View File

@@ -0,0 +1,27 @@
<?php
/**
* Local configuration.
*
* Copy this file to `local.php` and change its settings as required.
* `local.php` is ignored by git and safe to use for local and sensitive data like usernames and passwords.
*/
return [
'self' => [
'name' => 'Laterex Üzemeltető Kft.',
'address' => '1095 Budapest, Hídépítő utca 1-12.',
'tax_number' => '25398791-2-43',
'sender' => 'nobody@localhost',
'site-uri' => 'localhost',
],
'client' => [
'short' => 'XXII. kerület',
'name' => 'Budafok-Tétény, Budapest, XXII. kerületi Önkormányzat',
'address' => '1221 Budapest, Városház tér 11.',
'tax_number' => '15735856-2-43',
],
'acl_config' => [
'hmac_key' => '',
],
];

View File

@@ -0,0 +1,29 @@
<?php
use Zend\Mail\Transport\File;
use Zend\Mail\Transport\FileOptions;
//use Zend\Mail\Transport\Smtp;
//use Zend\Mail\Transport\SmtpOptions;
return [
'mailer' => [
// 'transportClass' => Smtp::class,
// 'optionsClass' => SmtpOptions::class,
// 'options' => [
// 'name' => 'localhost',
// 'host' => '127.0.0.1',
// 'port' => 25,
// 'connection_class' => 'plain',
// 'connection_config' => [
// 'username' => 'user',
// 'password' => 'pass',
// ],
// ],
'transportClass' => File::class,
'optionsClass' => FileOptions::class,
'options' => [
'path' => 'data/mail/',
],
]
];

View File

@@ -0,0 +1,12 @@
<?php
use Zend\Expressive\Router\FastRouteRouter;
use Zend\Expressive\Router\RouterInterface;
return [
'dependencies' => [
'invokables' => [
RouterInterface::class => FastRouteRouter::class,
],
],
];

View File

@@ -0,0 +1,27 @@
<?php
use Zend\ConfigAggregator\ConfigAggregator;
return [
// Toggle the configuration cache. Set this to boolean false, or remove the
// directive, to disable configuration caching. Toggling development mode
// will also disable it by default; clear the configuration cache using
// `composer clear-config-cache`.
ConfigAggregator::ENABLE_CACHE => true,
// Enable debugging; typically used to provide debugging information within templates.
'debug' => false,
'zend-expressive' => [
// Enable programmatic pipeline: Any `middleware_pipeline` or `routes`
// configuration will be ignored when creating the `Application` instance.
'programmatic_pipeline' => true,
// Provide templates for the error handling middleware to use when
// generating responses.
'error_handler' => [
'template_404' => 'error::404',
'template_error' => 'error::error',
],
],
];

36
config/config.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
use Zend\ConfigAggregator\ArrayProvider;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ConfigAggregator\PhpFileProvider;
// To enable or disable caching, set the `ConfigAggregator::ENABLE_CACHE` boolean in
// `config/autoload/local.php`.
$cacheConfig = [
'config_cache_path' => 'data/config-cache.php',
];
$aggregator = new ConfigAggregator([
\Zend\Mail\ConfigProvider::class,
\Zend\Validator\ConfigProvider::class,
\Zend\Cache\ConfigProvider::class,
\Zend\Hydrator\ConfigProvider::class,
// Include cache configuration
new ArrayProvider($cacheConfig),
// Default App module config
App\ConfigProvider::class,
// Load application config in a pre-defined order in such a way that local settings
// overwrite global settings. (Loaded as first to last):
// - `global.php`
// - `*.global.php`
// - `local.php`
// - `*.local.php`
new PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
// Load development config if it exists
new PhpFileProvider('config/development.config.php'),
], $cacheConfig['config_cache_path']);
return $aggregator->getMergedConfig();

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;

View File

@@ -0,0 +1,29 @@
<?php
/**
* File required to allow enablement of development mode.
*
* For use with the zf-development-mode tool.
*
* Usage:
* $ composer development-disable
* $ composer development-enable
* $ composer development-status
*
* DO NOT MODIFY THIS FILE.
*
* Provide your own development-mode settings by editing the file
* `config/autoload/development.local.php.dist`.
*
* Because this file is aggregated last, it simply ensures:
*
* - The `debug` flag is _enabled_.
* - Configuration caching is _disabled_.
*/
use Zend\ConfigAggregator\ConfigAggregator;
return [
'debug' => true,
ConfigAggregator::ENABLE_CACHE => false,
];

58
config/pipeline.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
use Zend\Expressive\Helper\ServerUrlMiddleware;
use Zend\Expressive\Helper\UrlHelperMiddleware;
use Zend\Expressive\Middleware\ImplicitHeadMiddleware;
use Zend\Expressive\Middleware\ImplicitOptionsMiddleware;
use Zend\Expressive\Middleware\NotFoundHandler;
use Zend\Stratigility\Middleware\ErrorHandler;
/**
* Setup middleware pipeline:
*/
// The error handler should be the first (most outer) middleware to catch
// all Exceptions.
$app->pipe(Tuupola\Middleware\Cors::class);
$app->pipe(ErrorHandler::class);
$app->pipe(ServerUrlMiddleware::class);
// Pipe more middleware here that you want to execute on every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses
//
// Piped Middleware may be either callables or service names. Middleware may
// also be passed as an array; each item in the array must resolve to
// middleware eventually (i.e., callable or service name).
//
// Middleware can be attached to specific paths, allowing you to mix and match
// applications under a common domain. The handlers in each middleware
// attached this way will see a URI with the MATCHED PATH SEGMENT REMOVED!!!
//
// - $app->pipe('/api', $apiMiddleware);
// - $app->pipe('/docs', $apiDocMiddleware);
// - $app->pipe('/files', $filesMiddleware);
// Register the routing middleware in the middleware pipeline
$app->pipeRoutingMiddleware();
$app->pipe(ImplicitHeadMiddleware::class);
$app->pipe(ImplicitOptionsMiddleware::class);
$app->pipe(UrlHelperMiddleware::class);
// Add more middleware here that needs to introspect the routing results; this
// might include:
//
// - route-based authentication
// - route-based validation
// - etc.
$app->pipe(Slim\Middleware\JwtAuthentication::class);
$app->pipe(App\Middleware\RouteAuthorization::class);
// Register the dispatch middleware in the middleware pipeline
$app->pipeDispatchMiddleware();
// At this point, if no Response is return by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);

60
config/routes.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
/**
* Setup routes with a single request method:
*
* $app->get('/', App\Action\HomePageAction::class, 'home');
* $app->post('/album', App\Action\AlbumCreateAction::class, 'album.create');
* $app->put('/album/:id', App\Action\AlbumUpdateAction::class, 'album.put');
* $app->patch('/album/:id', App\Action\AlbumUpdateAction::class, 'album.patch');
* $app->delete('/album/:id', App\Action\AlbumDeleteAction::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Action\ContactAction::class, ['GET', 'POST', ...], 'contact');
*
* Or handling all request methods:
*
* $app->route('/contact', App\Action\ContactAction::class)->setName('contact');
*
* or:
*
* $app->route(
* '/contact',
* App\Action\ContactAction::class,
* Zend\Expressive\Router\Route::HTTP_METHOD_ANY,
* 'contact'
* );
*/
$app->get('/', App\Action\PingAction::class, 'home');
$app->get('/api/ping', App\Action\PingAction::class, 'api.ping');
$app->get('/api/maintenance/upcoming', App\Action\MaintenanceUpcomingAction::class, 'api.maintenance.upcoming');
$app->route('/api/maintenance[/{id:\w+}]', App\Action\MaintenanceAction::class, ['GET', 'OPTIONS'], 'api.maintenance');
$app->route('/api/maintenance/{id:\w+}', App\Action\MaintenanceAction::class, ['PUT'], 'api.maintenance.put');
// authentication and user management
$app->route('/api/auth/login', App\Action\Auth\AuthAction::class, ['POST', 'OPTIONS'], 'api.auth.login');
$app->route('/api/auth/renew', App\Action\Auth\AuthAction::class, ['GET', 'OPTIONS'], 'api.auth.renew');
$app->route('/api/user[/{id:\d+}]', App\Action\User\UserAction::class, ['GET', 'PUT', 'OPTIONS'], 'api.user.profile');
$app->route('/api/user/password', App\Action\User\PasswordAction::class, ['POST', 'OPTIONS'], 'api.user.password');
// fault management
$app->route('/api/fault[/{id:\d+}]', App\Action\Fault\FaultAction::class, ['GET', 'OPTIONS'], 'api.fault.get'); // list/show
$app->post('/api/fault', App\Action\Fault\FaultAction::class, 'api.fault.post'); // create
$app->put('/api/fault/{id:\d+}', App\Action\Fault\FaultAction::class, 'api.fault.put'); // update
$app->delete('/api/fault/{id:\d+}', App\Action\Fault\FaultAction::class, 'api.fault.delete');
$app->route('/api/fault-reject/{id:\d+}', App\Action\Fault\FaultRejectAction::class, ['POST', 'OPTIONS'], 'api.fault-reject.post');
$app->route('/api/fault-comment/{id:\d+}', App\Action\Fault\FaultCommentAction::class, ['POST', 'OPTIONS'], 'api.fault-comment.post');
$app->route('/api/fault-attachment/{id:\d+}/{type}', App\Action\Fault\FaultAttachmentAction::class, ['POST', 'OPTIONS'], 'api.fault-attachment.post');
$app->route('/show-attachment/{id:\d+}', App\Action\Fault\FaultAttachmentAction::class, ['GET', 'OPTIONS'], 'show-attachment');
$app->route('/hibajegy-pdf/{id:\d+}[/{filename}]', App\Action\Pdf\GenerateWorksheetAction::class, ['GET', 'OPTIONS'], 'hibajegy-pdf');
$app->route('/karbantartasjegy-pdf/{id:\w+}[/{filename}]', App\Action\Pdf\GenerateMaintenanceSheetAction::class, ['GET', 'OPTIONS'], 'karbantartasjegy-pdf');
// core data
$app->route('/api/error-category', App\Action\ErrorCategoryAction::class, ['GET', 'OPTIONS'], 'api.error-category.get'); // list/show
$app->route('/api/error-origin', App\Action\ErrorOriginAction::class, ['GET', 'OPTIONS'], 'api.error-origin.get'); // list/show
$app->route('/api/facility-location', App\Action\FacilityLocationAction::class, ['GET', 'OPTIONS'], 'api.facility-location.get'); // list/show
$app->route('/api/solution-time-interval', App\Action\SolutionTimeIntervalAction::class, ['GET', 'OPTIONS'], 'api.solution-time-interval.get'); // list/show