plugin accessing extended methods

Developers
Vittorio
2014-06-09
2014-08-23
  • Vittorio
    Vittorio
    2014-06-09

    I managed to install a plugin in adminer/editor and also to extend it.

    Extensions works overriding credentials as indicated in the info:
    function credentials() {
    // server, username and password for connecting to database
    // hardcode the credential coordinates
    return array('dbserver', 'mydatabase', 'password');
    }

    Plugin is "allowed-prefixes" by Martin Macko (Show only tables with user set prefixes).
    there's a small glitch in the plugin, but nontheless it can't work with my extended class, and this leads to the architectural question (BTW plugin architecture is quite interesting and is not mentioned at all in http://php.vrana.cz/architecture-of-adminer.php)

    this plugin I downloaded does:
    function AdminerAllowedPrefixes($prefixes) {
    $server = Adminer::credentials()[0];
    $database = Adminer::database();
    $this->prefixes = $prefixes[$server][$database];
    }

    but since it accesses methods statically it will never pick up my extensions.

    I am able to subclass the plugin and alter it, but then: what's the right way to call my overridden methods of adminer? Is there one?

    In the meanwhile I think I will slam-in some hardcode and go on. But I would like to learn: Editor has very big potential as a lightweight backoffice for home grown cms.

    Thank you for the good product!

     
  • Jakub Vrána
    Jakub Vrána
    2014-06-15

    The "allowed-prefixes" shouldn't call Adminer class statically, it should call it through adminer(), e.g. adminer()->credentials().

     
  • Vittorio
    Vittorio
    2014-08-23

    Thank you Jakub. I managed to use the correct calls, but I had to move them from the constructor of the plugin to the main body because at instantiation time adminer.php is not yet included.
    No problem in this case, but I wonder if I'm missing something.
    No plugin can use adminer in its constructor, right?
    Thank you