jenssegers / blade

🔪 A standalone version of Laravel's Blade templating engine for use outside of Laravel.
https://jenssegers.com
825 stars 124 forks source link

Update from 1.1.0 to 1.2.1 breaks $blade->share() #31

Open danhofmann-com opened 5 years ago

danhofmann-com commented 5 years ago

I just updated from 1.1.0 to 1.2.1, and $view->blade() no longer works.

In my middlware // this line actually is defined in the initialization portion of my app, and is then stored in a service container. In my middleware, I grab the $blade object from the container, and call share(), and then later, in my controller, I get the $blade object from the container once again, and call make() $blade = new Blade($config['app']['template-views'], $config['app']['template-cache']); // hash is not empty, it is an array $blade->share('categoryHash', $hash);

In my view: echo (bool) is_null($categoryHash); die();

And the output is 1 (or true), indicating the value is null, when it should contain an array

This works fine in <= 1.1.0, but breaks when I updated to 1.2.1. Am I missing something?

danhofmann-com commented 5 years ago

Here is another example of a use case:

use League\Container\ServiceProvider\AbstractServiceProvider; use Jenssegers\Blade\Blade;

class TemplateServiceProvider extends AbstractServiceProvider { /**

class PartCategories {

const MAX_PART_PER_CATEGORY = 40;

public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{

    $container = App::getStaticContainer();
    $view = $container->get('Blade');
    $hash = $this->createCategorySubCategoryUrlHash();
    $view->share('categoryHash', $hash);

...

And even if i try to use the shared() method, to get a previously stored item, it is null

class ProductDetailController extends BaseController {

public function applicationDetail()
{
    $container = App::getStaticContainer();
    $view = $container->get('Blade');
    $categoryHash= $view->shared('categoryHash');
    print_pre($categoryHash); die(); // this is null after the update

If I downgrade back to 1.1.0, it works again.

amoutonbrady commented 5 years ago

I may have found the issue and started a pull request here : https://github.com/jenssegers/blade/pull/37 hopefully this was the right fix and will solve our problem