Giter Site home page Giter Site logo

doctrine / doctrinebundle Goto Github PK

View Code? Open in Web Editor NEW
4.7K 4.7K 442.0 3.22 MB

Symfony Bundle for Doctrine ORM and DBAL

Home Page: https://www.doctrine-project.org/projects/doctrine-bundle.html

License: MIT License

PHP 94.99% Twig 5.01%
bundle doctrine symfony symfony-bundle

doctrinebundle's People

Contributors

alcaeus avatar alli83 avatar bamarni avatar beberlei avatar dbu avatar derrabus avatar dlsniper avatar dmaicher avatar dunglas avatar fabpot avatar greg0ire avatar guilhermeblanco avatar javiereguiluz avatar jwage avatar kimhemsoe avatar kriswallsmith avatar l-vo avatar lsmith77 avatar mikesimonson avatar nicolas-grekas avatar ocramius avatar oskarstark avatar ostrolucky avatar pborreli avatar pkruithof avatar schmittjoh avatar seldaek avatar stof avatar vicb avatar weaverryan avatar

Stargazers

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

Watchers

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

doctrinebundle's Issues

Fixing tests

@jmikola, we have a failing test case related to the refactoring of the RegisterEventListenersSubscribersPass, could you take a look?

@Return doesn't contain FQN of classes

For now @return for Registry::getEntityManager() (and some other methods) looks like

* @return EntityManager

and the name EntityManager cannot be resolved using IDEs

* @return \Doctrine\ORM\EntityManager

should be used instead

doctrine:generate:entities regenerates privates for abstract or traits

Using traits (PHP5.4) or abstract class as parent will not generate the correct result when calling
doctrine:generate:entities

abstract class Address {
    /**
     * @ORM\Column(type="string", length=255)
     **/
    protected $firstname;

    public function setFirstName() ...
    public function getFirstName() ...
}

class Customer extends Address {

    // will generate this:
    private $firstname;

    public function setFirstName() ...
    public function getFirstName() ...
}  

The private should not be generated neither the public methods since they exist in the base class.
The same kind of thing happens when using trait.

[Command\Proxy] some `cache:clear-result` arguments doesn't exists

I'm using memcached as result_cache mechanism

If I run
app/console doctrine:cache:clear-result --id=cache_key
or with --prefix="user*"
I've got

  [RuntimeException]                 
  The "--id" option does not exist.  

Into the file
Doctrine\Bundle\DoctrineBundle\Command\Proxy\ClearResultCacheDoctrineCommand there's no --id neither the --prefix --suffix etc

Am I wrong something or the help message is deprecated?

Thanks a lot.

Better cache mapping

Currently, if you use a non-default cache support, like Redis, you're forced to map 3 instances for a single entity manager.
To simplify this support, and also make #65 and also remove the need of http://knpbundles.com/search?q=cache, we could use the 2.2 CacheBundle support ( symfony/symfony#3225 ) or simplify this by allowing our own cache:

doctrine:
    cache:
        apc: ~
    orm:
        // ...
        metadata_cache_driver: apc

This would also allow people to retrieve the cache drivers from service container.

Debug Bar should validate entity mappings

The Doctrine Debug Toolbar should validate all mappings of entities that are part of the request using the SchemaValidator. This helps users to find problems in their schema.

Types for dbal has to be defined twice

I know this is documented in http://symfony.com/doc/2.0/cookbook/doctrine/dbal.html (last two chapters), but I just had a major WTF.
I had had types registered only under dbal.types and worked just fine until there was some need for database reverse engineering like it's happening in doctrine:schema:validate and doctrine:schema:update --dump-sql

I think that mapping_types under connections is redundant and this should be somehow worked around in ConnectionFactory:createConnection

The problem probably lies deeper in DBAL as per @beberlei this is legacy which hasn't been integrated

Incorrect entity generation when multiple links on target entities

Hello,

I use Symfony 2.0.9. I guess this is linked directly to the doctrine / doctrine bundle.
EDIT: I found the issue in JIRA : http://www.doctrine-project.org/jira/browse/DDC-1497
I am unsure whether I should keep this issue in github then...

I have a User entity, which references a Band entity as an arrayCollection ($bands). So far everything is fine.

Then I try to setup 2 new variables as :

  • $favoriteBands with a ManyToMany relationship
  • $favoriteAlbums with a ManyToMany relationship

When generating the entity via php app/console doctrine:generate:entities AcmeMyBundle I have the following behavior:
for the bands:

