picqer / moneybird-php-client

PHP Client for Moneybird V2
MIT License
82 stars 77 forks source link

Allow access to the Moneybird::$connection object #59

Closed holtkamp closed 7 years ago

holtkamp commented 8 years ago

We use PHP-DI as dependency injection container which allows us to:

[
  Picqer\Financials\Moneybird\Connection::class => object()->constructor()
        ->method('setClientId', 'X')
        ->method('setClientSecret', 'Y')
        ->method('setRedirectUrl', 'Z'),
  Picqer\Financials\Moneybird\Moneybird::class => object()->constructor(get(Picqer\Financials\Moneybird\Connection::class)),
]

Then the Moneybird object can be injected like:

class Administration{

    /**
     * @Inject
     *
     * @var \Picqer\Financials\Moneybird\Moneybird
     */
    private $apiClient;

    public function execute(){
        var_dump($this->apiClient->administration->get());
    }
}

This works well. However, after determining the Administration, the Connection object needs to be updated with the administrationId. However, we can not access the connection of the Moneybird object.

Any suggestion on how to do this? Maybe the $connection property should be made public / or be accessible using a getter function?

stephangroen commented 7 years ago

I see no problem in creating a getter function for the connection.

holtkamp commented 7 years ago

see https://github.com/picqer/moneybird-php-client/pull/62