-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bump to latest Underpin Version #3
Comments
It certainly could be integrated with the new version of Underpin, and I don't even think it would take a lot of refactoring to make it work. Looking at the features this integration uses, it's mostly using things that still exist in the latest Underpin, they're just named differently. It's something I'd like to see done, as I'm still using BerlinDB regularly, and would like to be able to use this integration again. To make this refactor work, we would need to do the following:
The biggest difference is how you would implement this in the newer version of Underpin, because it doesn't have an enforced pattern like the older version had which autoloaded features such as this one. In other words, you would have to create some way to access the BerlinDB system yourself. This could be done with a singleton instance, or you could add it to a service container, or something like that. I envision that you would end up making this work kind of like this: Create some kind of accessor for BerlinDB. The simplest take on this would be a singleton instance, like this, but I usually use Dependency Injection or some kind of service container to handle this. It really depends on the context of what you're building. The example below is using a singleton. This would not be a part of the Underpin BerlinDB library, but rather something you would add in your own plugin to interface with it. <?php
use Underpin\Interfaces\Singleton;
use Underpin\Traits\With_Instance;
use Underpin\BerlinDB\Loaders\Database;
class Berlin_DB implements Singleton{
use With_Instance;
/**
* @var Database The database loader object for BerlinDB.
*/
public readonly $database;
public function __construct(){
$this->database = new Database();
}
} Once that's set up, you would be able to access the system statically using Berlin_DB::instance()->database Then, you would be able to create new table much like how it's documented now. The only difference is that you're using the accessor you made instead of what the older version of Underpin enforced: Berlin_DB::instance()->database->add( 'example', [
'table' => 'Namespace\To\Berlin_DB\Table',
'schema' => 'Namespace\To\Berlin_DB\Schema',
'query' => 'Namespace\To\Berlin_DB\Query',
'name' => 'Human Readable Table Name',
'description' => 'Description of the purpose of this table',
'sanitize_callback' => function( $key, $value ){
// Function to sanitize fields before saving.
}
] ); Basically, anywhere that says |
I just became aware of your project and tried installing this loader. However, i was only able to use it with version 2 of the core. Could the version be bumped to be compatible with the latest core version, or would this involve major refactoring?
The text was updated successfully, but these errors were encountered: