Code Monkey home page Code Monkey logo

doctrinemodule's Introduction

DoctrineModule for Laminas

Build Status Code Coverage Latest Stable Version Total Downloads

DoctrineModule provides basic functionality consumed by DoctrineORMModule (if you want to use Doctrine ORM) and DoctrineMongoODMModule (if you want to use Doctrine MongoDB ODM).

Installation

Run the following to install this library using Composer:

composer require doctrine/doctrine-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.

doctrinemodule's People

Contributors

bakura10 avatar basz avatar bilge avatar davidwindell avatar demiankatz avatar driehle avatar evandotpro avatar fezfez avatar gammamatrix avatar gianarb avatar greg0ire avatar gszy avatar hounddog avatar kocsismate avatar manuakasam avatar matwright avatar michalbundyra avatar midnightdesign avatar mpalourdio avatar neeckeloo avatar ocramius avatar rufinus avatar slamdunk avatar snapshotpl avatar superdweebie avatar svycka avatar thadafinser avatar tomhanderson avatar ufomelkor 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

doctrinemodule's Issues

Authentication Storage

    $authService = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService');

    $adapter = $authService->getAdapter();
    $adapter->setIdentityValue($userObject->username);
    $adapter->setCredentialValue($userObject->password);
    $authResult = $authService->authenticate();

    if ($authResult->isValid()) {
        $identity = $authResult->getIdentity();
        $authService->getStorage()->write($identity);
        return true;
    }

I was able to get the auth and storage to work but is there a way to omit some fields from $identity like 'password'

Hydrate object with ID

Hello.

Is it possible to hydrate following object?

namespace Application;

class User
{
    protected $email;

    public function setEmail($email)
    {
        $this->email = $email;
    }

    public function getEmail()
    {
        return $this->email;
    }
}

With this metadata:

Application\User:
  fields:
    email:
      id: true
      strategy: NONE

Now, when I trying to do it:

$odm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');

$hydrator = new \DoctrineModule\Stdlib\Hydrator\DoctrineObject($odm);
$user = new \Application\User();

$data = array(
    'email' => 'test',
);

$city = $hydrator->hydrate($data, $user);

I got an error:

Zend\Stdlib\Hydrator\ClassMethods::hydrate expects the provided $object to be a PHP object)

Fatal error when accessing Zend\Config objects as array

Using the latest DoctrineModule with Zend Framework 2.0.0beta4 results in a fatal error in the service factory due to Zend\Config\Config objects being passed to array_merge().

$ ./vendor/bin/doctrine-module orm:validate-schema

PHP Warning:  array_merge(): Argument #2 is not an array in .../vendor/doctrine/doctrine-module/src/DoctrineModule/Service/ConnectionFactory.php on line 27
Warning: array_merge(): Argument #2 is not an array in .../vendor/doctrine/doctrine-module/src/DoctrineModule/Service/ConnectionFactory.php on line 27
PHP Warning:  Illegal offset type in isset or empty in .../vendor/zendframework/zendframework/library/Zend/Config/Config.php on line 195
Warning: Illegal offset type in isset or empty in .../vendor/zendframework/zendframework/library/Zend/Config/Config.php on line 195
PHP Catchable fatal error:  Object of class Zend\Config\Config could not be converted to string in .../vendor/doctrine/doctrine-module/src/DoctrineModule/Service/AbstractFactory.php on line 61
Catchable fatal error: Object of class Zend\Config\Config could not be converted to string in .../vendor/doctrine/doctrine-module/src/DoctrineModule/Service/AbstractFactory.php on line 61

I have a fix for this problem which I will push in a few minutes.

Error with composer install (doctrineModule+ocraComposer)

php composer.phar update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove ocramius/OcraComposer dev-master
- doctrine/doctrine-module 0.3.1 requires ocramius/ocracomposer 0.2.0 -> sat
isfiable by ocramius/OcraComposer 0.2.0.
- doctrine/doctrine-module 0.1.0 requires ocramius/ocracomposer 0.1.0 -> sat
isfiable by ocramius/OcraComposer 0.1.0.
- doctrine/doctrine-module 0.2.1 requires ocramius/ocracomposer 0.1.0 -> sat
isfiable by ocramius/OcraComposer 0.1.0.
- doctrine/doctrine-module 0.3.0 requires ocramius/ocracomposer 0.1.0 -> sat
isfiable by ocramius/OcraComposer 0.1.0.
- Can only install one of: ocramius/OcraComposer dev-master, ocramius/OcraCo
mposer 0.2.0.
- Can only install one of: ocramius/OcraComposer dev-master, ocramius/OcraCo
mposer 0.1.0.
- Installation request for ocramius/ocracomposer dev-master -> satisfiable b
y ocramius/OcraComposer dev-master.
- Conclusion: remove doctrine/doctrine-module dev-master|install doctrine/do
ctrine-module 0.1.0|install doctrine/doctrine-module 0.2.1|install doctrine/doct
rine-module 0.3.0|install doctrine/doctrine-module 0.3.1
- doctrine/doctrine-orm-module dev-master requires doctrine/doctrine-module
0.* -> satisfiable by doctrine/doctrine-module 0.4.0, doctrine/doctrine-module 0
.1.0, doctrine/doctrine-module 0.2.0, doctrine/doctrine-module 0.2.1, doctrine/d
octrine-module 0.3.0, doctrine/doctrine-module 0.3.1, doctrine/doctrine-module 0
.5.0.
- doctrine/doctrine-orm-module dev-master requires doctrine/doctrine-module
0.* -> satisfiable by doctrine/doctrine-module 0.4.0, doctrine/doctrine-module 0
.1.0, doctrine/doctrine-module 0.2.0, doctrine/doctrine-module 0.2.1, doctrine/d
octrine-module 0.3.0, doctrine/doctrine-module 0.3.1, doctrine/doctrine-module 0
.5.0.
- Can only install one of: doctrine/doctrine-module dev-master, doctrine/doc
trine-module 0.4.0.
- Can only install one of: doctrine/doctrine-module dev-master, doctrine/doc
trine-module 0.2.0.
- Can only install one of: doctrine/doctrine-module 0.5.0, doctrine/doctrine
-module dev-master.
- Installation request for doctrine/doctrine-module dev-master -> satisfiabl
e by doctrine/doctrine-module dev-master.
- Installation request for doctrine/doctrine-orm-module dev-master -> satisf
iable by doctrine/doctrine-orm-module dev-master.

Catchable fatal error: Argument 1 passed to DoctrineModule\Util\CollectionUtils::intersectUnion() must implement interface Doctrine\Common\Collections\Collection, null given

called in vendor\doctrine\doctrine-module\src\DoctrineModule\Stdlib\Hydrator\DoctrineObject.php on line 152
and defined in vendor\doctrine\doctrine-module\src\DoctrineModule\Util\CollectionUtils.php on line 46

I don't understand what's the problem:

$form->setValidationGroup(array(
'csrf',
'candidat' => array(
'pseudo',
'adresse' => array('countryCode'),
#collection
'profils' => array(
'etatcivil' => array('civiliteId')
),
),
));

$this->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'profils',
'options' => array(
'label' => 'Please choose categories for this product',
'count' => 1,
'should_create_template' => false,
'allow_add' => true,
'target_element' => array(
'type' => 'Candidat\Form\Fieldset\CandidatProfilFieldset'
)
)
));

Invalid event subscriber "Closure" given, must be a service name, class name or an instance implementing Doctrine\Common\EventSubscriber

File:

vendor\doctrine\doctrine-module\src\DoctrineModule\Service\EventManagerFactory.php:58

Message:

Invalid event subscriber "Closure" given, must be a service name, class name or an instance implementing Doctrine\Common\EventSubscriber

Stack trace:

#0 [internal function]: DoctrineModule\Service\EventManagerFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'doctrine.eventm...', 'doctrine.eventm...')
#1 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(672): call_user_func(Array, Object(Zend\ServiceManager\ServiceManager), 'doctrine.eventm...', 'doctrine.eventm...')
#2 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(763): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Array, 'doctrine.eventm...', 'doctrine.eventm...')
#3 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(438): Zend\ServiceManager\ServiceManager->createFromFactory('doctrine.eventm...', 'doctrine.eventm...')
#4 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(391): Zend\ServiceManager\ServiceManager->create(Array)
#5 vendor\doctrine\doctrine-module\src\DoctrineModule\Service\ConnectionFactory.php(57): Zend\ServiceManager\ServiceManager->get('doctrine.eventm...')
#6 [internal function]: DoctrineModule\Service\ConnectionFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'doctrine.connec...', 'doctrine.connec...')
#7 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(672): call_user_func(Array, Object(Zend\ServiceManager\ServiceManager), 'doctrine.connec...', 'doctrine.connec...')
#8 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(763): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Array, 'doctrine.connec...', 'doctrine.connec...')
#9 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(438): Zend\ServiceManager\ServiceManager->createFromFactory('doctrine.connec...', 'doctrine.connec...')
#10 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(391): Zend\ServiceManager\ServiceManager->create(Array)
#11 vendor\doctrine\doctrine-orm-module\src\DoctrineORMModule\Service\EntityManagerFactory.php(14): Zend\ServiceManager\ServiceManager->get('doctrine.connec...')
#12 [internal function]: DoctrineORMModule\Service\EntityManagerFactory->createService(Object(Zend\ServiceManager\ServiceManager), 'doctrine.entity...', 'zfcuser_doctrin...')
#13 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(672): call_user_func(Array, Object(Zend\ServiceManager\ServiceManager), 'doctrine.entity...', 'zfcuser_doctrin...')
#14 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(763): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Array, 'doctrine.entity...', 'zfcuser_doctrin...')
#15 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(438): Zend\ServiceManager\ServiceManager->createFromFactory('doctrine.entity...', 'zfcuser_doctrin...')
#16 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(391): Zend\ServiceManager\ServiceManager->create(Array)
#17 vendor\zf-commons\zfc-user-doctrine-orm\Module.php(51): Zend\ServiceManager\ServiceManager->get('zfcuser_doctrin...')
#18 [internal function]: ZfcUserDoctrineORM\{closure}(Object(Zend\ServiceManager\ServiceManager), 'zfcuserusermapp...', 'zfcuser_user_ma...')
#19 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(672): call_user_func(Object(Closure), Object(Zend\ServiceManager\ServiceManager), 'zfcuserusermapp...', 'zfcuser_user_ma...')
#20 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(765): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'zfcuserusermapp...', 'zfcuser_user_ma...')
#21 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(438): Zend\ServiceManager\ServiceManager->createFromFactory('zfcuserusermapp...', 'zfcuser_user_ma...')
#22 vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php(391): Zend\ServiceManager\ServiceManager->create(Array)
#23 vendor\zf-commons\zfc-user\src\ZfcUser\Controller\UserController.php(57): Zend\ServiceManager\ServiceManager->get('zfcuser_user_ma...')
#24 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(137): ZfcUser\Controller\UserController->loginAction()
#25 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))
#26 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(453): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#27 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(193): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#28 vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(104): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#29 vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(139): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#30 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#31 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(453): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#32 vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(193): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

Interface 'Zend\Paginator\Adapter' not found

Fatal error: Interface 'Zend\Paginator\Adapter' not found in .../vendor/DoctrineModule/src/DoctrineModule/Paginator/Adapter/DqlQuery.php on line 28

In current version of ZF2 interface is called Zend\Paginator\Adapter\AdapterInterface

doctrine/doctrine-module dev-master requires doctrine/data-fixtures 1.* -> no matching package found.

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for doctrine/doctrine-module dev-master -> satisfiable by doctrine/doctrine-module dev-master.
- doctrine/doctrine-module dev-master requires doctrine/data-fixtures 1.* -> no matching package found.

Potential causes:

AuthenticationService::getObjectRepository needs refactoring

/**
 * @return ObjectRepository
 */
public function getObjectRepository()
{
    if ($this->objectRepository) {
        return $this->objectRepository;
    }

    return $this->objectManager->getRepository($this->identityClass);
}

should be

/**
 * @return ObjectRepository
 */
public function getObjectRepository()
{
    if (!$this->objectRepository) {
        $this->objectRepository = $this->getObjectManager()->getRepository($this->identityClass);
    }

    return $this->objectRepository;
}

Also, the docblocks need to be updated as setObjectManager apparently accepts a string (wrong).

CLI "No Metadata Classes to process" problem

Hello,

No matter what i try, i'm always getting this message.
Just cloned everything, so i'm using latest version of all (SkeletonApplication, DoctrineORMModule, ZF2).

I'm trying to reverse from DB into Yaml, this is working, the yml files are generated, but then when i try to generate entities i receive "No Metada Classes to process"...

What I'm doing wrong?

Thanks

CLI tool doesn't recognize local config

can be fixed by replacing line 14 in bin/doctrine.php as follows:

-$defaultListeners->getConfigListener()->addConfigGlobPath('config/autoload/.config.php');
+$defaultListeners->getConfigListener()->addConfigGlobPath('config/autoload/{,
.}{module.*,global,local}.config.php');

(the replacing line was taken from zf2s index.php)

use a method for DoctrineModule\Form\Proxy::loadValueOptions for the label

The ObjectSelect expects a method name as string for the primary Key and a field name for the label.

Why not use a method name for the label too. this would allow for more flexibility of what is shown in the options of the select. (like ID + Name)

see https://github.com/doctrine/DoctrineModule/blob/master/src/DoctrineModule/Form/Element/Proxy.php#L176

i extended ObjectSelect and the Proxy class to do this. so long its working as expected.

    protected function loadValueOptions()
    {
        if (!($om = $this->objectManager)) {
            throw new RuntimeException('No object manager was set');
        }

        if (!($targetClass = $this->targetClass)) {
            throw new RuntimeException('No target class was set');
        }

        // Backward compatibility
        if (!strstr($this->property, 'get')) {
            return parent::loadValueOptions(); // <------ if not "get*" call the old method
        }

        $metadata   = $om->getClassMetadata($targetClass);
        $identifier = $metadata->getIdentifierFieldNames();
        $objects    = $this->getObjects();
        $options    = array();

        if (empty($objects)) {
            $options[''] = '';
        } else {
            foreach ($objects as $key => $object) {

                if (!is_callable(array($object, $this->property))) {
                    throw new RuntimeException(sprintf(
                            'Method "%s::%s" is not callable',
                            $this->targetClass,
                            $this->property
                    ));
                }

                $label = $object->{$this->property}();

                if (count($identifier) > 1) {
                    $value = $key;
                } else {
                    $value = current($metadata->getIdentifierValues($object));
                }

                $options[] = array('label' => $label, 'value' => $value);
            }
        }

        $this->valueOptions = $options;
    }

Mind the line on Backward compatibility.

(Sorry no PR this time, i changed a lot around the ObjectSelect, and its kinda hard to take this features apart)

Submodule Redundancy

There is massive reptition with git submodule inclusion under the DoctrineModule. Currently it looks something like this:

DoctrineModule
docrine-common
doctrine-build-common
doctrine-data-fixtures
doctrine-common
doctrine-build-common
doctrine-dbal
doctrine-build-common
doctrine-common
doctrine-build-common
symfony-console
symfony-yaml
doctrine-orm
doctrine-build-common
doctrine-common
doctrine-build-common
doctrine-dbal
doctrine-build-common
doctrine-common
doctrine-build-common
symfony-console
symfony-yaml
symfony-console
symfony-yaml
symfony-console
symfony-yaml

Surely this isn't sensible! It makes the source tree very confusing, and opens wide the possibliity of conflit when different versions of the same repo are loaded into different submodules. I know this involves lots of modules, but surely it could be reorganised into something simpler, so that there is only one copy of each sub module required.

And while I'm looking at it, doctrine-orm shouldn't be a submodule of doctrine-data-fixtures, should it?

AuthenticationService::getObjectManager() does not instanciate a new om

/**
 * @return ObjectManager
 */
public function getObjectManager()
{
    return $this->objectManager;
}

should be:

/**
 * @return ObjectManager
 */
public function getObjectManager()
{
    if (is_string($this->objectManager)) {
        $this->objectManager = new {$this->objectManager}();
    }
    return $this->objectManager;
}

... or something similar

Doctrine Hydration Fails if Entity Object is a proxy

Simple setup. Longer Story :-)

Table Agency with various fields
Table Mandator with various fields

mandatorId is a FK in Agency.

I use the DoctrineEntity Hydrator in the Forms.

For all ID's where the mandatorId is NOT 1 its working. if its 1 it fails.

The only difference is the user which I'm logged in also belongs to
mandatorId 1. (i can reproduce it, if I change this users mandatorId to
eg. 3 then 3 will fail and 1 will work)

And here comes the funny part.
As soon as Doctrine uses the Proxy Class and not the Entity itself, the
id is of type String and this invokes the notice.

its kinda hard to explain, but take a look at the gist, and you will see
what i mean.
https://gist.github.com/4063648

This are var_dumps of $attributes from the
Zend\Stdlib\Hydrator\ClassMethods::extract method:
in the working version (
https://gist.github.com/4063648#file_1_working%20version ) the mandator
is of type Admin\Entity\Mandator and has an protected mandatorId.

in the failing version (
https://gist.github.com/4063648#file_2_faling%20version ) the mandator
is of type DoctrineORMModule\Proxy__CG__\Admin\Entity\Mandator which
have the mandatorId but it seems it cant be found by extractValue.

I'm sure this is a bug, but I can't figure out where it originates:
Doctrine\ORM\Persisters\BasicEntityPersister?
DoctrineORMModule?
DoctrineEntity Hydrator?
Zend ClassMethods Hydrathor?

As you can see in the failing version, the mandatorId in the _identifier
Array is of type string. (which leads to the notice).

my last try to quick fix this, was to typecast the getMandatorId method
in the Entity, as you can see in the proxy class generated by doctrine (
https://gist.github.com/4063648#file_8_mandator%20proxy.php ) if its not
initialized its already casted to int.
But as the notice talks about EntityPersister i guess it is initialized
and it "__loads" the entity. as this is using parent::getMandatorId() an
forced cast to int should help... but it didnโ€™t.

Authentication documentation

In the "docs / authentication.md" you have to had "orm_default" key in "authentication" array to store 'object_manager', 'identityClass"...

Restore compatibility with ModuleManager

Since 0.4.0 we're using composer as a method to autoload all dependencies of DoctrineModule, DoctrineORMModule and DoctrineMongoODMModule. While this is quite practical, we can add an utility Module.php that either redefines or includes (or extends) the current logic.

Interesting approach would be something like

<?php
require_once __DIR__ . '/src/DoctrineModule/Module.php';
Module::setManuallyAutoloaded(true);

then in the actual DoctrineModule\Module class, which would implement Zend\ModuleManager\Feature\AutoloaderProviderInterface:

<?php 
    public function getAutoloaderConfig()
    {
        if (!static::getManuallyAutoloaded()) {
            return array();
        }

        // introduce logic to handle autoloading, eventually also for dependencies 
        // if possible (hard!)
        return array(/* actual stuff, only when needed */);
    }

Documentation

Since we're reaching ZF2's release date, it is time to stop doing new stuff and refactoring classes (and breaking compatibility).
I'd like anyone involved to please check if there is something immediate and very important to add to the TODOs before we reach a freeze and tag a release too (assuming we're ready for it).

Then we should just split docs into smaller markdown files, each dedicated to a particular feature with its related examples and use cases. Those could be (in future) included in http://www.doctrine-project.org/ if we keep the markdown fairly simple.

The ORM/ODM modules should eventually link these docs if the functionality is based on Doctrine\Common only.

Ping @spiffyjr @bakura10 @superdweebie

Module not installed by composer :((

While install DoctrineORMModule by method writed in README composer failed with error:

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

  Problem 1
    - doctrine/orm dev-master requires doctrine/dbal 2.3.*,2.4.* -> no matching package found.
    - doctrine/doctrine-orm-module dev-master requires doctrine/orm dev-master -> satisfiable by doctrine/orm dev-master.
    - Installation request for doctrine/doctrine-orm-module dev-master -> satisfiable by doctrine/doctrine-orm-module dev-master.

doctrine-module cli not working

hi

can u give me a working example of cli usage

i used this :

D:\xampp\htdocs\ttadmin\vendor\bin>doctrine orm:schema-tool:create --dump-sql

and got this :
[InvalidArgumentException]
The helper "em" is not defined.

Get error when trying to install on windows

I am trying to install on a windows machine. I followed the directions. When I run the 'php composer.phar install' I get this error:

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

        Problems:
                - Problem caused by:
                        - Installation of package "doctrine/doctrinemodule" with
 constraint == 9999999-dev was requested. Satisfiable by packages [doctrine/doct
rinemodule-9999999-dev].
                        - Package "doctrine/doctrinemodule-9999999-dev" contains
 the rule doctrine/doctrinemodule requires php (>= 5.3.3.0). No package satisfie
s this dependency.

What is this?

Authentication doesn't work

Hey Guys,

i tried to implement the DoctrineModule Authentication into my ZF2 Application.
The Base Doctrine implementation works perfectly :)
But the Authentication Methods as in the documentation described don't work for me...

Now i get the following ErrorMessage:
string(121) "Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.authentication.orm_default"

These are my Files:

module.config.php

<?
// module/Mgmt/config/module.config.php:

namespace Core;


return array(
    'controllers' => array(
        'invokables' => array(
            'Core\Controller\Account' => 'Core\Controller\AccountController',
        ),
    ),
    // The following section is new and should be added to your file
    'router' => array(
        'routes' => array(
            'album' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/core[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Core\Controller\Account',
                        'action' => 'index',
                    ),
                ),
            ),
        ),
    ),
    // View setup for this module
    'view_manager' => array(
        'template_path_stack' => array(
            'album' => __DIR__ . '/../view',
        ),
    ),

     // Doctrine config
    'doctrine' => array(
        'driver' => array(
            __NAMESPACE__ . '_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
                )
            )
        ),
        'authentication' => array(
            'orm_default' => array(
                'object_manager' => 'Doctrine\ORM\Entity\Manager',
                'identity_class' => 'Core\Entity\Account',
                'identity_property' => 'mail',
                'credential_property' => 'password',
            ),
        ),
    )
);

Module.php

<?php

namespace Core;

use Zend\Form\View\HelperLoader as FormHelperLoader;
use Zend\Authentication\AuthenticationService;

class Module {
    public function getAutoloaderConfig() {
        return array (
                'Zend\Loader\ClassMapAutoloader' => array (
                        __DIR__ . '/autoload_classmap.php' 
                ),
                'Zend\Loader\StandardAutoloader' => array (
                        'namespaces' => array (
                                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__ 
                        ) 
                ) 
        );
    }
    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }
    public function getServiceConfig() {
        return array (
                'factories' => array (
                        'Zend\Authentication\AuthenticationService' => function ($serviceManager) {

                            return $serviceManager->get('doctrine.authentication.orm_default');

                        } 
                ) 
        );
    }
}


$adapter = new \DoctrineModule\Options\AuthenticationAdapter (
        array (
                'object_manager' => 'Doctrine\ORM\Entity\Manager',
                'identity_class' => 'Core\Entity\Account',
                'identity_property' => 'mail',
                'credential_property' => 'password',

        )
);

AccountController.php

<?php

namespace Core\Controller;

use Zend\Mvc\Controller\AbstractActionController, Zend\View\Model\ViewModel, Doctrine\ORM\EntityManager, Core\Entity\Adress, Core\Entity\Account;
use Zend\Authentication\AuthenticationService;

class AccountController extends AbstractActionController {
    /**
     *
     * @var Doctrine\ORM\EntityManager
     */
    protected $em;
    public function setEntityManager(EntityManager $em) {
        $this->em = $em;
    }
    public function getEntityManager() {
        if (null === $this->em) {
            $this->em = $this->getServiceLocator ()->get ( 'Doctrine\ORM\EntityManager' );
        }
        return $this->em;
    }
    public function indexAction() {
        $data = $this->getRequest ()->getPost ();

        try {
            $authService = $this->getServiceLocator ()->get ( 'Zend\Authentication\AuthenticationService' );
        } catch ( \Exception $e ) {
            var_dump ( $e->getTraceAsString() );
        }

        $adapter = $authService->getAdapter ();
        $adapter->setIdentityValue ( "username" );
        $adapter->setCredentialValue ( "password" );
        $authResult = $authService->authenticate ();


        if ($authResult->isValid ()) {
            // return $this->redirect()->toRoute('home');
        }

        return new ViewModel ( array (
                'error' => 'Your authentication credentials are not valid' 
        ) );
    }
}

StackTrace

string(3021) "#0 /var/www/kbt-mgmt/module/Core/Module.php(29): Zend\ServiceManager\ServiceManager->get('doctrine.authen...')
#1 [internal function]: Core\{closure}(Object(Zend\ServiceManager\ServiceManager), 'zendauthenticat...', 'Zend\Authentica...')
#2 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(690): call_user_func(Object(Closure), Object(Zend\ServiceManager\ServiceManager), 'zendauthenticat...', 'Zend\Authentica...')
#3 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(807): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'zendauthenticat...', 'Zend\Authentica...')
#4 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(459): Zend\ServiceManager\ServiceManager->createFromFactory('zendauthenticat...', 'Zend\Authentica...')
#5 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(416): Zend\ServiceManager\ServiceManager->create(Array)
#6 /var/www/kbt-mgmt/module/Core/src/Core/Controller/AccountController.php(27): Zend\ServiceManager\ServiceManager->get('Zend\Authentica...')
#7 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php(87): Core\Controller\AccountController->indexAction()
#8 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#9 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#10 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php(108): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#13 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#14 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#15 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /var/www/kbt-mgmt/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(297): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /var/www/kbt-mgmt/public/index.php(21): Zend\Mvc\Application->run()
#18 {main}"

Is there anything i forgot??
Please let me know

thx
benni

Multiple properties as label value

Hey everyone,

i ran into the need to have several properties added as the value of my select element. Personally i come across this a lot because often Entities have another Identifier apart from DB-IDs (for example internal names of companies: 1:AD:Team Application Development, with AD being the internal key)

So very often i am needed to provide the key as a label, but having the full name next to that is simply a very nice feature in case of non self-speaking keys.

So i rewrote the Proxy-Class a little bit, you can check it our at this GIST:
https://gist.github.com/4352572

I needed to extract some code into a separate function, but other than that the base-code is pretty unchanged. One thing that changed, too, is to allow the $options['property'] to be an array or a string. I've added another allowed option called "label_connector'" to set the concatenation-string for several properties. The usage of the new feature looks like this:
https://gist.github.com/4352583

setValue bug on Form\Element\ObjectSelect

It doesn't select the good value! $value = current($metadata->getIdentifierValues($value)); in proxy.php(doctrinemodule/form/element/proxy.php) returns boolean false!

please check if it works for you.

i quick fixed it for myself( not for other because i don't know the script).

                    $value = $value->id;
                    // $value = current($metadata->getIdentifierValues($value));

Use ArrayCollection instead of PHP array

I think that we should change the hydrator so that it uses ArrayCollection instead of PHP arrays (for instance here) : https://github.com/doctrine/DoctrineModule/blob/master/src/DoctrineModule/Stdlib/Hydrator/DoctrineObject.php#L168

This would allow greater flexibility in the domain code is we would not need to iterate manually to add the data in the ArrayCollection.

However I think it would introduce a BC, as most of us would expect an array in entity code instead of an ArrayCollection, so we may introduce it once we have a stable version of DoctrineModule.

Packagist out of date

It appears packagist is out of date for both DoctrineModule and DoctrineORM module.

My project composer.json includes has DoctrineModule and DoctrineORMModule set to dev-master.

Output of "php composer.phar show doctrine/DoctrineModule":

name     : doctrine/DoctrineModule
descrip. : Zend Framework 2 Module that provides Doctrine basic functionality required for ORM and ODM modules
keywords : zf2, module, doctrine
versions : * dev-master, 0.4.0, 0.3.1, 0.3.0, 0.2.1, 0.2.0, 0.1.0
type     : library
license  : MIT
source   : [git] git://github.com/doctrine/DoctrineModule.git 46b44060a6311658caeb03190c034b9ea38856f7
dist     : [zip] https://github.com/doctrine/DoctrineModule/zipball/46b44060a6311658caeb03190c034b9ea38856f7 46b44060a6311658caeb03190c034b9ea38856f7
names    : doctrine/doctrinemodule

autoload
psr-0
DoctrineModule => src/
DoctrineModuleTest => tests/
classmap
./

requires
php >=5.3.3
doctrine/common 2.*
doctrine/data-fixtures dev-master
symfony/yaml 2.0.*
symfony/console 2.0.*

As a result, when I run "php composer.phar update" DoctrineModule is out of date, and hasn't brought in the fixed use statements for Zend\Stdlib\Options.

Is this actually an issue with composer/packagist, or are the service hooks not working correctly to update packagist or something like that?

Authentication\Adapter should not return identity object with all available fields

The identity object that is returned by DoctrineModule\Authentication\Adapter is then stored by Zend\Authentication\Storage that we choose. In many cases that would be session. If identity has many field and related tables that may be troublesome.

In my opinion the identity passed to auth service should contain only identity_property or the fileds that user specify.

Probably the better way of solving this is to provide a DoctrineModule\Authentication\AuthenticationService that may retrieve the identity object on getIdentity call. That way the properties like credentials are not stored into storage.

ServiceManager can't find OracleInitSession

When adding this into my config file:

    'eventmanager' => array(
            'orm_default' => array(
            'subscribers' => array("Doctrine\DBAL\Event\Listeners\OracleSessionInit")
        )
    ),

I end up with the error:

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Doctrine\DBAL\Event\Listeners\OracleSessionInit

I narrowed the issue down to DoctrineModule\Service\EventManagerFactory.

This:

        foreach($options->getSubscribers() as $subscriber) {
            if (is_subclass_of($subscriber, 'Doctrine\Common\EventSubscriber')) {
                $evm->addEventSubscriber(new $subscriber);
            } else {
                $evm->addEventSubscriber($sl->get($subscriber));
            }
        }

Should be this:

        foreach($options->getSubscribers() as $subscriber) {
            if (is_subclass_of($subscriber, 'Doctrine\Common\EventSubscriber')) {
                $evm->addEventSubscriber($sl->get($subscriber));
            } else {
                $evm->addEventSubscriber(new $subscriber);
            }
        }

wrong link in /vendor/bin

actualy it try to generate a symlink to a non existing file

doctrine-module -> ../doctrine/DoctrineModule/bin/doctrine-module

and breaks the "php composer.phar install" installation, I had to manually create the correct symlink

doctrine-module -> ../doctrine/doctrine-module/bin/doctrine-module

restart the install and everything seems in place now.

Last ORM in DoctrineModule

I line in @Ocramius's call to nail things down, there is still one ORM hanging around in DoctrineModule. I've noticed that Options\Driver class still defaults to Doctrine\ORM\Mapping\Driver\AnnotationDriver, and I'm not sure that it really should.

Naming of auth factory

I suggest that the key https://github.com/doctrine/DoctrineModule/blob/master/src/DoctrineModule/Service/AuthenticationAdapterFactory.php#L42 should be authentication_adapter for coherency purposes.

EDIT : and it looks like the Module misses the alias for creating an auth adapter.

EDIT 2 : and it misses a factory for the storage too...

EDIT 3 : I really think the auth adapter factory is useless right now. It should create a full Zend\AuthenticationService object, not an auth adapter...

EDIT 4 : in fact, we are going back to the code I wrote and that we removed...

Annotation driver

Hi,

The constructor for AnnotationDriver.php in Doctrine ORM library expects the first argument to be the reader and the second the paths however in the createDriver function in DoctrineModule\Service\DriverFactory.php line 98, passes the paths as the first argument.

Also line 89 ($reader = new Annotations\AnnotationReader;) is redundant and probably should be passed in as the first argument in line 98.

Regards

Pele

Composer update error - doctrine/doctrine-module requires doctrine/data-fixtures 1.*

Several of us on a team have periodically faced composer errors when trying to update... it looks like it might be related to an upstream doctrine/data-fixtures change, but it's been occurring on and off for several weeks now so I thought I'd check. Full composer output below, I'd appreciate any insight on whether others have faced this issue or if it's something specific to our environment. Thank you!

php composer.phar update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - doctrine/doctrine-module 0.5.0 requires doctrine/data-fixtures 1.* -> satisfiable by doctrine/data-fixtures v1.0.0-ALPHA3, doctrine/data-fixtures v1.0.0-ALPHA1, doctrine/data-fixtures v1.0.0-ALPHA2, doctrine/data-fixtures v1.0.0-ALPHA3.
    - doctrine/doctrine-module 0.5.0 requires doctrine/data-fixtures 1.* -> satisfiable by doctrine/data-fixtures v1.0.0-ALPHA3, doctrine/data-fixtures v1.0.0-ALPHA1, doctrine/data-fixtures v1.0.0-ALPHA2, doctrine/data-fixtures v1.0.0-ALPHA3.
    - Can only install one of: doctrine/data-fixtures dev-master, doctrine/data-fixtures v1.0.0-ALPHA3.
    - Can only install one of: doctrine/data-fixtures dev-master, doctrine/data-fixtures v1.0.0-ALPHA1.
    - Can only install one of: doctrine/data-fixtures dev-master, doctrine/data-fixtures v1.0.0-ALPHA2.
    - Can only install one of: doctrine/data-fixtures dev-master, doctrine/data-fixtures v1.0.0-ALPHA3.
    - Installation request for doctrine/data-fixtures dev-master -> satisfiable by doctrine/data-fixtures dev-master.
    - Installation request for doctrine/doctrine-module 0.5.0 -> satisfiable by doctrine/doctrine-module 0.5.0.

Form\Element\Proxy does not support method invocation as the label

I do not know what the reason is that Proxy can only use properties as label, but in my opinion it lacks flexibility. Furthermore, I have an issue because of it, as I would show the users' name in the DoctrineORMModule\Form\Element\EntitySelect, but my entity only has firstname and surname fields.

I would propose a solution I tried. It seems to work well. Hope, you like it.

So, I added an option 'isMethod' of boolean type to the Form\Element\Proxy. If isMethod is false, everything works pretty the same as the current solution. But if isMethod is true, the propery acts like a getter method. To achieve this, only some lines are needed to be inserted:

// The property definition:
protected $isMethod;

// The initialization condition in the setOptions method:

if (isset($options['isMethod'])) {
    $this->setIsMethod($options['isMethod']);
}

// The getter and setter:

public function setIsMethod($isMethod)
{
    $this->isMethod = $isMethod;
    return $this;
}

public function getIsMethod()
{
     return $this->isMethod;
}

Plus changing one line in the loadValueOptions() method:

// if (!$metadata->hasField($property)) {
// To:

if ($this->isMethod == false && !$metadata->hasField($property)) {

This solution is safe as the existence of the method to be called is also checked on the further lines, but if isMethod is set to true you do not need to use an existing database field.

So if you do this in ZF2:

$this->add(array(
    'name' => 'user',
    'type' => 'DoctrineORMModule\Form\Element\EntitySelect',
    'options' => array(
        'label' => '',
        'object_manager' => Registry::get('entityManager'),
        'target_class' => 'My\Entity\Users',
        'property' => 'name',
        'isMethod' => true
    ),
));

The Proxy will provide the result of the getter method of the name field (which obviously does not exist in the database) as the label.

Hydrator RFC (byref/byval logic)

We need to get new ideas on how to work with hydration. My proposal is to allow two approaches:

  • by_ref: hydrator acts on object properties via class metadata, any userland code is completely skipped
  • by_val: hydrator fetches and sets data via public API of the entity, and applies additional security on any extracted value so that retrieved objects are not modified (handling them as immutable).

@bakura10 already pasted some basic thoughts on this at https://gist.github.com/3873354 after we discussed the approaches a bit.

ObjectRepository: don't always require credentialProperty

Currently, it is always required to specify a credentialProperty to the ObjectRepository authentication adapter. However, if I supply a credentialCallable that returns true when the credential is correct and false otherwise, the ObjectRepository should never have to query the credentialProperty itself.

The ObjectRepository::validateIdentity method currently first always tries to get the value of the credentialProperty, even though this value might not be required if the credentialCallable returns a boolean indicating success. I propose to slightly modify the validateIdentity method to only consult the credentialProperty when the credentialCallable doesn't exist or returns something other than a boolean.

Suggested implementation:

/**
     * This method attempts to validate that the record in the resultset is indeed a
     * record that matched the identity provided to this adapter.
     *
     * @param  object                              $identity
     * @throws Exception\UnexpectedValueException
     * @return AuthenticationResult
     */
    protected function validateIdentity($identity)
    {
        $authenticationSuccess = false;

        $callable = $this->options->getCredentialCallable();
        $credentialValue = $this->credentialValue;
        if ($callable) {
            $credentialValue = call_user_func($callable, $identity, $credentialValue);
            $authenticationSuccess = ($credentialValue === true);
        }


        if (! $authenticationSuccess) {
            $credentialProperty = $this->options->getCredentialProperty();
            $getter = 'get' . ucfirst($credentialProperty);
            $documentCredential = null;

            if (method_exists($identity, $getter)) {
                $documentCredential = $identity->$getter();
            } elseif (property_exists($identity, $credentialProperty)) {
                $documentCredential = $identity->{$credentialProperty};
            } else {
                throw new Exception\UnexpectedValueException(sprintf(
                    'Property (%s) in (%s) is not accessible. You should implement %s::%s()',
                    $credentialProperty,
                    get_class($identity),
                    get_class($identity),
                    $getter
                ));
            }
            $authenticationSuccess = ($credentialValue === $documentCredential);
        }

        if ($authenticationSuccess) {
            $this->authenticationResultInfo['code']       = AuthenticationResult::SUCCESS;
            $this->authenticationResultInfo['identity']   = $identity;
            $this->authenticationResultInfo['messages'][] = 'Authentication successful.';
        } else {
            $this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
            $this->authenticationResultInfo['messages'][] = 'Supplied credential is invalid.';
        }

        return $this->createAuthenticationResult();
    }

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.