public function preFill($contenttypes = [])
{
$output = '';
// Get a list of images.
$images = $this->app['filesystem']->find()->in('files://')->name('/\\.jpe?g$/')->name('*.png')->toArray();
// Set the 'Preferred titles' for filling the 'blocks' contenttype.
$this->preferredTitles = ['About Us', 'Address', 'Search Teaser', '404 Not Found'];
$emptyOnly = empty($contenttypes);
foreach ($this->app['config']->get('contenttypes') as $key => $contenttype) {
$tablename = $this->getContenttypeTablename($contenttype);
if ($emptyOnly && $this->hasRecords($tablename)) {
$output .= Trans::__('Skipped <tt>%key%</tt> (already has records)', ['%key%' => $key]) . "<br>\n";
continue;
} elseif (!in_array($key, $contenttypes) && !$emptyOnly) {
$output .= Trans::__('Skipped <tt>%key%</tt> (not checked)', ['%key%' => $key]) . "<br>\n";
continue;
}
$amount = isset($contenttype['prefill']) ? $contenttype['prefill'] : 5;
for ($i = 1; $i <= $amount; $i++) {
$output .= $this->preFillSingle($key, $contenttype, $images);
}
}
$output .= "<br>\n\n" . Trans::__('general.phrase.done-bang');
return $output;
}