alex-phillips / clouddrive-php

Amazon Cloud Drive API and CLI for PHP
MIT License
36 stars 9 forks source link

Removing the need for static Node access #19

Open nikkiii opened 8 years ago

nikkiii commented 8 years ago

I've been wondering if it'd be possible through some kind of node repository interface rather than statically setting information... It severely limits operation between several accounts in the same instance when it's linked together by a static account field, and in theory it'd be possible to pass some of the node logic into an object stored in the CloudDrive class.

Just wondering if you have any thoughts to this probably big, and API breaking change before spending the time looking into it.

Unrelated, but Amazon is running a deal on the Unlimited package ($5 for a year), so I'm hoping there will be a boost in usage/available APIs for this service, and I was incredibly happy to find this one!

alex-phillips commented 8 years ago

This would definitely be useful. I was debating on the best way to have the node class access the account credentials and information when I built it and really couldn't find a better way other than making the account class a singleton and fetching its instance. Otherwise, You'd have to pass in the account object into each node created or loaded.

One option is to use dependency injection, but that really depends on the implementation of the code. And since this was structured to be an SDK, I didn't want to lock anyone down to extra dependencies and govern how they needed to implement it.

I'm definitely interested in looking at making changes to make this easier and more flexible. If you have any specific examples or suggestions, please let me know!

nikkiii commented 8 years ago

I was thinking about maybe offloading load* into CloudDrive, returning a Node from there (by using the Account instance in the CloudDrive class), which would probably work quite well... I'll see if I can write a proof of concept, would definitely help