lundi 7 mai 2018

How to extend vendor package service provider in Laravel 5.5

I am using a package that is a wrapper for another PHP package that integrates Xero accounting.

They have a file called XeroServiceProvider.php in the following location: /vendor/drawmyattention/xerolaravel/Providers/XeroServiceProvider.php.

I need to extend this service provider in my application but I don't like the idea of editing this file directly.

Is there a way I can extend this service provider easily without updating vendor files?

Here is the file I need to extend:

namespace DrawMyAttention\XeroLaravel\Providers;

use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use \App\Invoice;

class XeroServiceProvider extends ServiceProvider
{
    private $config = 'xero/config.php';

    public function boot()
    {
        $this->publishes([
            __DIR__.'/../config.php' => config_path($this->config),
        ]);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('XeroInvoice', function(){
           //return new \XeroPHP\Models\Accounting\Invoice();
           return new Invoice();
        });

    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire