28
28
*
29
29
* @author Javier Eguiluz <[email protected] >
30
30
*/
31
- class CheckSQLiteEventSubscriber implements EventSubscriberInterface
31
+ class CheckRequirementsSubscriber implements EventSubscriberInterface
32
32
{
33
- /**
34
- * @var EntityManager
35
- */
33
+ /** @var EntityManager */
36
34
private $ entityManager ;
37
35
38
36
/**
39
- * CheckSQLiteEventSubscriber constructor.
40
- *
41
37
* @param EntityManager $entityManager
42
38
*/
43
39
public function __construct (EntityManager $ entityManager )
@@ -54,9 +50,9 @@ public static function getSubscribedEvents()
54
50
return [
55
51
// Exceptions are one of the events defined by the Console. See the
56
52
// rest here: http://symfony.com/doc/current/components/console/events.html
57
- ConsoleEvents::EXCEPTION => 'handleDatabaseExceptions ' ,
58
- // See: http://api.symfony.com/3.2 /Symfony/Component/HttpKernel/KernelEvents.html
59
- KernelEvents::EXCEPTION => 'onKernelException ' ,
53
+ ConsoleEvents::EXCEPTION => 'handleConsoleException ' ,
54
+ // See: http://api.symfony.com/master /Symfony/Component/HttpKernel/KernelEvents.html
55
+ KernelEvents::EXCEPTION => 'handleKernelException ' ,
60
56
];
61
57
}
62
58
@@ -67,7 +63,7 @@ public static function getSubscribedEvents()
67
63
*
68
64
* @param ConsoleExceptionEvent $event
69
65
*/
70
- public function handleDatabaseExceptions (ConsoleExceptionEvent $ event )
66
+ public function handleConsoleException (ConsoleExceptionEvent $ event )
71
67
{
72
68
$ commandNames = ['doctrine:fixtures:load ' , 'doctrine:database:create ' , 'doctrine:schema:create ' , 'doctrine:database:drop ' ];
73
69
@@ -80,15 +76,16 @@ public function handleDatabaseExceptions(ConsoleExceptionEvent $event)
80
76
}
81
77
82
78
/**
83
- * This method is triggered when kernel exception occurs. And checks if sqlite extension is enabled.
79
+ * This method checks if the triggered exception is related to the database
80
+ * and then, it checks if the required 'sqlite3' PHP extension is enabled.
84
81
*
85
82
* @param GetResponseForExceptionEvent $event
86
83
*/
87
- public function onKernelException (GetResponseForExceptionEvent $ event )
84
+ public function handleKernelException (GetResponseForExceptionEvent $ event )
88
85
{
89
86
$ exception = $ event ->getException ();
90
- // Since any exception thrown during a Twig template rendering is wrapped in a Twig_Error_Runtime.
91
- // We must get the original exception.
87
+ // Since any exception thrown during a Twig template rendering is wrapped
88
+ // in a Twig_Error_Runtime, we must get the original exception.
92
89
$ previousException = $ exception ->getPrevious ();
93
90
94
91
// Driver exception may happen in controller or in twig template rendering
@@ -101,14 +98,14 @@ public function onKernelException(GetResponseForExceptionEvent $event)
101
98
}
102
99
103
100
/**
104
- * Check if demo application is configured to use SQLite as database.
101
+ * Checks if the application is using SQLite as its database.
105
102
*
106
103
* @return bool
107
104
*/
108
105
private function isSQLitePlatform ()
109
106
{
110
107
$ databasePlatform = $ this ->entityManager ->getConnection ()->getDatabasePlatform ();
111
108
112
- return $ databasePlatform ? $ databasePlatform ->getName () === ' sqlite ' : false ;
109
+ return $ databasePlatform ? ' sqlite ' === $ databasePlatform ->getName () : false ;
113
110
}
114
111
}
0 commit comments