/**
     * Add favoritealbums
     *
     * @param Acme\MyBundle\Entity\Album $favoritealbums
     */
    public function addAlbum(\Acme\MyBundle\Entity\Album $favoritealbums)
    {
        $this->favoritealbums[] = $favoritealbums;
    }

    /**
     * Get favoritealbums
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getFavoritealbums()
    {
        return $this->favoritealbums;
    }

I feel like I should have addFavoriteAlbum instead of addAlbum...

Furthermore, concerning the $favoriteBands, I only have the getter generated as the setter is considered, I assume, already generated (since I already have a "addBand" method coming from the $bands collection already registered).

Can you please fix it (or tell me if I am doing something wrong!)

Remove Entity/Document/CouchDocument auto-detection

The auto detection and differentiation between Entity/Document/CouchDocument folders is really a pain.

The FOS Bundles went to an ugly MappedSuperClass + Extend pattern to work around this.

In general Doctrine is a DataMapper, because its supposed to be persistence ignorant. All the classes can be in any folder.

Idea:

  • AutoMapping points to Bundle directory, not to subdirectories anymore. That means Entities can be in any folder of the bundle.
  • DoctrineBundle (Bridge) provides a way to avoid the same classes to be mapped by multiple persistence mappers, so that FOSBundle style distribution of mappings for all bundles is still possible.

Composer requirements for dev-master

Hello,

trying to integrate PHPCR with the jackalope-doctrine-dbal transport in a symfony2.1 application, I am running into a number of problems regarding composer dependencies:

This is taken from the composer.json file:

    "doctrine/dbal": "2.2.2",
    "doctrine/doctrine-bundle": "dev-master",
    "doctrine/orm": "2.2.x-dev",
    "jackalope/jackalope-doctrine-dbal": "dev-master",

The issue I'm trying to raise is the dependencies set by these components won't match. DoctrineBundle will won't install when dbal and orm are set to dev-master.

What I'm suggesting is to create a 2.2.* branch for DoctrineBundle as its requirements for Doctrine and DoctrineDBAL will fit, and for dev-master of DoctrineBundle to meet the requirements of the master branches for doctrine and dbal

xsd validation occurs before external parameter substitution

This fails:

<doctrine:config>
        <doctrine:dbal default-connection="default">
            <doctrine:connection
                name="default"
                dbname="%database_name%"
                host="%database_host%"
                port="%database_port%"
                user="%database_user%"
                password="%database_password%"
                driver="%database_driver%"
                charset="UTF8"
            />
        </doctrine:dbal>

with:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]                                                                                                                                                        
  [ERROR 1824] Element '{http://symfony.com/schema/dic/doctrine}connection', attribute 'port': '%database_port%' is not a valid value of the atomic type 'xs:integer'. (in /var/www/nde/app/config/config.xml - line 95, column 0)  

onFlush events with 2 or more dbal connections throw ErrorExceptions

Using Symfony 2.1 BETA. In configuration's with 2 connections, onFlush events written to (appDevDebugProject|appProd)Container.php contain calls to addEventListener. The method signature for the 2nd connection is incorrect. Changing the order the connection's are specified produces the incorrect signature on whatever happens to be the 2nd connection.

Compare the signatures for MysqlConnectionService and PlatConnectionService:

appDevDebugProjectContainer.php

protected function getDoctrine_Dbal_MysqlConnectionService()
{
    $c->addEventListener(array(0 => 'onFlush'), $this->get('nrc_notice.notice.notice_listener'));
}


protected function getDoctrine_Dbal_PlatConnectionService()
{
    $c->addEventListener(array(0 => array(0 => 'onFlush')), $this->get('nrc_notice.notice.notice_listener'));
}

Error Message

ErrorException: Warning: Illegal offset type in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115

in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115
at ErrorHandler->handle('2', 'Illegal offset type', '/Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php', '115', array('events' => array(array('onFlush')), 'listener' => object(NoticeListener), 'hash' => '000000000bfa891500000000295a660c', 'event' => array('onFlush'))) in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 115
at ContainerAwareEventManager->addEventListener(array(array('onFlush')), object(NoticeListener)) in /Applications/MAMP/htdocs/checknet.local/app/cache/dev/appDevDebugProjectContainer.php line 272
at appDevDebugProjectContainer->getDoctrine_Dbal_PlatConnectionService() in /Applications/MAMP/htdocs/checknet.local/app/bootstrap.php.cache line 194
at Container->get('doctrine.dbal.plat_connection') in /Applications/MAMP/htdocs/checknet.local/app/cache/dev/appDevDebugProjectContainer.php line 370
at appDevDebugProjectContainer->getDoctrine_Orm_PlatEntityManagerService() in /Applications/MAMP/htdocs/checknet.local/app/bootstrap.php.cache line 194
at Container->get('doctrine.orm.plat_entity_manager') in /Applications/MAMP/htdocs/checknet.local/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ManagerRegistry.php line 35

My config.yml

doctrine:
    dbal:
        default_connection: mysql
        connections:
            mysql:
                 driver: etc...
            plat:
                 driver_class:   etc...

My services.yml

services:
  nrc_notice.notice.notice_listener:
     class: Some\Listener\Class
     arguments:
       container: '@service_container'
     tags:
        - { name: kernel.event_listener, event: nrc_notice.notice.change.approved, method: onNotify }

Similar pattern occurs while adding more connections:

protected function getDoctrine_Dbal_MysqlConnectionService()
{
    $c->addEventListener(array(0 => 'onFlush'), $this->get('nrc_notice.notice.notice_listener'));
}

protected function getDoctrine_Dbal_Mysql2ConnectionService()
{
    $c->addEventListener(array(0 => array(0 => 'onFlush')), $this->get('nrc_notice.notice.notice_listener'));
}

protected function getDoctrine_Dbal_PlatConnectionService()
{
    $c->addEventListener(array(0 => array(0 => array(0 => 'onFlush'))), $this->get('nrc_notice.notice.notice_listener'));
}

Cannot dump definitions which have method calls.

Hi Fab, and all,

I want to help, but please note that this is a very elusive issue. I do not have a minimal repro test case, but I will try to elaborate:

Error message : "Cannot dump definitions which have method calls.".

Stacktrace:
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot dump definitions which have method calls.' in /var/www/test_deployment/shared/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php:1018\nStack trace:\n#0 /var/www/test_deployment/shared/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php(337): Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue(Object(Symfony\Component\DependencyInjection\Definition))\n#1 /var/www/test_deployment/shared/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php(572): Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceInstance('serializer', Object(Symfony\Component\DependencyInjection\Definition))\n#2 /var/www/test_deployment/shared/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php(631): Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService('serializer', Object(Symfony\Component\DependencyInjection\Definition))\n#3 /var/www/test_deploym in /var/www/test_deployment/shared/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php on line 1018

Faulting service (via php app/console container:debug), this is the value I got from dumping the "$class" in addServiceInstance .
sensio_framework_extra.converter.manager container Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager

Repro steps: NONE

However, I narrowed down the commit to a CONFLICT MERGE which requires manual intervention. From git diff, there are 4 major places which were affected:

  1. a constants file, containing things like class Status { const ACTIVE = 0; } which is not breaking
  2. test cases in phpunit, nothing fancy.
  3. services.xml, adding 4 new custom services

Apparently, the 3) is the most likely cause because the stacktrace also tells of something in adding a service instance. However, those were all custom developed instances and with prefixed ids, so would never conflict with the other bundle ones. Yet, the commit before this faulty commit works. No more idea on how to work.

A very suspicious bundle is the Sensio bundle, and the class is Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager .

Temporary fix: Comment out the 'Cannot dump definitions which have method calls.'. I don't like it, but I have to.

Environment and code revisions:

$php -v
PHP 5.4.0 (cli) (built: Mar 23 2012 15:08:43)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

$ apachectl -v
Server version: Apache/2.2.22 (Unix)
Server built: Mar 26 2012 17:54:48

"git log" at /vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper gives:
commit b55a43813e8fbcf4facd19ce1da0cd7acc67ce9b
Author: Fabien Potencier [email protected]
Date: Wed Nov 16 20:35:49 2011 +0100

"git log" at /vendor/bundles/Sensio/Bundle/FrameworkExtraBundle/Request/ParamConverter
commit dcd40eb4e2fff2d82fad644bb44fc2a40ccaf381
Merge: 96949b8 338cc31
Author: Fabien Potencier [email protected]
Date: Mon Nov 7 08:38:47 2011 +0100

The code change/commit is private resource, such as I cannot divulge information publicly to be indexed. Developers of the branch may want to ping me. Thanks.

It is possible to use DoctrineBundle with Symfony 2.0.9?

I've upgraded to the Doctrine 2.2.0 and also move Doctrine bundle to the Doctrine organization (as described here http://www.doctrine-project.org/blog/symfony-bundles-move).

Now I get an error:

PHP Fatal error:  Call to undefined method Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::addUserProviderFactory() in [...]\vendor\bundles\Doctrine\Bundle\DoctrineBundle\DoctrineBundle.php on line 39

AFAIK "addUserProviderFactory" is an Symfony 2.1 feature. So, I cannot run Doctrine bundle with 2.0.9 (I see no additional tags for 2.0.x support)?

Allow queries to be "explained" in WebProfilerBundle

Hi,

Currently it's possible to view the queries execute and parameters used.
It would be awesome if we also add a link close the query allowing to execute the EXPLAIN command, so people could also optimize Indexes if necessary.

Cheers,

Guilherme Blanco

Configuration caching issue

Hello,

Currently there's an issue in the way that Symfony2 is caching the configuration as it prevents of using multiple ports for memcached.

I've made this GIST as an example of config/cache of what happens. https://gist.github.com/2003670

As you can see, I'm using different ports for each type of cache but only the query_cache_driver (11532) is used, or at least it's the only one as far as I can tell.

Hope this helps.

Kind regards.

doctrine:generate:entities and composite primary keys

Hi,

I splitted a many-to-many relationship in two many-to-one relationships because I wanted to store attributes about the association (like the datetime, etc...).

I want the attributes post_id and tag_id (if Post and Tag are the two entities concerned) to be the two primary keys instead of a unique id. So, in the PostUserReference entity I deleted the $id propertie and the getter, I added @Orm\Id and @Orm\GeneratedValue(strategy="NONE") on my $user and $post properties. These properties are set via the constructor.

At first I thought I could keep the autogenerated setters setUser() and setPost() but when I run the tast doctrine:generate:entities, an error comes out at the exact line of the first setter. When I deleted these setters, the task could be run again but it re-generated the setters.

Is there a way (maybe an annotation) to specify that I don't want the setter generated ? Or am I doing something wrong ?

composer.json should not reference symfony/symfony

Existing "symfony/symfony": "2.1.*" requirement forces composer to download all symfony components, but I really doubt that DoctrineBundle requires form, for example. So instead of carpet bombing, it should specify exactly what symfony components it needs.

Custom Mapping Type from bundles

It will be useful to have an availability defining maping types, ex. have a bundle with many custom types. For now it can be done with appending your types to doctrine.dbal.connection_factory.types parameter (it works only if your bundle is loaded after Doctrine one).

Tags with CompilerPass are used for similar cases, but as typesConfig is just an array it doesn't seem so cool:

Use some interface/class and tag it:

interface TypeProvider
{
    public function getTypesConfig();
}
<service id="acme_bundle.dbal.type_provider" class="TypeProviderImpl">
    <argument type="collection">
        <argument key="custom">AcmeBundle\DBAL\Type\CustomType</argument>
    </argument>
    <tag name="doctrine.dbal.type">
</service>

Or use some fake services which will be removed on compile

<service id="acme_bundle.dbal.type" class="AcmeBundle\DBAL\Type\CustomType">
    <tag name="doctrine.dbal.type" type="custom">
</service>

Another way is don't use tags but use some parameter pattern like doctrine.dbal.types.bundle_name, collect them with CompilerPass and add to doctrine.dbal.connection_factory.types.

<parameter key="doctrine.dbal.types.bundle_name" type="collection">
    <parameter key="custom">AcmeBundle\DBAL\Type\CustomType</parameter>
</parameter>

Does anybody interesting in such feature? What implementation will be better?

SQLite database path shouldn't be quoted with `quoteSingleIdentifier` ([14] Unable to open database file))

In pull request #68 the database name gets escaped with quoteSingleIdentifier, however this same variable is also used for the path when using SQLite resulting in the path containing quote characters at the start/end, as can be seen in the below example:

xeross@Flutterbox ~/dev/projects/symfony2-todo/vendor/doctrine % php ../../app/console doctrine:database:create
string(55) ""/home/xeross/dev/projects/symfony2-todo/app/db.sqlite""
Could not create database for connection named /home/xeross/dev/projects/symfony2-todo/app/db.sqlite
SQLSTATE[HY000] [14] unable to open database file

Should be fixed by checking if $params['path'] is set and if so don't quote, will add patch shortly.

Configuration : addDefaultsIfNotSet on a prototype node

Since I updated to symfony 2.1, I get this error :

[Symfony\Component\Config\Definition\Exception\InvalidDefinitionException]                                                    
Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::addDefaultsIfNotSet() is not applicable to prototype nodes.

Seems related to getOrmEntityManagersNode(), line 215.

[2.0] Multiple entity managers + debug=false + env=dev fails

On the 2.0 branch, when using multiple entity managers and running a console command with --no-debug and --env=dev, I get:

[RuntimeException]
Cannot dump definitions which have method calls.

Which originates from the Symfony\Component\DependencyInjection\Dumper\PhpDumper.

This only happens with the debug=false and env=dev combination.

FWIW, here's a stack trace:

array(11) {
  [0]=>
  array(5) {
    ["file"]=>
    string(117) "/project/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php"
    ["line"]=>
    int(377)
    ["function"]=>
    string(9) "dumpValue"
    ["class"]=>
    string(54) "Symfony\Component\DependencyInjection\Dumper\PhpDumper"
    ["type"]=>
    string(2) "->"
  }
  [1]=>
  array(5) {
    ["file"]=>
    string(117) "/project/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php"
    ["line"]=>
    int(538)
    ["function"]=>
    string(21) "addServiceMethodCalls"
    ["class"]=>
    string(54) "Symfony\Component\DependencyInjection\Dumper\PhpDumper"
    ["type"]=>
    string(2) "->"
  }
  [2]=>
  array(5) {
    ["file"]=>
    string(117) "/project/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php"
    ["line"]=>
    int(596)
    ["function"]=>
    string(10) "addService"
    ["class"]=>
    string(54) "Symfony\Component\DependencyInjection\Dumper\PhpDumper"
    ["type"]=>
    string(2) "->"
  }
  [3]=>
  array(5) {
    ["file"]=>
    string(117) "/project/vendor/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php"
    ["line"]=>
    int(93)
    ["function"]=>
    string(11) "addServices"
    ["class"]=>
    string(54) "Symfony\Component\DependencyInjection\Dumper\PhpDumper"
    ["type"]=>
    string(2) "->"
  }
  [4]=>
  array(5) {
    ["file"]=>
    string(63) "/project/app/bootstrap.php.cache"
    ["line"]=>
    int(877)
    ["function"]=>
    string(4) "dump"
    ["class"]=>
    string(54) "Symfony\Component\DependencyInjection\Dumper\PhpDumper"
    ["type"]=>
    string(2) "->"
  }
  [5]=>
  array(5) {
    ["file"]=>
    string(63) "/project/app/bootstrap.php.cache"
    ["line"]=>
    int(780)
    ["function"]=>
    string(13) "dumpContainer"
    ["class"]=>
    string(35) "Symfony\Component\HttpKernel\Kernel"
    ["type"]=>
    string(2) "->"
  }
  [6]=>
  array(5) {
    ["file"]=>
    string(63) "/project/app/bootstrap.php.cache"
    ["line"]=>
    int(513)
    ["function"]=>
    string(19) "initializeContainer"
    ["class"]=>
    string(35) "Symfony\Component\HttpKernel\Kernel"
    ["type"]=>
    string(2) "->"
  }
  [7]=>
  array(5) {
    ["file"]=>
    string(113) "/project/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php"
    ["line"]=>
    int(80)
    ["function"]=>
    string(4) "boot"
    ["class"]=>
    string(35) "Symfony\Component\HttpKernel\Kernel"
    ["type"]=>
    string(2) "->"
  }
  [8]=>
  array(5) {
    ["file"]=>
    string(113) "/project/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php"
    ["line"]=>
    int(66)
    ["function"]=>
    string(16) "registerCommands"
    ["class"]=>
    string(50) "Symfony\Bundle\FrameworkBundle\Console\Application"
    ["type"]=>
    string(2) "->"
  }
  [9]=>
  array(5) {
    ["file"]=>
    string(100) "/project/vendor/symfony/src/Symfony/Component/Console/Application.php"
    ["line"]=>
    int(118)
    ["function"]=>
    string(5) "doRun"
    ["class"]=>
    string(50) "Symfony\Bundle\FrameworkBundle\Console\Application"
    ["type"]=>
    string(2) "->"
  }
  [10]=>
  array(5) {
    ["file"]=>
    string(51) "/project/app/console"
    ["line"]=>
    int(22)
    ["function"]=>
    string(3) "run"
    ["class"]=>
    string(37) "Symfony\Component\Console\Application"
    ["type"]=>
    string(2) "->"
  }
}

Side note: When removing the additional entity managers (leaving just one default one), the container compiles. Re-adding them after that does not trigger re-compilation, so it just ignores the newly added entity managers.

/app/cache/dev/doctrine/orm/Proxies/__CG__EntityClass.php does not exist (generateProxyClasses in 2.2.1)

Theres a Problem on generating Proxie Classes in Version 2.2.1.
In DoctrineBundle on Line 74 you compare the classes with the origin Class Name. But the Origin Class Name has the Prefix CG.

if ($name == $originalClassName) {
    $em->getProxyFactory()->generateProxyClasses(array($class));
}

echo $name; > 'SomeEntityClass'
echo $originalClassName; > __CG__SomeEntityClass

This Prefix must be replaced and the Problem is solved.

if ($name == str_replace('__CG__', '', $originalClassName)) {
    $em->getProxyFactory()->generateProxyClasses(array($class));
}

A way to enable auto_mapping with multipe Entity Manager

Currently i have 50 active bundles in my project.

10 bundles do not require database interaction.
39 bundles uses the default entity manager, that uses the default dbal connection.
1 bundle use the 'custom' entity manager, that uses the 'custom' dbal connection.

to do this, i need to disable auto_mapping and specify all mappings.

doctrine:
    dbal:
        default_connection: default
        connections:
                default:
                    driver:   %database_driver%
                   ....
                custom:
                    driver:   pdo_pgsql
                    ...
    orm:
        entity_managers:
            default:
                mappings:
                    Bundle1: ~
                    Bundle2: ~
                    Bundle3: ~
                    Bundle4: ~
                    Bundle4: ~
                    ........
            superdpi:
                mappings: 
                    SuperDpiCoreBundle: ~
                connection: custom     

this is very annoying...
currently i've resolved the problem in this way:
1)

doctrine:
    orm:
        entity_managers:
            default:
                auto_mapping : true
            superdpi:
                mappings: 
                    SuperDpiCoreBundle: ~
                connection: custom     

removed auto_mapping check inside DoctrineExtension::loadOrmEntityManager()
3)
removed auto mapping expansion inside AbstractDoctrineExtension::loadMappingInformation()
4) added DoctrineExtension::collectAutoMappings()

protected function collectAutoMappings (array $entityManagerConfigs, ContainerBuilder $container){
    $defindedBundles = array_keys($container->getParameter('kernel.bundles'));
    foreach ($entityManagerConfigs as $name => $entityManager) {
        if(isset($entityManager['auto_mapping']) && $entityManager['auto_mapping']){
            foreach ($defindedBundles as $bundle){
                foreach ($entityManagerConfigs as $name2 => $entityManager2) {
                    if($entityManager2['mappings'][$bundle]){
                        continue 2;
                    }
                }
                $entityManagerConfigs[$name]['mappings'][$bundle]['mapping']=true;
            }
        }
    }
    return $entityManagerConfigs;
}
  1. added
$config['entity_managers'] = $this->collectAutoMappings($config['entity_managers'], $container);

inside DoctrineExtension::ormLoad() just before

foreach ($config['entity_managers'] as $name => $entityManager) {
       $entityManager['name'] = $name;
       $this->loadOrmEntityManager($entityManager, $container);
}

suggestions?

make the orm part optional

it seems like its impossible to not include the ORM when including this Bundle. for example several commands are always loaded that extend from ORM commands, which break if the ORM lib isn't available

FOSUserBundle SQL error

Hi developers of FOSUserBundle. I had written this issue on Symfony forum but noone is answering, so maybe I've found the bug of Doctrine or FOSUserBundle
I'm using Symfony 2.0.12, so I've installed as git submodules FOSUserBundle, created User Entity with one-to-one relationship with Company Entity, here goes the code:

<?php

namespace AV\TradeBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**

  • @Orm\Entity

  • @Orm\Table(name="fos_user")
    /
    class User extends BaseUser
    {
    /
    *

    • @Orm\Id
    • @Orm\Column(type="integer")
    • @Orm\GeneratedValue(strategy="AUTO")
      */
      protected $id;

    /**

    • @var company
      *
    • @Orm\OneToOne(targetEntity="Companies", mappedBy="user")
      *
      */
      private $company;

    public function __construct()
    {
    parent::__construct();
    // your own logic
    }

    public function getCompany() {
    return $this->company;
    }

    public function setCompany($company) {
    $this->company = $company;
    }
    }

and piece of Company Entity:

container->get('fos_user.user_manager')->createUser($user); When I'm trying to login I see such error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't46.id' in 'on clause' The whole SELECT statement that I found in logs sounds like this one: SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, t18.id AS id19, t18.egrpou AS egrpou20, t18.business_form AS business_form21, t18.title AS title22, t18.phone_code AS phone_code23, t18.phone_country_code AS phone_country_code24, t18.phone AS phone25, t18.fax_code AS fax_code26, t18.fax_country_code AS fax_country_code27, t18.fax AS fax28, t18.website AS website29, t18.fio AS fio30, t18.birthday AS birthday31, t18.firm_created AS firm_created32, t18.employees_count AS employees_count33, t18.logo AS logo34, t18.zip AS zip35, t18.street AS street36, t18.position AS position37, t18.thumb_logo AS thumb_logo38, t18.description AS description39, t18.created_at AS created_at40, t18.email AS email41, t18.cities_id AS cities_id42, t18.regions_id AS regions_id43, t18.countries_id AS countries_id44, t18.user_id AS user_id45 FROM fos_user t0 LEFT JOIN companies t18 ON t18.user_id = t46.id WHERE t0.username_canonical = ? (["cfyzz"]) [] [] Does anyone know why it's not t0 in join condition but t46? If needed I'll show my deps.lock, maybe such situation was already fixed, but I was googling for answer for several days - and nothing. Thanks in advance

