Skip to content
Snippets Groups Projects
Commit 6ca7970e authored by Marcelo Vani's avatar Marcelo Vani
Browse files

Issue #3348890: Deleting un-needed files.

parent 77d9380d
Branches
Tags
1 merge request!5Resolve #3348890 "Drupal10 ckeditor5"
<?php
/**
* @file Install file.
*/
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\Core\File\FileSystemInterface;
/**
* Implements hook_install().
*/
function paragraphs_inline_entity_form_example_install() {
// Creates the paragraph icons.
$embed_types = [
'block',
'columns',
'facebook',
'gallery',
'image',
'instagram',
'text',
'twitter',
'view',
'youtube',
];
// Create and set icons.
foreach ($embed_types as $type) {
$filename = $type . '_thumb.jpg';
$icon = \Drupal::service('extension.path.resolver')->getPath('module', 'paragraphs_inline_entity_form_example') . '/images/' . $filename;
$data = file_get_contents($icon);
if ($file = \Drupal::service('file.repository')->writeData($data, 'public://' . $filename, FileSystemInterface::EXISTS_REPLACE)) {
$paragraphs_type = 'paragraphs_ief_' . $type;
if ($paragraphs_type_entity = ParagraphsType::load($paragraphs_type)) {
$paragraphs_type_entity->set('icon_uuid', $file->uuid());
$paragraphs_type_entity->save();
}
}
}
}
<?php
/**
* @file Install file.
*/
use Drupal\embed\Entity\EmbedButton;
use Drupal\Core\File\FileSystemInterface;
/**
* Implements hook_install().
*/
function paragraphs_inline_entity_form_install() {
// Set the default icon.
$icon = \Drupal::service('extension.path.resolver')->getPath('module', 'paragraphs_inline_entity_form') . '/images/paragraph_icon.png';
$data = file_get_contents($icon);
if ($file = \Drupal::service('file.repository')->writeData($data, 'public://paragraph_icon.png', FileSystemInterface::EXISTS_REPLACE)) {
if ($embed_button = EmbedButton::load('paragraphs_inline_entity_form')) {
$embed_button->set('icon', EmbedButton::convertImageToEncodedData($file->getFileUri()));
$embed_button->save();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment