GithubHelp home page GithubHelp logo

lexik / lexikdatalayerbundle Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 5.0 23 KB

Manipulate the Google Tag Manager Data Layer from your Symfony application

PHP 100.00%
google-tag-manager symfony symfony-bundle

lexikdatalayerbundle's People

Contributors

mhujer avatar slashfan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

lexikdatalayerbundle's Issues

Fix A tree builder without a root node deprecation in Symfony 4.2

A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.

The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "lexik_data_layer" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.

See https://github.com/lexik/LexikDataLayerBundle/blob/master/DependencyInjection/Configuration.php

Fix would be:

<?php

namespace Lexik\Bundle\DataLayerBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Configuration
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('lexik_data_layer');
        // BC layer for symfony/config < 4.2
        $rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('apy_breadcrumb_trail');

        return $treeBuilder;
    }
}

Symfony 4 + Flex possible controller auto-wiring issue

I found a probable issue with the autowiring DataLayerManager to the Controller. When I add DataLayerManager as a constructor parameter to the Controller, there is an exception:

Cannot autowire service "My\App\HomepageController": argument "$dataLayerManager" of method "__construct()" references class "Lexik\Bundle\DataLayerBundle\Manager\DataLayerManager" but no such service exists. It cannot be auto-registered because it is from a different root namespace.

It works fine when I try to inject \Doctrine\ORM\EntityManagerInterface (so autowiring a class from a different namespace works in general).

Possible Workaround

I found this workaround - just add this to services.yaml:

services:
    Lexik\Bundle\DataLayerBundle\Manager\DataLayerManager: '@lexik_data_layer.manager.data_layer_manager'
    Lexik\Bundle\DataLayerBundle\Collector\CollectorChain: '@lexik_data_layer.collector.collector_chain'

Even this works:

services:
    Lexik\Bundle\DataLayerBundle\Manager\DataLayerManager:
    Lexik\Bundle\DataLayerBundle\Collector\CollectorChain:

Thanks for the Bundle ๐Ÿ‘ I really like the idea of mimicking the flash messages behaviour as it works great for tracking conversions after submitting the form + redirect.

Error in production

I dont know I am getting thhis error in production:

stderr: PHP Fatal error: Call to a member function getUser() on a non-object in /var/www/vhosts/arvalcarenet.com/releases/20170411094121/vendor/lexik/data-layer-bundle/Lexik/Bundle/DataLayerBundle/Collector/UserIdCollector.php on line 33

 class UserIdCollector implements CollectorInterface
{
    /**
     * @var TokenStorageInterface
     */
    protected $tokenStorage;

    /**
     * @param TokenStorageInterface $tokenStorage
     */
    public function __construct(TokenStorageInterface $tokenStorage)
    {
        $this->tokenStorage = $tokenStorage;
    }

    /**
     * {@inheritdoc}
     */
    public function handle(&$data)
    {
        $token = $this->tokenStorage->getToken();
        unset($data[0]);

        if($token != null){
            if ($token->getUser() && $token->getUser() instanceof User) {
                $data[0] = array_merge($data,['userId' => $token->getUser()->getUid()]);
            }
        }
    }
}

But I am calling my own service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.