Inheritance: extends MetaModels\FrontendIntegration\HybridFilterClearAll
Beispiel #1
0
 /**
  * Render a module or content element.
  *
  * @param string $table     The name of the table.
  *
  * @param string $content   The html content in which to replace.
  *
  * @param string $replace   The string within the html to be replaced.
  *
  * @param int    $elementId The id of the module/ce-element to be inserted for the replace string.
  *
  * @return string
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function generateElement($table, $content, $replace, $elementId)
 {
     $sql = sprintf('SELECT * FROM %s WHERE id=? AND type="metamodels_frontendclearall"', $table);
     /** @var IMetaModelsServiceContainer $serviceContainer */
     $serviceContainer = $GLOBALS['container']['metamodels-service-container'];
     $objDbResult = $serviceContainer->getDatabase()->prepare($sql)->execute($elementId);
     // Check if we have a ce element.
     if ($objDbResult->numRows == 0) {
         return str_replace($replace, '', $content);
     }
     // Get instance and call generate function.
     if ($table == 'tl_module') {
         $objElement = new ModuleFilterClearAll($objDbResult);
     } elseif ($table == 'tl_content') {
         $objElement = new ContentElementFilterClearAll($objDbResult);
     } else {
         return str_replace($replace, '', $content);
     }
     return str_replace($replace, $objElement->generateReal(), $content);
 }