a2lix / TranslationFormBundle

Ease translations with some dedicated Symfony form types
https://a2lix.fr/bundles/translation-form
MIT License
330 stars 140 forks source link

Has no association named translations #378

Open Doreitor opened 2 years ago

Doreitor commented 2 years ago

Environment

Composer packages

$ composer show
a2lix/auto-form-bundle               0.4.3     Automate form building
a2lix/translation-form-bundle        3.2.1     Translate your doctrine objects easily with some helpers
antishov/doctrine-extensions-bundle  v1.4.3    Forked from stof/doctrine-extensions-bundle integration of the gedmo/doctrine-extensions with Symfony 4
beberlei/doctrineextensions          v1.3.0    A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.
behat/transliterator                 v1.5.0    String transliterator
brick/math                           0.9.3     Arbitrary-precision arithmetic library
composer/package-versions-deprecated 1.11.99.3 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
damienharper/auditor                 2.0.3     The missing audit log library.
damienharper/auditor-bundle          5.0.2     Integrate auditor library in your Symfony projects.
doctrine/annotations                 1.13.3    Docblock Annotations Parser
doctrine/cache                       2.2.0     PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections                 1.6.8     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      3.3.0     PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, prox...
doctrine/data-fixtures               1.5.3     Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        2.13.9    Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                v1.0.0    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/doctrine-bundle             2.7.0     Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle    3.4.2     Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  2.2.3     Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   2.0.4     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator                1.4.1     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.3     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  2.3.5     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily ...
doctrine/orm                         2.12.3    Object-Relational-Mapper for PHP
doctrine/persistence                 2.5.3     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter               1.1.3     a PHP SQL highlighting library
egulias/email-validator              3.2.1     A library for validating emails against several RFCs
ezyang/htmlpurifier                  v4.14.0   Standards compliant HTML filter written in PHP
friendsofphp/proxy-manager-lts       v1.0.12   Adding support for a wider range of PHP versions to ocramius/proxy-manager
friendsofsymfony/rest-bundle         3.1.1     This Bundle provides various tools to rapidly develop RESTful API's with Symfony
gedmo/doctrine-extensions            v3.7.0    Doctrine2 behavioral extensions
google/recaptcha                     1.2.4     Client library for reCAPTCHA, a free service that protects websites from spam and abuse.
imagine/imagine                      1.3.2     Image processing for PHP 5.3
ip2location/ip2location-php          8.3.0     [Official Release] IP2Location PHP API to get location info from IPv4 and IPv6 address.
jms/metadata                         2.6.1     Class/method/property metadata management in PHP
jms/serializer                       3.17.1    Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle                3.10.0    Allows you to easily serialize, and deserialize data of any complexity
karser/karser-recaptcha3-bundle      v0.1.22   Google ReCAPTCHA v3 for Symfony
knplabs/doctrine-behaviors           2.3.0     Doctrine Behavior Traits
knplabs/knp-components               v3.4.0    Knplabs component library
knplabs/knp-menu                     v3.3.0    An object oriented menu library
knplabs/knp-menu-bundle              v3.2.0    This bundle provides an integration of the KnpMenu library
knplabs/knp-paginator-bundle         v5.8.0    Paginator bundle for Symfony to automate pagination and simplify sorting and other features
kphoen/sitemap-bundle                2.0.1     Provides a way to create/generate a sitemap using Doctrine, etc.
kphoen/sitemap-generator             1.4.1     Provides a way to create/generate a sitemap using Propel, Doctrine, etc.
laminas/laminas-code                 4.5.2     Extensions to the PHP Reflection API, static code scanning, and code generation
liip/imagine-bundle                  2.6.1     This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.
maennchen/zipstream-php              2.2.1     ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.
markbaker/complex                    3.0.1     PHP Class for working with complex numbers
markbaker/matrix                     3.0.0     PHP Class for working with matrices
monolog/monolog                      1.27.1    Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/php-enum                     1.8.3     PHP Enum implementation
nelmio/cors-bundle                   2.2.0     Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
nette/utils                          v3.2.7    🛠  Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON e ncoding/decoding, validation, slug or strong password gen...
nikic/php-parser                     v4.14.0   A PHP parser written in PHP
phpoffice/phpspreadsheet             1.24.0    PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
phpstan/phpdoc-parser                1.6.4     PHPDoc parser with support for nullable, intersection and generic types
presta/sitemap-bundle                v2.5.0    A Symfony bundle that provides tools to build your application sitemap.
psr/cache                            2.0.0     Common interface for caching libraries
psr/container                        1.1.2     Common Container Interface (PHP FIG PSR-11)
psr/http-client                      1.0.1     Common interface for HTTP clients
psr/http-factory                     1.0.1     Common interfaces for PSR-7 HTTP message factories
psr/http-message                     1.0.1     Common interface for HTTP messages
psr/log                              1.1.4     Common interface for logging libraries
psr/simple-cache                     2.0.0     Common interfaces for simple caching
ramsey/collection                    1.2.2     A PHP library for representing and manipulating collections.
ramsey/uuid                          4.3.1     A PHP library for generating and working with universally unique identifiers (UUIDs).
sensio/framework-extra-bundle        v5.6.1    This bundle provides a way to configure your controllers with annotations
swiftmailer/swiftmailer              v6.3.0    Swiftmailer, free feature-rich PHP mailer
symfony/apache-pack                  v1.0.1    A pack for Apache support in Symfony
symfony/asset                        v4.4.40   Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files
symfony/cache                        v5.4.10   Provides an extended PSR-6, PSR-16 (and tags) implementation
symfony/cache-contracts              v2.5.2    Generic abstractions related to caching
symfony/config                       v4.4.42   Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console                      v4.4.43   Eases the creation of beautiful and testable command line interfaces
symfony/debug                        v4.4.41   Provides tools to ease debugging PHP code
symfony/dependency-injection         v4.4.43   Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts        v3.1.1    A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge              v4.4.43   Provides integration for Doctrine with various Symfony components
symfony/dotenv                       v4.4.37   Registers environment variables from a .env file
symfony/error-handler                v4.4.41   Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher             v4.4.42   Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts   v1.1.13   Generic abstractions related to dispatching event
symfony/expression-language          v6.1.2    Provides an engine that can compile and evaluate expressions
symfony/filesystem                   v5.4.9    Provides basic utilities for the filesystem
symfony/finder                       v5.4.8    Finds files and directories via an intuitive fluent interface
symfony/flex                         v1.19.2   Composer plugin for Symfony
symfony/form                         v4.4.43   Allows to easily create, process and reuse HTML forms
symfony/framework-bundle             v4.4.43   Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client                  v4.4.42   Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts        v2.5.2    Generic abstractions related to HTTP clients
symfony/http-foundation              v5.4.10   Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                  v4.4.43   Provides a structured process for converting a Request into a Response
symfony/intl                         v5.4.10   Provides a PHP replacement layer for the C intl extension that includes additional data from the ICU library
symfony/lock                         v6.1.1    Creates and manages locks, a mechanism to provide exclusive access to a shared resource
symfony/maker-bundle                 v1.39.0   Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/mime                         v5.4.10   Allows manipulating MIME messages
symfony/monolog-bridge               v4.4.43   Provides integration for Monolog with various Symfony components
symfony/monolog-bundle               v3.8.0    Symfony MonologBundle
symfony/options-resolver             v5.4.3    Provides an improved replacement for the array_replace PHP function
symfony/polyfill-intl-grapheme       v1.26.0   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn            v1.26.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer     v1.26.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring            v1.26.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72               v1.26.0   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73               v1.26.0   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80               v1.26.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81               v1.26.0   Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/process                      v5.4.8    Executes commands in sub-processes
symfony/property-access              v5.4.8    Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info                v5.4.10   Extracts information about PHP class' properties using metadata of popular sources
symfony/routing                      v4.4.41   Maps an HTTP request to a set of configuration variables
symfony/security-bundle              v4.4.42   Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/security-core                v4.4.41   Symfony Security Component - Core Library
symfony/security-csrf                v4.4.37   Symfony Security Component - CSRF Library
symfony/security-guard               v4.4.37   Symfony Security Component - Guard
symfony/security-http                v4.4.42   Symfony Security Component - HTTP Integration
symfony/service-contracts            v2.5.2    Generic abstractions related to writing services
symfony/stopwatch                    v4.4.38   Provides a way to profile code
symfony/string                       v5.4.10   Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/swiftmailer-bundle           v3.5.4    Symfony SwiftmailerBundle
symfony/translation                  v4.4.41   Provides tools to internationalize your application
symfony/translation-contracts        v2.5.2    Generic abstractions related to translation
symfony/twig-bridge                  v4.4.42   Provides integration for Twig with various Symfony components
symfony/twig-bundle                  v4.4.41   Provides a tight integration of Twig into the Symfony full-stack framework
symfony/validator                    v4.4.43   Provides tools to validate values
symfony/var-dumper                   v5.4.9    Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter                 v6.1.1    Allows exporting any serializable PHP data structure to plain PHP code
symfony/web-profiler-bundle          v4.4.43   Provides a development tool that gives detailed information about the execution of any request
symfony/web-server-bundle            v4.4.37   Provides commands for running applications using the PHP built-in web server
symfony/yaml                         v4.4.43   Loads and dumps YAML files
twig/extra-bundle                    v3.4.0    A Symfony bundle for extra Twig extensions
twig/intl-extra                      v3.4.0    A Twig extension for Intl
twig/twig                            v3.4.1    Twig, the flexible, fast, and secure template language for PHP
vich/uploader-bundle                 1.19.1    Ease file uploads attached to entities
willdurand/jsonp-callback-validator  v1.1.0    JSONP callback validator.
willdurand/negotiation               3.1.0     Content Negotiation tools for PHP provided as a standalone library.

PHP version

$ php -v
PHP 8.1.6 (cli) (built: May 11 2022 08:55:59) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies

Subject

[Semantical Error] line 0, col 61 near 't ': Error: App\Entity\Insight has no association named translations

Steps to reproduce

SQL Server

Expected results

Actual results

Doctrine\ORM\Query\ QueryException SELECT i FROM App\Entity\Insight i INNER JOIN i.translations t WHERE i.regions LIKE :region AND i.languages LIKE :language AND t.locale LIKE :local AND i.published = true ORDER BY t.title ASC

Doreitor commented 2 years ago

`public function findByFeatured(Request $request) { $entityManager = $this->getEntityManager();

    $region = $request->attributes->get('_region');
    $language = $request->attributes->get('_locale');

    $query = $entityManager->createQuery(
        "SELECT i FROM App\Entity\Insight i INNER JOIN i.translations t
            WHERE i.regions LIKE :region AND i.languages LIKE :language AND t.locale LIKE :local AND i.published = true
            ORDER BY t.title ASC "
    )->setParameters(array(
            'language' => '%'.$language.'%',
            'region' => '%'.$region.'%',
            'local' => '%'.$language.'%',
    ));

    return $query->getResult();
}`

CREATE TABLE [dbo].[Insight]( [id] [int] IDENTITY(1,1) NOT NULL, [home_id] [int] NULL, [createdAt] [datetime2](6) NULL, [updatedAt] [datetime2](6) NULL, [languages] [varchar](max) NOT NULL, [regions] [varchar](max) NOT NULL, [metaRobots] [nvarchar](128) NULL, [published] [bit] NULL, [headerType] [nvarchar](64) NOT NULL, [showIntroBlock] [bit] NOT NULL, [showKnowledgeBlock] [bit] NOT NULL, [showEventsBlock] [bit] NOT NULL, [showLegalNoveltiesBlock] [bit] NOT NULL, [showCaseStudiesBlock] [bit] NOT NULL, [oldId] [int] NULL, [showTeamsBlock] [bit] NULL, [featured] [bit] NULL, [private] [bit] NULL, [activity_id] [int] NULL)

CREATE TABLE [dbo].[InsightTranslation]( [id] [int] IDENTITY(1,1) NOT NULL, [translatable_id] [int] NULL, [title] [nvarchar](255) NOT NULL, [summary] [varchar](max) NULL, [description] [varchar](max) NULL, [slug] [nvarchar](128) NOT NULL, [metaTitle] [nvarchar](255) NULL, [metaDescription] [nvarchar](255) NULL, [locale] [nvarchar](255) NOT NULL)