1616use Joomla \CMS \Installer \InstallerAdapter ;
1717use Joomla \CMS \Language \Text ;
1818use Joomla \CMS \Table \Category ;
19- use Joomla \Database \DatabaseInterface ;
19+ use Joomla \Database \DatabaseAwareInterface ;
20+ use Joomla \Database \DatabaseAwareTrait ;
2021use Joomla \Filesystem \File ;
2122use Joomla \Filesystem \Folder ;
2223
2526 *
2627 * @since 3.4
2728 */
28- class Com_WeblinksInstallerScript
29+ class Com_WeblinksInstallerScript implements DatabaseAwareInterface
2930{
31+ use DatabaseAwareTrait;
32+
3033 /**
3134 * Function called before extension installation/update/removal procedure commences
3235 *
@@ -87,7 +90,7 @@ public function preflight($type, $parent)
8790 public function install ($ parent )
8891 {
8992 // Initialize a new category
90- $ category = new Category (Factory:: getContainer ()-> get (DatabaseInterface::class ));
93+ $ category = new Category ($ this -> getDatabase ( ));
9194
9295 // Check if the Uncategorised category exists before adding it
9396 if (!$ category ->load (['extension ' => 'com_weblinks ' , 'title ' => 'Uncategorised ' ])) {
@@ -142,7 +145,7 @@ public function install($parent)
142145 public function postflight ($ type , $ parent )
143146 {
144147 // Only execute database changes on MySQL databases
145- $ dbName = Factory:: getContainer ()-> get (DatabaseInterface::class )->name ;
148+ $ dbName = $ this -> getDatabase ( )->name ;
146149
147150 if (strpos ($ dbName , 'mysql ' ) !== false ) {
148151 // Add Missing Table Columns if needed
@@ -166,7 +169,7 @@ public function postflight($type, $parent)
166169 private function insertMissingUcmRecords ()
167170 {
168171 // Insert the rows in the #__content_types table if they don't exist already
169- $ db = Factory:: getContainer ()-> get (DatabaseInterface::class );
172+ $ db = $ this -> getDatabase ( );
170173
171174 // Get the type ID for a Weblink
172175 $ query = $ db ->getQuery (true );
@@ -288,7 +291,7 @@ private function dropColumnsIfNeeded()
288291 'approved ' ,
289292 ];
290293
291- $ db = Factory:: getContainer ()-> get (DatabaseInterface::class );
294+ $ db = $ this -> getDatabase ( );
292295 $ table = $ db ->getTableColumns ('#__weblinks ' );
293296
294297 $ columns = array_intersect ($ oldColumns , array_keys ($ table ));
@@ -309,7 +312,7 @@ private function dropColumnsIfNeeded()
309312 */
310313 private function addColumnsIfNeeded ()
311314 {
312- $ db = Factory:: getContainer ()-> get (DatabaseInterface::class );
315+ $ db = $ this -> getDatabase ( );
313316 $ table = $ db ->getTableColumns ('#__weblinks ' );
314317
315318 if (!\array_key_exists ('version ' , $ table )) {
0 commit comments