By nielsonm on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Introduced in version:
8.x
Issue links:
Description:
hook_archiver_info has been replaced by the plugin system.
To implement an archiver in a module create a class in {module}/src/Plugin/Archiver/{ArchiverName}.php and implement ArchiverInterface.
The class must also declare a plugin annotation in its docblock comment. See the D8 example below and the @Archiver annotation declaration in the class' docblock.
D7
function system_archiver_info() {
$archivers['tar'] = array(
'class' => 'ArchiverTar',
'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'),
);
}
D8
<?php
namespace Drupal\system\Plugin\Archiver;
use Drupal\Component\Archiver\Tar as BaseTar;
/**
* Defines an archiver implementation for .tar files.
*
* @Archiver(
* id = "Tar",
* title = @Translation("Tar"),
* description = @Translation("Handles .tar files."),
* extensions = {"tar", "tgz", "tar.gz", "tar.bz2"}
* )
*/
class Tar extends BaseTar {
}
?>
These classes are discovered by Drupal\Core\Archiver\ArchiverManager which is available (and overrideable) as a core service.
Note: hook_archiver_info_alter() still exists and shares the same arguments as the hook in Drupal 7.
Impacts:
Module developers