Extending class from another plugin

@Jrbdog, I cannot get LightSlider to work either using autoloader, but the following workaround does work (using Grav 1.7.0-rc.20) :

  • No need to alter default ‘/user/plugins/child/composer.json’
  • To override LightSlider::onTwigSiteVariables() in ‘child.php’ use:
    <?php
    namespace Grav\Plugin;
    
    use Composer\Autoload\ClassLoader;
    
    require __DIR__ . '/../lightslider/lightslider.php';
    
    use Grav\Plugin\LightsliderPlugin;
    
    class ChildPlugin extends LightSliderPlugin
    {
      public function autoload(): ClassLoader
      {
        return require __DIR__ . '/vendor/autoload.php';
      }
    
      public function onTwigSiteVariables() {
          parent::onTwigSiteVariables();
      }
    }
    
1 Like