Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.32.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : font-bridge.php
<?php

/**
 * Class Brizy_Admin_Cloud_FontBridge
 */
class Brizy_Admin_Cloud_FontBridge extends Brizy_Admin_Cloud_AbstractBridge {

	/**
	 * @var Brizy_Admin_Fonts_Manager
	 */
	private $fontManager;

	/**
	 * Brizy_Admin_Cloud_FontBridge constructor.
	 *
	 * @param Brizy_Admin_Cloud_Client $client
	 */
	public function __construct( $client ) {
		parent::__construct( $client );

		$this->fontManager = new Brizy_Admin_Fonts_Manager();
	}

	/**
	 * @param $fontUid
	 *
	 * @return mixed|void
	 * @throws Exception
	 */
	public function export( $fontUid ) {

		$fontData = $this->fontManager->getFontForExport( $fontUid );

		if ( ! $fontData ) {
			throw new \Exception( "Unable to find font {$fontUid}" );
		}

		if ( ! $this->client->getFont( $fontUid ) ) {
			$this->client->createFont( $fontData );
		}
	}

	/**
	 * @param $fontUid
	 *
	 * @return mixed|void
	 * @throws Exception
	 */
	public function import( $fontUid ) {

		if ( $font = $this->fontManager->getFont( $fontUid ) ) {
			return $font;
		}

		$font = $this->client->getFont( $fontUid );

		$family  = $font['family'];
		$weights = $font['files'];

		$newWeights = array();

		foreach ( $weights as $weight => $weightType ) {
			foreach ( $weightType as $type => $fileUrl ) {
				$newWeights[ $weight ][ $type ] = $this->downloadFileToTemporaryFile( $fileUrl );
			}
		}

		return $this->fontManager->createFont( $fontUid, $family, $newWeights, 'uploaded' );
	}

	private function downloadFileToTemporaryFile( $url ) {
		$content  = Brizy_Editor_Asset_StaticFile::get_asset_content( $url );

		return Brizy_Editor_Asset_StaticFileTrait::createSideLoadFile(
			basename( $url ),
			$content
		);

	}

	/**
	 * @param $fontUid
	 *
	 * @return mixed|void
	 * @throws Exception
	 */
	public function delete( $fontUid ) {
		throw new Exception( 'Not implemented' );
	}
}
© 2025 XylotrechusZ