Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion][thinkphp] thinkphp use it , the facade class #1221

Closed
RubyKiss opened this issue Sep 13, 2023 · 1 comment
Closed

[suggestion][thinkphp] thinkphp use it , the facade class #1221

RubyKiss opened this issue Sep 13, 2023 · 1 comment

Comments

@RubyKiss
Copy link

RubyKiss commented Sep 13, 2023

the class code

<?php

namespace app\facades;

use Intervention\Image\ImageManager;
use think\Facade;

/**
 * @method static \Intervention\Image\Image make(mixed $data)
 * @method static self configure(array $config)
 * @method static \Intervention\Image\Image canvas(int $width, int $height, mixed $background = null)
 * @method static \Intervention\Image\Image cache(\Closure $callback, int $lifetime = null, boolean $returnObj = false)
 */
class InterventionImage extends Facade {
    protected static function getFacadeClass()
    {
    	return InterventionImageSource::class;
    }
}

class InterventionImageSource {
    /**
     * @var ImageManager
     */
    private $man;
    public function __construct()
    {
        $this->man = new ImageManager(['driver' => 'gd']); //you can change this driver use other driver
    }
    public function make($data)
    {
        return $this->man->make($data);
    }
    public function configure($data=[])
    {
        return $this->man->configure($data);
    }
    public function canvas(int $width, int $height, $background = null)
    {
        return $this->man->canvas($width,$height,$background);
    }
    public function cache(\Closure $callback, int $lifetime = null, $returnObj = false)
    {
        return $this->man->cache($callback,$lifetime,$returnObj);
    }
}
@RubyKiss RubyKiss changed the title [suggess][thinkphp] thinkphp 6+ use it , the faceds class [suggestion][thinkphp] thinkphp 6+ use it , the faceds class Sep 13, 2023
@RubyKiss RubyKiss changed the title [suggestion][thinkphp] thinkphp 6+ use it , the faceds class [suggestion][thinkphp] thinkphp use it , the facade class Sep 13, 2023
@olivervogel
Copy link
Member

Thanks for your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants