Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
ACP3
ACP3 CMS
Commits
d68fccdf
Commit
d68fccdf
authored
Jan 26, 2019
by
Tino Goratsch
Browse files
remove the hard coded error logger from the app bootstrap process
parent
70c7af28
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
107 additions
and
32 deletions
+107
-32
ACP3/Core/Application/AbstractBootstrap.php
ACP3/Core/Application/AbstractBootstrap.php
+0
-8
ACP3/Core/Application/Bootstrap.php
ACP3/Core/Application/Bootstrap.php
+7
-3
ACP3/Core/Application/Event/Listener/OnOutputPageExceptionListener.php
...lication/Event/Listener/OnOutputPageExceptionListener.php
+29
-0
ACP3/Core/Application/Event/OutputPageExceptionEvent.php
ACP3/Core/Application/Event/OutputPageExceptionEvent.php
+31
-0
ACP3/Core/config/components/events.yml
ACP3/Core/config/components/events.yml
+7
-0
ACP3/Core/config/components/logger.yml
ACP3/Core/config/components/logger.yml
+1
-1
ACP3/Core/config/services.yml
ACP3/Core/config/services.yml
+1
-0
installation/Installer/Core/Application/Bootstrap.php
installation/Installer/Core/Application/Bootstrap.php
+7
-3
installation/Installer/Core/DependencyInjection/ServiceContainerBuilder.php
...ller/Core/DependencyInjection/ServiceContainerBuilder.php
+1
-12
installation/Installer/Core/config/components/application.yml
...allation/Installer/Core/config/components/application.yml
+6
-0
installation/Installer/Core/config/components/logger.yml
installation/Installer/Core/config/components/logger.yml
+16
-0
installation/Installer/Core/config/services.yml
installation/Installer/Core/config/services.yml
+1
-5
No files found.
ACP3/Core/Application/AbstractBootstrap.php
View file @
d68fccdf
...
...
@@ -9,8 +9,6 @@ namespace ACP3\Core\Application;
use
ACP3\Core\Environment\ApplicationMode
;
use
ACP3\Core\Environment\ApplicationPath
;
use
ACP3\Core\Logger\LoggerFactory
;
use
Psr\Log\LoggerInterface
;
use
Symfony\Component\Debug\ErrorHandler
;
use
Symfony\Component\Debug\ExceptionHandler
;
...
...
@@ -28,10 +26,6 @@ abstract class AbstractBootstrap implements BootstrapInterface
* @var \ACP3\Core\Environment\ApplicationPath
*/
protected
$appPath
;
/**
* @var LoggerInterface
*/
protected
$logger
;
/**
* @param string $appMode
...
...
@@ -42,7 +36,6 @@ abstract class AbstractBootstrap implements BootstrapInterface
{
$this
->
appMode
=
$appMode
;
$this
->
initializeApplicationPath
();
$this
->
logger
=
(
new
LoggerFactory
(
$this
->
appPath
))
->
create
(
'error'
);
}
protected
function
initializeApplicationPath
()
...
...
@@ -60,7 +53,6 @@ abstract class AbstractBootstrap implements BootstrapInterface
ExceptionHandler
::
register
(
$debug
);
$errorHandler
=
new
ErrorHandler
();
$errorHandler
->
setDefaultLogger
(
$this
->
logger
);
ErrorHandler
::
register
(
$errorHandler
);
}
...
...
ACP3/Core/Application/Bootstrap.php
View file @
d68fccdf
...
...
@@ -7,6 +7,7 @@
namespace
ACP3\Core\Application
;
use
ACP3\Core\Application\Event\OutputPageExceptionEvent
;
use
ACP3\Core\Application\Exception\MaintenanceModeActiveException
;
use
ACP3\Core\Controller\Exception\ForwardControllerActionAwareExceptionInterface
;
use
ACP3\Core\DependencyInjection\ServiceContainerBuilder
;
...
...
@@ -84,7 +85,7 @@ class Bootstrap extends AbstractBootstrap
/**
* {@inheritdoc}
*
* @throws \
Exception
* @throws \
Throwable
*/
public
function
outputPage
()
{
...
...
@@ -104,8 +105,11 @@ class Bootstrap extends AbstractBootstrap
$response
=
$controllerActionDispatcher
->
dispatch
(
$e
->
getServiceId
(),
$e
->
routeParams
());
}
catch
(
MaintenanceModeActiveException
$e
)
{
$response
=
new
Response
(
$e
->
getMessage
(),
$e
->
getCode
());
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
critical
(
$e
);
}
catch
(
\
Throwable
$e
)
{
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */
$eventDispatcher
=
$this
->
container
->
get
(
'core.event_dispatcher'
);
$eventDispatcher
->
dispatch
(
'core.output_page_exception'
,
new
OutputPageExceptionEvent
(
$e
));
throw
$e
;
}
...
...
ACP3/Core/Application/Event/Listener/OnOutputPageExceptionListener.php
0 → 100644
View file @
d68fccdf
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace
ACP3\Core\Application\Event\Listener
;
use
ACP3\Core\Application\Event\OutputPageExceptionEvent
;
use
Psr\Log\LoggerInterface
;
class
OnOutputPageExceptionListener
{
/**
* @var \Psr\Log\LoggerInterface
*/
private
$logger
;
public
function
__construct
(
LoggerInterface
$logger
)
{
$this
->
logger
=
$logger
;
}
public
function
__invoke
(
OutputPageExceptionEvent
$event
):
void
{
$this
->
logger
->
error
(
$event
->
getThrowable
());
}
}
ACP3/Core/Application/Event/OutputPageExceptionEvent.php
0 → 100644
View file @
d68fccdf
<?php
/**
* Copyright (c) by the ACP3 Developers.
* See the LICENSE file at the top-level module directory for licensing details.
*/
namespace
ACP3\Core\Application\Event
;
use
Symfony\Component\EventDispatcher\Event
;
class
OutputPageExceptionEvent
extends
Event
{
/**
* @var \Throwable
*/
private
$throwable
;
public
function
__construct
(
\
Throwable
$throwable
)
{
$this
->
throwable
=
$throwable
;
}
/**
* @return \Throwable
*/
public
function
getThrowable
():
\
Throwable
{
return
$this
->
throwable
;
}
}
ACP3/Core/config/components/events.yml
View file @
d68fccdf
...
...
@@ -33,3 +33,10 @@ services:
-
'
@core.acl'
tags
:
-
{
name
:
core.eventListener
,
event
:
core.application.controller_action_dispatcher.before_dispatch
}
core.application.event.on_output_page_listener
:
class
:
ACP3\Core\Application\Event\Listener\OnOutputPageExceptionListener
arguments
:
-
'
@core.logger.system_logger'
tags
:
-
{
name
:
core.eventListener
,
event
:
core.output_page_exception
}
ACP3/Core/config/components/logger.yml
View file @
d68fccdf
...
...
@@ -13,4 +13,4 @@ services:
class
:
Psr\Log\LoggerInterface
factory
:
'
core.logger.logger_factory:create'
arguments
:
-
'
system
'
-
'
error
'
ACP3/Core/config/services.yml
View file @
d68fccdf
...
...
@@ -46,3 +46,4 @@ services:
core.event_dispatcher
:
class
:
Symfony\Component\EventDispatcher\EventDispatcher
public
:
true
installation/Installer/Core/Application/Bootstrap.php
View file @
d68fccdf
...
...
@@ -8,6 +8,7 @@
namespace
ACP3\Installer\Core\Application
;
use
ACP3\Core
;
use
ACP3\Core\Application\Event\OutputPageExceptionEvent
;
use
ACP3\Installer\Core\DependencyInjection\ServiceContainerBuilder
;
use
ACP3\Installer\Core\Environment\ApplicationPath
;
use
Symfony\Component\HttpFoundation\Request
as
SymfonyRequest
;
...
...
@@ -57,7 +58,7 @@ class Bootstrap extends Core\Application\AbstractBootstrap
*/
public
function
initializeClasses
(
SymfonyRequest
$symfonyRequest
)
{
$this
->
container
=
ServiceContainerBuilder
::
create
(
$this
->
logger
,
$this
->
appPath
,
$symfonyRequest
,
$this
->
appMode
);
$this
->
container
=
ServiceContainerBuilder
::
create
(
$this
->
appPath
,
$symfonyRequest
,
$this
->
appMode
);
}
/**
...
...
@@ -72,8 +73,11 @@ class Bootstrap extends Core\Application\AbstractBootstrap
$response
=
$controllerActionDispatcher
->
dispatch
();
}
catch
(
Core\Controller\Exception\ControllerActionNotFoundException
$e
)
{
$response
=
$controllerActionDispatcher
->
dispatch
(
'errors.controller.install.index.not_found'
);
}
catch
(
\
Exception
$e
)
{
$this
->
logger
->
critical
(
$e
);
}
catch
(
\
Throwable
$e
)
{
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */
$eventDispatcher
=
$this
->
container
->
get
(
'core.event_dispatcher'
);
$eventDispatcher
->
dispatch
(
'core.output_page_exception'
,
new
OutputPageExceptionEvent
(
$e
));
$response
=
$controllerActionDispatcher
->
dispatch
(
'errors.controller.install.index.server_error'
);
}
...
...
installation/Installer/Core/DependencyInjection/ServiceContainerBuilder.php
View file @
d68fccdf
...
...
@@ -16,7 +16,6 @@ use ACP3\Core\Validation\DependencyInjection\RegisterValidationRulesPass;
use
ACP3\Core\View\Renderer\Smarty\DependencyInjection\RegisterLegacySmartyPluginsPass
;
use
ACP3\Core\View\Renderer\Smarty\DependencyInjection\RegisterSmartyPluginsPass
;
use
ACP3\Installer\Core\Environment\ApplicationPath
;
use
Psr\Log\LoggerInterface
;
use
Symfony\Component\Config\FileLocator
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
use
Symfony\Component\DependencyInjection\Loader\YamlFileLoader
;
...
...
@@ -25,10 +24,6 @@ use Symfony\Component\HttpFoundation\Request;
class
ServiceContainerBuilder
extends
ContainerBuilder
{
/**
* @var LoggerInterface
*/
private
$logger
;
/**
* @var ApplicationPath
*/
...
...
@@ -49,7 +44,6 @@ class ServiceContainerBuilder extends ContainerBuilder
/**
* ServiceContainerBuilder constructor.
*
* @param LoggerInterface $logger
* @param ApplicationPath $applicationPath
* @param Request $symfonyRequest
* @param string $applicationMode
...
...
@@ -58,7 +52,6 @@ class ServiceContainerBuilder extends ContainerBuilder
* @throws \Exception
*/
public
function
__construct
(
LoggerInterface
$logger
,
ApplicationPath
$applicationPath
,
Request
$symfonyRequest
,
string
$applicationMode
,
...
...
@@ -66,7 +59,6 @@ class ServiceContainerBuilder extends ContainerBuilder
)
{
parent
::
__construct
();
$this
->
logger
=
$logger
;
$this
->
applicationPath
=
$applicationPath
;
$this
->
symfonyRequest
=
$symfonyRequest
;
$this
->
applicationMode
=
$applicationMode
;
...
...
@@ -83,7 +75,6 @@ class ServiceContainerBuilder extends ContainerBuilder
$this
->
setParameter
(
'cache_driver'
,
'Array'
);
$this
->
set
(
'core.http.symfony_request'
,
$this
->
symfonyRequest
);
$this
->
set
(
'core.environment.application_path'
,
$this
->
applicationPath
);
$this
->
set
(
'core.logger.system_logger'
,
$this
->
logger
);
$this
->
addCompilerPass
(
new
RegisterListenersPass
(
...
...
@@ -171,7 +162,6 @@ class ServiceContainerBuilder extends ContainerBuilder
}
/**
* @param LoggerInterface $logger
* @param ApplicationPath $applicationPath
* @param Request $symfonyRequest
* @param string $applicationMode
...
...
@@ -182,12 +172,11 @@ class ServiceContainerBuilder extends ContainerBuilder
* @throws \Exception
*/
public
static
function
create
(
LoggerInterface
$logger
,
ApplicationPath
$applicationPath
,
Request
$symfonyRequest
,
string
$applicationMode
,
bool
$includeModules
=
false
)
{
return
new
static
(
$logger
,
$applicationPath
,
$symfonyRequest
,
$applicationMode
,
$includeModules
);
return
new
static
(
$applicationPath
,
$symfonyRequest
,
$applicationMode
,
$includeModules
);
}
}
installation/Installer/Core/config/components/application.yml
View file @
d68fccdf
...
...
@@ -30,3 +30,9 @@ services:
tags
:
-
{
name
:
core.eventListener
,
event
:
core.application.controller_action_dispatcher.before_dispatch
}
core.application.event.on_output_page_listener
:
class
:
ACP3\Core\Application\Event\Listener\OnOutputPageExceptionListener
arguments
:
-
'
@core.logger.system_logger'
tags
:
-
{
name
:
core.eventListener
,
event
:
core.output_page_exception
}
installation/Installer/Core/config/components/logger.yml
0 → 100644
View file @
d68fccdf
services
:
core.logger
:
class
:
ACP3\Core\Logger
arguments
:
-
'
@core.environment.application_path'
core.logger.logger_factory
:
class
:
ACP3\Core\Logger\LoggerFactory
arguments
:
-
'
@core.environment.application_path'
core.logger.system_logger
:
class
:
Psr\Log\LoggerInterface
factory
:
'
core.logger.logger_factory:create'
arguments
:
-
'
error'
installation/Installer/Core/config/services.yml
View file @
d68fccdf
...
...
@@ -17,11 +17,6 @@ services:
arguments
:
-
'
@core.environment.application_path'
core.logger
:
class
:
ACP3\Core\Logger
arguments
:
-
'
@core.environment.application_path'
core.router
:
class
:
ACP3\Installer\Core\Router\Router
arguments
:
...
...
@@ -59,6 +54,7 @@ services:
core.event_dispatcher
:
class
:
Symfony\Component\EventDispatcher\EventDispatcher
public
:
true
core.xml
:
class
:
ACP3\Core\XML
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment