function file_browser_install in File Entity Browser 8
Implements hook_install().
File
- ./
file_browser.install, line 16 - Defines library requirements and install routines for File Browser.
Code
function file_browser_install() {
// Add an icon for File Browser if we aren't installing from configuration.
if (!\Drupal::isConfigSyncing()) {
$data = file_get_contents(dirname(__FILE__) . '/file_browser_icon.png');
/** @var \Drupal\file\FileInterface $file */
$file = file_save_data($data, 'public://file_browser_icon.png', FileSystemInterface::EXISTS_REPLACE);
if ($file) {
// Set file uuid same as default config.
$uuid = Yaml::decode(file_get_contents(dirname(__FILE__) . '/config/install/embed.button.file_browser.yml'))['icon_uuid'];
$file
->set('uuid', $uuid);
$file
->save();
\Drupal::service('file.usage')
->add($file, 'embed', 'embed_button', 'file_browser');
}
}
}