Automattic\Jetpack\Autoloader
CustomAutoloaderPlugin::determineSuffix() private WC 1.0
Determine the suffix for the autoloader class.
Reuses an existing suffix from vendor/autoload_packages.php or vendor/autoload.php if possible.
{} It's a method of the class: CustomAutoloaderPlugin{}
No Hooks.
Return
String. Suffix.
Usage
// private - for code of main (parent) class only $result = $this->determineSuffix();
Code of CustomAutoloaderPlugin::determineSuffix() CustomAutoloaderPlugin::determineSuffix WC 5.0.0
private function determineSuffix() {
$config = $this->composer->getConfig();
$vendorPath = $config->get( 'vendor-dir' );
// Command line.
$suffix = $config->get( 'autoloader-suffix' );
if ( $suffix ) {
return $suffix;
}
// Reuse our own suffix, if any.
if ( is_readable( $vendorPath . '/autoload_packages.php' ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$content = file_get_contents( $vendorPath . '/autoload_packages.php' );
if ( preg_match( '/^namespace Automattic\\\\Jetpack\\\\Autoloader\\\\jp([^;\s]+);/m', $content, $match ) ) {
return $match[1];
}
}
// Reuse Composer's suffix, if any.
if ( is_readable( $vendorPath . '/autoload.php' ) ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$content = file_get_contents( $vendorPath . '/autoload.php' );
if ( preg_match( '{ComposerAutoloaderInit([^:\s]+)::}', $content, $match ) ) {
return $match[1];
}
}
// Generate a random suffix.
return md5( uniqid( '', true ) );
}