Problem with annotations namespaces when trying to guess form field type

If field type isn't set in Form/MyEntityType.php:

public function buildForm(FormBuilder $builder, array $options) 
  { 
      $builder 
          ->add('text')

Next exception is thrown when trying to guess type:
[Semantical Error] The annotation "@table" in class Entity\MyEntity was never imported. Did you maybe forget to add a "use" statement for this annotation?

If you put:
->add('text', 'textarea')
exception is not thrown

mapping annotations throws an exception

Using the latest master of doctrinebundle, I get the following exception

ServiceNotFoundException: The service "doctrine.orm.default_entity_manager" has a dependency on a non-existent service "annotation_reader".

When I specify a mapping as follows:

mappings:
    zikula_core_entities:
        type: annotation
        dir: %kernel.root_dir%/../src
        is_bundle: false
        prefix: Zikula

Symfony2 fails to manage multiple connections and relationships between different bundles

EDIT: Assetic has changed its path, so you can remove assetic tags from app/config/config.yml and app/config/config_dev.yml to get rid of the error.

Hi,

i'm writting this thread in order to detail the full story about what's happening to me when working with multiple connections.

I have an Oracle database which is accessed by OracleBundle through oracle connection, then i have a MySQL database which is accessed by MySQLBundle using mysql connection. Inside MySQLBundle i have an entity which tries to store, as FK, a field which belongs to another entity which resides inside OracleBundle. AFAIK it can't be done by Symfony2, but in the testing process and before linking each entity with each other, so there are no FK to link each entity, while creating the above ( http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html ) "project" i noticed doctrine bundle can't manage multiple connections properly.

What's happening to me when working with multiple connections? If you download the tar.gz file you could see there is a FooBundle and a BarBundle, each one using its own connection an of course each own entity manager. Inside FooBundle there is Foo entity and inside Bar Bundle there is Bar entity, each one has each fixture to load some info to the database. The issue i'm talking about appears here when trying to load the fixtures.

**First i create both databases, each one using each own entity manage so also using each own connection:
php ./symfony doctrine:database:drop --connection="bar" --force'
php ./symfony doctrine:database:drop --connection="foo" --force'
php ./symfony doctrine:database:create --connection="bar"
php ./symfony doctrine:database:create --connection="foo"

**Then i successfully create the schema:
php ./symfony doctrine:schema:create --em="bar"
php ./symfony doctrine:schema:create --em="foo"

**And finally i try to load the fixtures which throughs me an error:
php ./symfony doctrine:fixtures:load --em="foo"
php ./symfony doctrine:fixtures:load --em="bar"

**That's the error i get, so i think Symfony has some kind of bug:
Created database for connection named bar
Created database for connection named foo
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myFooBundleBundle\Entity\Foo is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

**But if i randomly remove a fixture, no matter which one, everything runs fine:
mv src/myVendor/myBarBundleBundle/DataFixtures/ORM/Bar.php /tmp/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo

**But when both fixtures exists:
mv /tmp/Bar.php src/myVendor/myBarBundleBundle/DataFixtures/ORM/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

Doctrine 2.1.6 Reverse Engineering 1-n (one to many) association misunderstood as 1-1 (one to one)

I found an odd behaviour of Doctrine's reverse engineering process, just create two simple tables tied by a simple 1-n relationship, take a look at the snap of the folowing SQL code:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

DROP SCHEMA IF EXISTS `ACME` ;
CREATE SCHEMA IF NOT EXISTS `ACME` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `ACME` ;

-- -----------------------------------------------------
-- Table `ACME`.`task`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ACME`.`task` ;

CREATE  TABLE IF NOT EXISTS `ACME`.`task` (
  `id_task` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `description` VARCHAR(45) NULL ,
  PRIMARY KEY (`id_task`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ACME`.`tag`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `ACME`.`tag` ;

CREATE  TABLE IF NOT EXISTS `ACME`.`tag` (
  `id_tag` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(50) NULL ,
  `task_id` INT UNSIGNED NOT NULL ,
  PRIMARY KEY (`id_tag`) ,
  INDEX `fk_tag_task` (`task_id` ASC) ,
  CONSTRAINT `fk_tag_task`
    FOREIGN KEY (`task_id` )
    REFERENCES `ACME`.`task` (`id_task` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;



SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

I have a Symfony2 netbeans project at

/Applications/MAMP/htdocs/Acme

and from that location, according to

http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html

in a terminal I did:

$ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:convert yml ./src/Acme/TaskBundle/Resources/config/doctrine/ --from-database --force
Processing entity "Tag"
Processing entity "Task"

Exporting "yml" mapping information to "/Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine"

$ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:import Acme\TaskBundle yml
Importing mapping information from "default" entity manager
  > writing /Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine/Tag.orm.yml
  > writing /Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine/Task.orm.yml

$ ./../../bin/php/php5.3.6/bin/php app/console doctrine:generate:entities Acme\TaskBundle
Generating entities for bundle "AcmeTaskBundle"
  > backing up Tag.php to Tag.php~
  > generating Acme\TaskBundle\Entity\Tag
  > backing up Task.php to Task.php~
  > generating Acme\TaskBundle\Entity\Task

The fact is that it only seems ok, because if you take a look at "Tag.orm.yml":

Acme\TaskBundle\Entity\Tag:
  type: entity
  table: tag
  fields:
    idTag:
      id: true
      type: integer
      unsigned: false
      nullable: false
      column: id_tag
      generator:
        strategy: IDENTITY
    name:
      type: string
      length: 50
      fixed: false
      nullable: true
  oneToOne:
    task:
      targetEntity: Task
      cascade: {  }
      mappedBy: null
      inversedBy: null
      joinColumns:
        task_id:
          referencedColumnName: id_task
      orphanRemoval: false
  lifecycleCallbacks: {  }

It created a oneToOne relationship and not a oneToMany !

If you need any more confirmation, here are _Task.php_ and _Tag.php_:

_Task.php_

<?php

namespace Acme\TaskBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Acme\TaskBundle\Entity\Task
 */
class Task
{
    /**
     * @var integer $idTask
     */
    private $idTask;

    /**
     * @var string $description
     */
    private $description;


    /**
     * Get idTask
     *
     * @return integer 
     */
    public function getIdTask()
    {
        return $this->idTask;
    }

    /**
     * Set description
     *
     * @param string $description
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }

    /**
     * Get description
     *
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }
}

_Tag.php_

<?php

namespace Acme\TaskBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Acme\TaskBundle\Entity\Tag
 */
class Tag
{
    /**
     * @var integer $idTag
     */
    private $idTag;

    /**
     * @var string $name
     */
    private $name;

    /**
     * @var Acme\TaskBundle\Entity\Task
     */
    private $task;


    /**
     * Get idTag
     *
     * @return integer 
     */
    public function getIdTag()
    {
        return $this->idTag;
    }

    /**
     * Set name
     *
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set task
     *
     * @param Acme\TaskBundle\Entity\Task $task
     */
    public function setTask(\Acme\TaskBundle\Entity\Task $task)
    {
        $this->task = $task;
    }

    /**
     * Get task
     *
     * @return Acme\TaskBundle\Entity\Task 
     */
    public function getTask()
    {
        return $this->task;
    }
}

linuxatico

[WebProfiler] Add cache section

It would be great to have a cache section in the sf2 webprofiler panel.
Useful information are:

  • hits
  • misses
  • uptime
  • size
  • status (monitoring)
  • availabe drivers
  • content

Create tag for Symfony 2.0.14

I try to use latest Symfony tag 2.0.14, but it couldn't work with doctrine/DoctrineBundle dev-master, because it requires Symfony dev-master. Can you create tag for Symfony 2.0.14 with proper composer.json?

Add SQLFilter parameter in the configuration for Doctrine ORM

Hello there,

In doctrine 2.2, a new feature was added : sql filters made by @asm89 => doctrine/orm#210.

But the doctrinebundle seems not to enable this in the configuration, so I'd like to add it.

Maybe we could add it as follow, in the config.yml :

doctrine:

    orm:
        filters:
            my_first_filter:
                class: 'Fully\Qualified\Class\Name'
                enabled: true
            my_second_filter:
                class: 'Fully\Qualified\Class\Name2'
                enabled: true

and so modify the Configuration and DoctrineExtension classes to enable this?

What do you think about this?

HasLifecycleCallbacks on MappedSuperclass not triggered

Are Lifecycle call backs supported when defined in MappedSuperclassees. I have a class File from which I extend Image but lyfecycles are never triggered unless I define them in the child class( Image) and add the HasLifecycleCallbacks annotation there. Is this a bug? Everything else seems to work when using MappedSuperclass.

/**

  • Description of File
    *
    *
  • @Orm\MappedSuperclass
  • @Orm\HasLifecycleCallbacks
    /
    class File
    {
    /
    *
    • @Orm\PrePersist()
    • @Orm\PreUpdate()
      */
      public function preUpload()
      {
      if (null !== $this->file)
      {
      $this->path = uniqid() . '.' . $this->file->guessExtension();
      }
      }
      }

/**
*

  • @Orm\Table(name="image")
  • @Orm\Entity
    */
    class Image extends File
    {
    }

Should the configuration support "keepSlave"?

In DBAL's MasterSlaveConnection, it supports the keepSlave option:

$this->keepSlave = isset($params['keepSlave']) ? (bool)$params['keepSlave'] : false;

@stof is there any reason you chose to not add it when you implemented #53?

I am finding that the slave is overwritten (and ignored) because of calls to SET NAMES UTF8 in the same request so I'd like to be able to configure this in the options.

Note: a current work around I am using to to wrap DBAL's MasterSlaveConnection in my own class and just set the keepSlave setting to true in the constructor. This is hard-coded though, not configurable.

Custom platform is not taken into account

When defining a custom platform in the configuration of Symfony 2 like below (config.yml) :

services:
    my_platform:
        class: Doctrine\DBAL\Platforms\MyPlatform

doctrine:
    dbal:
        options:
            driver: %driver%
            platform: @my_platform

the custom platform MyPlatform is not taken into account and the driver default one is used instead.

Allowing services as filters

It's more related to the orm but I can't create an issue out there.

Is there a particular reason why we can only add filter class names in the orm config and not objects?

For example when using the orm with symfony2 it would allow to use services as filters, currently I guess we have to manually get the filter from the em and set the needed dependencies.

If you're interested by this I can work on a PR in the orm to allow setting a filter with both an object or a class, and then retrieving or creating it in the FilterCollection enable method.

Refreshing an entity after disabling a filter has no effect

The situation:

I have a Person with a 1-to-1 relation to User, fetch mode is EAGER. The user has a deleted flag, which in this case is set to true. The filter automatically adds a "deleted = 0" to the join query

I wish to fetch the user anyway, so I disable the filter and execute a refresh:

$em->getFilters()->disable('soft_delete');
$em->refresh($person);

Unfortunately, this doesn't work as the left join part of the query is saved line 971 through 973 in BasicEntityPersister:

        if ($this->_selectColumnListSql !== null) {
            return $this->_selectColumnListSql;
        }

if I remove these lines, everything works fine...

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.