Code Monkey home page Code Monkey logo

doctrineormmodule's Introduction

Doctrine ORM Module for Laminas

Build Status Code Coverage Latest Stable Version Total Downloads

The DoctrineORMModule leverages DoctrineModule and integrates Doctrine ORM with Laminas quickly and easily. The following features are intended to work out of the box:

  • Doctrine ORM support
  • Multiple ORM entity managers
  • Multiple DBAL connections
  • Reuse existing PDO connections in DBAL connection

Installation

Run the following to install this library using Composer:

composer require doctrine/doctrine-orm-module

Documentation

Please check the documentation on the Doctrine website for more detailed information on features provided by this component. The source files for the documentation can be found in the docs directory.

doctrineormmodule's People

Contributors

bakura10 avatar basz avatar davidwindell avatar demiankatz avatar driehle avatar fabiocarneiro avatar fbrinker avatar gianarb avatar greg0ire avatar ittmann avatar kokspflanze avatar merorafael avatar michalbundyra avatar mpalourdio avatar neeckeloo avatar nono1971 avatar ocramius avatar prolic avatar rogervila avatar slamdunk avatar snapshotpl avatar superdweebie avatar svycka avatar thestanislav avatar thomasvargiu avatar tomhanderson avatar villermen avatar volkan avatar waahhhh avatar zluiten 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrineormmodule's Issues

Cannot use cli for alternate entitymanagers

If I build a set of modules for an application, and I use different entity managers to manage connectivity to these modules, I cannot use the CLI tool at all, as it is hard-coded to use orm_default.

cli: doctrine-module. There is no registered "doctrine.cli" service

After the last update I am getting error with Doctrine command line. Here is the exception:
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli'

Whitespace issue

module.doctrine_orm.config.php.dist sample config file starts with whitespace so its leading to header sent error when you just copy paste it.

Issue with querying and CLI commands

I've installed the DoctrineORMModule as per instructions and am able save (persist & flush) data. However I'm unable to query or use the CLI commands. I'm using the ZendSkeleton module and the latest master branch of zf2.

Below is an example of the CLI issue:

./vendor/DoctrineModule/bin/doctrine odm:generate:documents ./module/Application/src/Application/

PHP Notice:  Trying to get property of non-object in
/var/www/SiteTpl/vendor/DoctrineMongoODMModule/Module.php on line 48

Notice: Trying to get property of non-object in
/var/www/SiteTpl/vendor/DoctrineMongoODMModule/Module.php on line 48
PHP Fatal error:  Uncaught exception 'Exception' with message '
Doctrine could not be autoloaded - ensure it is in the correct path.
           ' in /var/www/SiteTpl/vendor/DoctrineMongoODMModule/Module.php:62
Stack trace:
#0 [internal function]:
DoctrineMongoODMModule\Module->modulesLoaded(Object(Zend\Module\ModuleEvent))
...

I've created documents:

<?php
$dm = $this->getLocator()->get('mongo_dm');
$pg = new Page();
$pg->setName('testpage1');
$dm->persist($pg);
$dm->flush();

validated their existence:

> db.Page.find()
{ "_id" : ObjectId("4fa156923f0c4f5434000005"), "name" : "testpage1", "type" : "page" }

but when attempting to query:

<?php
$dm = $this->getLocator()->get('mongo_dm');
$dm->createQueryBuilder('Page');

Warning: class_parents(): Class Page does not exist and could not be loaded in /var/www/SiteTpl/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336 Warning: array_reverse() expects parameter 1 to be array, boolean given in /var/www/SiteTpl/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336 Warning: Invalid argument supplied for foreach() in /var/www/SiteTpl/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 336 
...

below is a sample entity file:

<?php
namespace Application\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
 * @ODM\Document
 * @ODM\DiscriminatorField(fieldName="type")
 * @ODM\DiscriminatorMap({"page"="Page", "product"="Product"})
 * */
class Page
{
    /** @ODM\Id */
    private $id;

    /**
     * @ODM\Field(type="string")
     */
    private $name;

    /**
     * @return the $id
     */
    public function getId ()
    {
        return $this->id;
    }

    /**
     * @param field_type $id
     */
    public function setId ($id)
    {
        $this->id = $id;
    }

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

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

doctrine migrations

Hi. I'm trying to generate migrations by command line
I have generated my migration class but when I want execute a especific version I have this error

InvalidArgumentException: The helper "dialog" is not defined

Zend\Form Interaction, edit entities with ManyToMany relationship

Hello there, i have a defined ManyToMany relationship and adding the relationship to the database works fine with given form structure:

class SomeFieldset extends Fieldset implements InputFilterProvider
{
    //somecode
    $this->add(array(
        'type' => 'Zend\Form\Element\Collection',
        'name' => 'options',
        'options' => array(
            'label' => 'Please choose Options for this Type',
            'count' => 5,
            'should_create_template' => true,
            'allow_add' => true,
            'target_element' => array(
                'type' => 'DoctrineORMModule\Form\Element\DoctrineEntity',
                'name' => 'option',
                'options' => array(
                    'label' => 'Name of the Option',
                    'object_manager' => $em,
                    'target_class' => 'AssetManagement\Entity\Option',
                    'property' => 'name'
                ),
                'attributes' => array(
                    'required' => true
                )
            )
        )
    ));
    //somecode
}

Using the same form structure to actually edit this entity results in the following Notice and fatal error:

Notice: Undefined property: DoctrineORMModule\Form\Element\DoctrineEntity::$object in
%rootPath%\vendor\zendframework\zendframework\library\Zend\Form\Element\Collection.php on line 428

Fatal error: Class name must be a valid object or a string in 
%rootPath%\vendor\zendframework\zendframework\library\Zend\Form\Element\Collection.php on line 428

This only happens if the ManyToMany relationship actually has a connected relation. If editing an entity that has no relations defined in the database, the form works perfect. As soon as there are relations stored at the database, abovementioned notice and error pops up.

Edit: Full Code is currently visible at AssetManagement Git on this account

ZendStorageCacheFactory

got an error after install. โ€œClass ZendStorageCacheFactoryโ€ not found โ€ฆ

had to change โ€˜doctrine-modules/src/DoctrineModule/Module.phpโ€™ in lines 23 and 66 from โ€œZendStorageCacheFactoryโ€ to โ€œZendCacheStorageFactoryโ€

Annotations causing load failures

After installing this module on a fresh install of ZF2 (after installing DoctrineModule), it caused the framework to die without explanation. I admittedly didn't go far into the issue since I don't plan on using Annotations... so I simply disabled them in the config which fixed the issue.

I only traced the problem as far as the module definition, it fails on line 58 of Module.php after:

AnnotationRegistry::registerFile($libfile);

Not sure how much help this is, but I don't have much time to debug this one.

Problem installing

I'm triying to install DoctrineORMModule in a blank ZendSkeletonApplication, and it doesnยดt work for me, but it used to when I tried it, like a month ago, the error:
Warning: require_once([mydir]\ZendSkeletonApplication\vendor\DoctrineORMModule/vendor/doctrine-orm/lib/vendor/doctrine-dbal/lib/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php) [function.require-once]: failed to open stream: No such file or directory in [mydir]\ZendSkeletonApplication\vendor\ZendFramework\library\Zend\Loader\ClassMapAutoloader.php on line 153

Thanks a lot for your work!

Allow adding "filters" to configuration

Please refer: http://docs.doctrine-project.org/en/latest/reference/filters.html

Although it is possible to grab the config object from ServiceManager, it would be nice/cleaner to add filters to a config file and have them automatically added to the Doctrine config object.

A partial sample config file might look like:

    return array(
        'doctrine' => array(
            'configuration' => array(
                'orm_default' => array(
                    'filters' => array(
                        'locale' => '\Doctrine\Tests\ORM\Functional\MyLocaleFilter'
                    )
                )
            )
        )
    )

Implementation is trivial. DoctrineORMModule\Service\ConfigurationFactory.php and DoctrineORMModule\Options\Configuration.php need to be updated to handle the new configuration value(s).

Move form extension to DoctrineModule

The form- related classes can be refactored to use ObjectManager and ObjectRepository only.
Should be moved to DoctrineModule, and tests have to be fixed too.

FirebugProfiler

Hi there,
What about \ZendX\Doctrine2\FirebugProfiler integration ?

David

Apache HTTP Server error

Hello, just installed DoctrineORMModule on a clean ZendSkeletonApplication running on Apache 2.2.21 (WampServer 2.2D) and when I try to run the application, it throws an Apache HTTP Server popup and server not found page. I have no idea where to beging with for finding a solution so I would be very grateful if you coul help me. Thanks a lot.

Not all identifier properties can be found in the ResultSetMapping: id

File:

vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Pagination\CountOutputWalker.php:117

Message:

Not all identifier properties can be found in the ResultSetMapping: id

Stack trace:

#0 vendor\doctrine\orm\lib\Doctrine\ORM\Query\Exec\SingleSelectExecutor.php(38): Doctrine\ORM\Tools\Pagination\CountOutputWalker->walkSelectStatement(Object(Doctrine\ORM\Query\AST\SelectStatement))
#1 vendor\doctrine\orm\lib\Doctrine\ORM\Query\SqlWalker.php(241): Doctrine\ORM\Query\Exec\SingleSelectExecutor->__construct(Object(Doctrine\ORM\Query\AST\SelectStatement), Object(Doctrine\ORM\Tools\Pagination\CountOutputWalker))
#2 vendor\doctrine\orm\lib\Doctrine\ORM\Query\Parser.php(325): Doctrine\ORM\Query\SqlWalker->getExecutor(Object(Doctrine\ORM\Query\AST\SelectStatement))
#3 vendor\doctrine\orm\lib\Doctrine\ORM\Query.php(233): Doctrine\ORM\Query\Parser->parse()
#4 vendor\doctrine\orm\lib\Doctrine\ORM\Query.php(245): Doctrine\ORM\Query->_parse()
#5 vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php(737): Doctrine\ORM\Query->_doExecute()
#6 vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php(562): Doctrine\ORM\AbstractQuery->execute(NULL, 3)
#7 vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Pagination\Paginator.php(144): Doctrine\ORM\AbstractQuery->getScalarResult()
#8 vendor\doctrine\doctrine-orm-module\src\DoctrineORMModule\Paginator\Adapter.php(86): Doctrine\ORM\Tools\Pagination\Paginator->count()
#9 vendor\zendframework\zendframework\library\Zend\Paginator\Paginator.php(982): DoctrineORMModule\Paginator\Adapter->count()
#10 vendor\zendframework\zendframework\library\Zend\Paginator\Paginator.php(660): Zend\Paginator\Paginator->_calculatePageCount()
#11 module\Candidat\src\Candidat\Controller\CatalogueController.php(31): Zend\Paginator\Paginator->setItemCountPerPage('30')
#12 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(150): Candidat\Controller\CatalogueController->listeAction()
#13 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))
#14 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#15 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#18 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#19 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#20 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#21 vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(289): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

The helper "em" is not defined.

Is this a bug?

./vendor/bin/doctrine orm:schema-tool:create --verbose



  [InvalidArgumentException]       
  The helper "em" is not defined.  



Exception trace:
 () at ./vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php:79
 Symfony\Component\Console\Helper\HelperSet->get() at ./vendor/symfony/console/Symfony/Component/Console/Command/Command.php:541
 Symfony\Component\Console\Command\Command->getHelper() at ./vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:42
 Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() at ./vendor/symfony/console/Symfony/Component/Console/Command/Command.php:239
 Symfony\Component\Console\Command\Command->run() at ./vendor/symfony/console/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at ./vendor/symfony/console/Symfony/Component/Console/Application.php:106
 Symfony\Component\Console\Application->run() at ./vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php:41
 Doctrine\ORM\Tools\Console\ConsoleRunner::run() at ./vendor/doctrine/orm/bin/doctrine.php:43
 include() at ./vendor/doctrine/orm/bin/doctrine:4


orm:schema-tool:create [--dump-sql]

unbelievable bug with composer autoload.php

iv fully installed your doctrine and doctrine orm module
and tested it ... entity manager works fine and i used it to persist entities without problem

i started to write a form that extends zend form

in my indexAction in my Controller i have the following code:

$formx = new LoginForm();
        $formx->setAttribute('action', $this->url('album', array('action' => 'add')));


        var_dump($formx);
        $model = new ViewModel(array(

                'form'  => $formx,
            ));
return $model;

result of vardump :

object(Application\Form\LoginForm)[237]
  protected 'attributes' => 
    array
      'method' => string 'post' (length=4)
      'name' => string 'album' (length=5)
      'action' => 
        object(Zend\Mvc\Controller\Plugin\Url)[243]
          protected 'controller' => 
            object(Application\Controller\IndexController)[204]
              ...
  protected 'bindAs' => int 17
  protected 'bindOnValidate' => int 0
  protected 'baseFieldset' => null
  protected 'data' => null
  protected 'filter' => null

and so on ...

when i do this var_dump on my $form variable in index.phtml i get this :

$form = $this->form;

var_dump($form);

vardump result :

array
  1 => 
    object(Zend\Form\Element)[240]
      protected 'attributes' => 
        array
          'name' => string 'id' (length=2)
          'type' => string 'hidden' (length=6)
      protected 'label' => null
      protected 'labelAttributes' => null
      protected 'messages' => 
        array
          empty
      protected 'options' => 
        array
          empty
      protected 'value' => null
  0 => 
    object(Zend\Form\Element)[242]
      protected 'attributes' => 
        array
          'name' => string 'artist' (length=6)
          'type' => string 'text' (length=4)
      protected 'label' => string 'Artist' (length=6)
      protected 'labelAttributes' => null
...

as u can see i get array of form elements instead of FORM object

if i remove autoload.php from vendor folder
and remove loading of doctrinemodule and doctrineormmodule

i exactly get that form object in my view but with that autoload.php file it convert it ot array of form element :-O ~!

can u please help me

The helper "dialog" is not defined.

You have to inject an DialogHelper to execute the migrations:migrate-Command

<?php
            'doctrine_cli_helperset' => array(
                'injections' => array(
                    'set' => array(
                        array(
                            'helper' => 'Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper',
                            'alias' => 'em'
                        ),
                        array(
                            'helper' => 'Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper',
                            'alias' => 'db'
                        ),
                        array(
                            'helper' => 'Symfony\Component\Console\Helper\DialogHelper',
                            'alias' => 'dialog'
                        ),
                    ),
                ),
            ),

another orm driver?

i tried anything add another ORM driver to config file but fail

this code not works (module.config.php) :

'orm_driver_chain' => array(
'parameters' => array(
'drivers' => array(
'Accounting' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Accounting\Model',
'paths' => array(
DIR . '/../src/Accounting\Model'
)
)
)
)
),

is there any way to add multiple name spaces to driver ?
for example :

i have this :
'driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Admin\Model',
'paths' => array('module/Admin/src/Admin/Model')
),

but i want this :

'driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => array( Admin\Model', 'Accounting\Model')
'paths' => array('module/Admin/src/Admin/Model')
),

How to subscribe listener into module.config.php ?

Hi there.
I'd like to use i18n with Doctrine2 so i found gedmo
https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md

I want to setup my configuration file with the following code:
http://www.doctrine-project.org/blog/doctrine2-behavioral-extensions#setup
//setting the drivers
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$yourDefaultDriverImpl = new \Doctrine\ORM\Mapping\Driver\YamlDriver('/yml/mapping/files'); // only an example
$translatableDriverImpl = $doctrineOrmConfig->newDefaultAnnotationDriver(
'/path/to/library/DoctrineExtensions/lib/Gedmo/Translatable/Entity'
);
$chainDriverImpl->addDriver($yourDefaultDriverImpl, 'Entity');
$chainDriverImpl->addDriver($translatableDriverImpl, 'Gedmo\Translatable');
$doctrineOrmConfig->setMetadataDriverImpl($chainDriverImpl);
// attach listener to event manager
$evm = new \Doctrine\Common\EventManager();
$translationListener = new \Gedmo\Translatable\TranslationListener();
$translationListener->setTranslatableLocale('en_us');
$evm->addEventSubscriber($translationListener);

Here is what i did in my configuration file:

// driver settings
'entity_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Entity',
'paths' => array(APPLICATION_PATH . '/model/Entity')
),
'translatable_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'namespace' => 'Gedmo\Translatable',
'paths' => array(APPLICATION_PATH . '/vendor/Gedmo/Translatable/Entity')
),

'orm_driver_chain' => array(
'parameters' => array(
'drivers' => array(
'application_entity_driver' => $settings['entity_driver'],
'application_translatable_driver' => $settings['translatable_driver']

),
'cache' => $settings['cache']
)
),
'orm_evm' => array(
'parameters' => array(
'opts' => array(
'subscribers' => array(
'application_translatable_listener' => 'Gedmo\Translatable\TranslatableListener',
)
)
)
),

The following line:
'application_translatable_listener' => 'Gedmo\Translatable\TranslatableListener',

causes an arror:

Catchable fatal error: Argument 1 passed to Gedmo\Translatable\TranslatableListener::getTranslationClass() must be an instance of Gedmo\Translatable\Mapping\Event\TranslatableAdapter, instance of Gedmo\Mapping\Event\Adapter\ORM given, called in \vendor\Gedmo\Translatable\TranslatableListener.php on line 355 and defined in \vendor\Gedmo\Translatable\TranslatableListener.php on line 159

So i can't attach listener to event manager.

David

Doctrine\ORM\Mapping\DefaultNamingStrategy needed ?

Hi there,
i updated my configuration with the last revision of this module and dependencies:

PHP Error:
Class 'Doctrine\ORM\Mapping\DefaultNamingStrategy' not found

I can see that this class has been removed from classmap file but it seems to me that i need it.
Here is my backtrace:

Doctrine\ORM\Configuration::getNamingStrategy() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\Configuration.php : 574 Show File
Doctrine\ORM\Configuration::newClassMetadataInstance() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php : 398 Show File
Doctrine\ORM\Mapping\ClassMetadataFactory::loadMetadata() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php : 271 Show File
Doctrine\ORM\Mapping\ClassMetadataFactory::getMetadataFor() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php : 178 Show File
Doctrine\ORM\Mapping\ClassMetadataFactory::getClassMetadata() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\EntityManager.php : 269 Show File
Doctrine\ORM\EntityManager::getRepository() at J:\zf2\module\DoctrineORMModule\vendor\doctrine-orm\lib\Doctrine\ORM\EntityManager.php : 613 Show File
Doctrine\ORM\EntityManager::getOptions() at J:\zf2\module\Localisation\src\Localisation\Model\Service\PaysService.php : 10 Show File

Module.php (71) Can't find 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' uncaught exception

I installed your module and got this error...

[13-May-2012 01:56:56] PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class Doctrine\ORM\Mapping\Driver\AnnotationDriver does not exist' in C:\Zend\Apache2\htdocs\zf2\vendor\DoctrineORMModule\Module.php:71
Stack trace:
#0 C:\Zend\Apache2\htdocs\zf2\vendor\DoctrineORMModule\Module.php(71): ReflectionClass->__construct('Doctrine\ORM\Ma...')
#1 [internal function]: DoctrineORMModule\Module->registerAnnotations(Object(Zend\Module\ModuleEvent))
#2 C:\Zend\Apache2\htdocs\zf2\vendor\ZendFramework\library\Zend\EventManager\EventManager.php(463): call_user_func(Array, Object(Zend\Module\ModuleEvent))
#3 C:\Zend\Apache2\htdocs\zf2\vendor\ZendFramework\library\Zend\EventManager\EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('loadModules.pos...', Object(Zend\Module\ModuleEvent), NULL)
#4 C:\Zend\Apache2\htdocs\zf2\vendor\ZendFramework\library\Zend\Module\Manager.php(87): Zend\EventManager\EventManager->trigger('loadModules.pos...', Object(Zend\Module\Manager), Object(Zend\Module\ModuleEvent))
#5 C:\Zend\Apache2 in C:\Zend\Apache2\htdocs\zf2\vendor\DoctrineORMModule\Module.php on line 71

Zend\Form\View\Helper\FormSelect interaction, edit entities with ManyToOne

Defining a ManyToOne relationship via Doctrine i set up my form like this

class SomeFieldset extends Fieldset implements InputFilterProvider 
{
    // other stuff
    $this->add(array(
        'name' => 'type',
        'type' => 'DoctrineORMModule\Form\Element\DoctrineEntity',
        'options' => array(
              'label' => 'Choose a MyEntity',
              'object_manager' => $em,
              'target_class' => 'Namespace\Entity\MyEntity',
              'property' => 'name'
        ),
        'attributes' => array(
            'required' => true
        )
    ));
    // other stuff
}

Filling out this formular and sending it to the database works for both ADD and EDIT purpose. The problem is with the Rendering of the SELECT-Element.

For each OPTION-Element you'll get a notice

Notice: Object of class Doctrine\ORM\Persisters\BasicEntityPersister could not be converted to int 
in %rootPath%\vendor\zendframework\zendframework\library\Zend\Form\View\Helper\FormSelect.php on line 155

Unsure if this is something the BasicEntityPersister should cover or if that belongs to Zends FormSelect alone.

Edit: Full Code is currently visible at AssetManagement Git on this account

installation by composer failed

Updating dependencies
Your requirements could not be solved to an installable set of packages.

    Problems:
            - Problem caused by:
                    - Installation request for doctrine/doctrine-orm-module

== 9999999-dev: Satisfiable by [doctrine/doctrine-orm-module-dev-master, doctrin
e/doctrine-orm-module-dev-master].
- Package "doctrine/doctrine-orm-module-9999999-dev" con
tains the rule doctrine/doctrine-orm-module requires doctrine/orm (== 9999999-de
v). Any of these packages satisfy the dependency: doctrine/orm-9999999-dev.
- Package "doctrine/doctrine-orm-module-9999999-dev" con
tains the rule doctrine/doctrine-orm-module requires doctrine/orm (== 9999999-de
v). Any of these packages satisfy the dependency: doctrine/orm-9999999-dev.
- learned: -doctrine/orm-9999999-dev

Forgot AbstractCache class

'Doctrine\Common\Cache\AbstractCache' => DIR . '/vendor/doctrine-orm/lib/vendor/doctrine-common/lib/Doctrine/Common/Cache/AbstractCache.php',

is missing in autoload_classmap.php

David

Module config overriding is not working

Hi, I'm using ZF2 beta 3 and I'm trying to configure the DoctrineORMModule.
Everything works well, except for the module config overriding.
I've put a file named module.doctrine_orm.config.php in my/application/path/config/autoload/ to override connection settings but it does not load.

Any suggestion?

Thanks
Antonio

Zend form annotation problem

It seems it is impossible to use DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity and DoctrineORMModule\Form\Element\DoctrineEntity when creating form with annotations. They both need entityManager, but when using annotations, it is not provided for them. It seems that both of these classes should be configured with entityManager, when \DoctrineORMModule\Form\Annotation\AnnotationBuilder creates the form.

You get errors like this:
Argument 1 passed to DoctrineModule\Stdlib\Hydrator\DoctrineObject::__construct() must implement interface Doctrine\Common\Persistence\ObjectManager, none given,
OR
Call to a member function getRepository() on a non-object in \DoctrineORMModule\src\DoctrineORMModule\Form\Element\DoctrineEntity.php on line 228

(Seems to be related to this issue: #69)

Creating the form

<?php

use DoctrineORMModule\Form\Annotation\AnnotationBuilder;

$builder = new AnnotationBuilder( $em );
$form    = $builder->createForm('TestClass');

Sample entity.

<?php

/**
 * @ORM\Entity 
 * @ORM\Table(name="test_class")
 * 
 * @Annotation\Name("test_class")
 * @Annotation\Hydrator("DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity")
 */
class TestClass {

    /** 
     * @ORM\Id 
     * @ORM\Column(type="integer", name="CompanyId") 
     * @ORM\GeneratedValue 
     * 
     * @Annotation\Exclude()
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="User")
     * @ORM\JoinColumn(name="UserId", referencedColumnName="UserId", nullable=false) 
     * 
     * @Annotation\Type("DoctrineORMModule\Form\Element\DoctrineEntity")
     */
    protected $form;

}

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.entitymanager.orm_default

H there, here is my configuration file into autoload directory:

<?php
return array(
    'doctrine' => array(
        'driver' => array(
            'entity_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array('model/Entity')
            ),
            'translatable_driver' => array(
                'class'     => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'namespace' => 'Gedmo\Translatable',
                'paths'     => array('vendor/Gedmo/Translatable/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    'Entity' => 'entity_driver',
                    'Gedmo\Translatable\Entity' => 'translatable_driver'
                )
            )
        ),
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => $connection
            )
        )
    ),
);

But when i'm calling :
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
( instead of $em = $this->getLocator()->get('doctrine.entitymanager.orm_default'); because methode getLocator() doesn't exist.), i get the following error:

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.entitymanager.orm_default

i don't know what's wrong

where to add config info?

hi

in readme you said "To register drivers with Doctrine module simply add the drivers to the doctrine.driver key in your configuration."

which configuration file? i mean the path of the target config file?

and can u please give me an example of working config file

thanks

The helper "em" is not defined.

After installing the module via composer and executing ./vendor/bin/doctrine-module orm:info i always get an error

[InvalidArgumentException]       
  The helper "em" is not defined.

but the database connection is configured

Doctrine cli broken in zf2 beta 3

Not sure if this is a bug for DoctrineModule or DoctrineORMModule, but here's the situation:

Trying to run the cli tool from the command line (with no parameters) yields:

Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter drivers for DoctrineORMModule\Doctrine\ORM\DriverChain::__construct' in /proj/vendor/ZendFramework/library/Zend/Di/Di.php:617

DoctrineORMModule\Doctrine\ORM\DriverChain extends DoctrineModule\Doctrine\Common\DriverChain, which has this constructor:

public function __construct(array $drivers = array(), Cache $cache)

Interestingly enough, if you override it with a constructor with no params in DoctrineORMModule\Doctrine\ORM\DriverChain, that seems to at least partially fix it.

No Commands in CLI after update

After updateing to Current version of ZendSkeletonApplication with the ZendFramework @ 448f2bf the CLI don't contain a doctrine command only help and list.
Maybe the DI was changed?

./vendor/bin/doctrine-module list
DoctrineModule Command Line Interface version dev-master

Usage:
[options] command [arguments]

Options:
--help -h Display this help message.
--quiet -q Do not output any message.
--verbose -v Increase verbosity of messages.
--version -V Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction -n Do not ask any interactive question.

Available commands:
help Displays help for a command
list Lists commands

boolean datatype and checkbox annotation

Example
/**

  • @annotation\Type("Zend\Form\Element\Checkbox")
    */
    protected $isOpen;

It is impossible to set isOpen value to false.

if required=true or allowEmpty=false then NotEmpty filter is automatically added.

This treats false as empty value and value can't be set.

EDIT: This seems to be issue of zend, not DoctrineORMModule.

Entity manager problem

I use 'doctrine_em' alias.
After recent update I got fatal error:

Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter params for DoctrineORMModule\Doctrine\ORM\Connection::__construct' in /proj/vendor/ZendFramework/library/Zend/Di/Di.php on line 617

If I change

'Doctrine\ORM\EntityManager' => array(
    'parameters' => array(
        'conn' => 'orm_connection',
    )
),

to

'orm_em' => array(
    'parameters' => array(
         'conn' => 'orm_connection',
    )
),

at the end of DoctrineORMModule/config/module.config.php file it works.

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.