<commit_before><?php

namespace Ty666\PictureManager;

use Illuminate\Support\ServiceProvider;

class PictureManagerServiceProvider extends ServiceProvider
{
    /**
     * 服务提供者加是否延迟加载.
     *
     * @var bool
     */
    protected $defer = true;
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            realpath(__DIR__.'/../config/picture.php') => config_path('picture.php'),
        ]);

        //$this->pictureRoute();
    }

    /**
     * 图片路由
     */
    protected function pictureRoute(){
        $config = $this->app['config']->get('picture');
        if($config['route']['path'] != ''){
            //图片尺寸正则
            $sizePattern = '('.implode('|', array_keys($config['sizeList'])).')';
            //图片后缀正则
            $suffixPattern = '('.implode('|',$config['allowTypeList']).')';
            $this->app['router']->get($config['route']['path'].'/{img_id}_{size}_{suffix}',[
                'as' => $config['route']['name'],
                'middleware' => $config['route']['middleware'],
                function ($img_id, $size, $suffix){
                    return \Ty666\PictureManager\Facades\PictureManager::init($img_id, $size, $suffix)->show();
                }
            ])->where(['img_id'=>'[a-zA-Z0-9]{32}','size' => $sizePattern, 'suffix' => $suffixPattern]);
        }
    }
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('pictureManager', function ($app) {
            $config = $app['config']->get('picture');
            $pictureManager = new PictureManager();
            $pictureManager->setUploadDir($config['uploadPath'])
                ->setSizeList($config['sizeList'])
                ->setAllowTypeList($config['allowTypeList'])
                ->setWatermark($config['watermark']);
            if(isset($config['needWatermark'])){
                $pictureManager->needWaterMark = $config['needWatermark'];
            }
            return $pictureManager;
        });
        //合并配置文件
        $this->mergeConfigFrom(
            realpath(__DIR__.'/../config/picture.php'), 'picture'
        );
    }
}
<commit_msg>Update PictureManagerServiceProvider.php<commit_after><?php

namespace Ty666\PictureManager;

use Illuminate\Support\ServiceProvider;

class PictureManagerServiceProvider extends ServiceProvider
{
    /**
     * 服务提供者加是否延迟加载.
     *
     * @var bool
     */
    protected $defer = true;
    /**
     * 获取由提供者提供的服务.
     *
     * @return array
     */
    public function provides()
    {
        return ['pictureManager'];
    }

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {

        $this->publishes([
            realpath(__DIR__.'/../config/picture.php') => config_path('picture.php'),
        ]);

        //$this->pictureRoute();
    }

    /**
     * 图片路由
     */
    protected function pictureRoute(){
        $config = $this->app['config']->get('picture');
        if($config['route']['path'] != ''){
            //图片尺寸正则
            $sizePattern = '('.implode('|', array_keys($config['sizeList'])).')';
            //图片后缀正则
            $suffixPattern = '('.implode('|',$config['allowTypeList']).')';
            $this->app['router']->get($config['route']['path'].'/{img_id}_{size}_{suffix}',[
                'as' => $config['route']['name'],
                'middleware' => $config['route']['middleware'],
                function ($img_id, $size, $suffix){
                    return \Ty666\PictureManager\Facades\PictureManager::init($img_id, $size, $suffix)->show();
                }
            ])->where(['img_id'=>'[a-zA-Z0-9]{32}','size' => $sizePattern, 'suffix' => $suffixPattern]);
        }
    }
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('pictureManager', function ($app) {
            $config = $app['config']->get('picture');
            $pictureManager = new PictureManager();
            $pictureManager->setUploadDir($config['uploadPath'])
                ->setSizeList($config['sizeList'])
                ->setAllowTypeList($config['allowTypeList'])
                ->setWatermark($config['watermark']);
            if(isset($config['needWatermark'])){
                $pictureManager->needWaterMark = $config['needWatermark'];
            }
            return $pictureManager;
        });
        //合并配置文件
        $this->mergeConfigFrom(
            realpath(__DIR__.'/../config/picture.php'), 'picture'
        );
    }
}

{'fraction_non_alphanumeric': 0.18235919234856535, 'fraction_numerical': 0.004250797024442083, 'mean_word_length': 2.069797782126549, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6255199', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1381, 'n_words': 187}