Skip to content

Extend not possible due to private helper methods #44

Closed

Description

Hello, please consider to make the private helper methods protected. It is not possible to extend SleekDb this way. After setting bootStore and initVariables from private to protected i was able to extend, but also had to copy the whole store method:

class LibreSleekDb extends \SleekDB\SleekDB
{
	public static function store( $storeName = false, $dataDir, $options = false ) {
		if ( !$storeName OR empty( $storeName ) ) throw new \Exception( 'Store name was not valid' );
		$_dbInstance = new LibreSleekDb( $dataDir, $options );
		$_dbInstance->storeName = $storeName;
		// Boot store.
		$_dbInstance->bootStore();
		// Initialize variables for the store.
		$_dbInstance->initVariables();
		return $_dbInstance;
	}

	public function fetch()
	{
		$results = parent::fetch();
		foreach ($results as $key => $result) {
			$results[$key] = (object) $result;
		}
		return $results;
	}
}

Now i can do LibreSleekDb::store('articles', $dataDir);

Activity

  1. rakibtg commented on Oct 21, 2020

    @rakibtg
    Member

    Can you tell me a little more about this use case, why you wanted to extend it instead of initialising it directly inside the LibreSleekDb class?

  2. rakibtg commented on Oct 21, 2020

    @rakibtg
    Member

    @einicher Thanks for the details, I will look into it. If you have any further input on this in the mean time let me know.

  3. Timu57 commented on Jan 24, 2021

    @Timu57
    Member

    We refactored and rewrote the whole project. Possible that it now suites your needs. I will close this issue. Feel free to reopen it if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions