scoutapp / scout-apm-laravel

ScoutAPM PHP Agent for the Laravel Framework
MIT License
22 stars 12 forks source link

implement getCompiler function in ScoutViewEngineDecorator #8

Closed imhmdb closed 5 years ago

imhmdb commented 5 years ago

we're using a library that uses the laravel blade compiler to add directives like this: $blade = app('view')->getEngineResolver()->resolve('blade')->getCompiler(); when I installed scout-apm-laravel package the application stopped working because the ScoutViewEngineDecorator does not implement the public function getCompiler of the realEngine Illuminate\View\Engines\CompilerEngine

this is what the logs were showing: Call to undefined method Scoutapm\Laravel\Events\ScoutViewEngineDecorator::getCompiler() {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to undefined method

as a test I tried adding this method to ScoutViewEngineDecorator and everything started working again.

public function getCompiler(){
            return $this->realEngine->getCompiler();
    }
asgrim commented 5 years ago

Hmm, interesting, \Illuminate\Contracts\View\Engine doesn't mention getCompiler() at all (including the first version the interface was introduced).

Feels like if the \Illuminate\View\Engines\CompilerEngine::getCompiler method is intended for public consumption, it should be part of the interface, since that's what interfaces are for (to ensure Liskov substitution principle) :/

Will review fix #9 next.

asgrim commented 5 years ago

Fixed in #9 .