/**
  * Install related extensions
  * Overriding the Alledia Install because we're specifying some additional things
  * @TODO: Remove when AllediaInstaller is updated with this enhancement
  *
  * @return void
  */
 protected function installRelated()
 {
     parent::installRelated();
     if ($this->relatedExtensions) {
         $source = $this->installer->getPath('source');
         foreach ($this->relatedExtensions as $type => $folders) {
             foreach ($folders as $folder => $extensions) {
                 foreach ($extensions as $element => $settings) {
                     $path = $source . '/' . $type;
                     if ($type == 'plugin') {
                         $path .= '/' . $folder;
                     }
                     $path .= '/' . $element;
                     if (is_dir($path)) {
                         $current = $this->findExtension($type, $element, $folder);
                         $isNew = empty($current);
                         $typeName = trim(($folder ?: '') . ' ' . $type);
                         $text = 'LIB_ALLEDIAINSTALLER_RELATED_' . ($isNew ? 'INSTALL' : 'UPDATE');
                         $installer = new JInstaller();
                         if ($installer->install($path)) {
                             $this->setMessage(JText::sprintf($text, $typeName, $element));
                             if ($isNew) {
                                 $current = $this->findExtension($type, $element, $folder);
                                 if ($settings[0]) {
                                     $current->publish();
                                 }
                                 if ($settings[2] && $type == 'plugin') {
                                     $this->setPluginOrder($current, $settings[2]);
                                 }
                             }
                         } else {
                             $this->setMessage(JText::sprintf($text . '_FAIL', $typeName, $element), 'error');
                         }
                     }
                 }
             }
         }
     }
 }