Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 1.0 #256

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7324170
Fix for issue #230.
superdweebie May 6, 2013
36fa2c8
fix mistake
superdweebie May 6, 2013
9a1f0fa
Improved, cleaner fix for #230. Also fixes for #234
superdweebie May 13, 2013
9b6ac7d
Working on release 1.0
superdweebie May 21, 2013
ff4ba0b
Chagne php 5.4 format array to 5.3
superdweebie May 21, 2013
b4900f9
First round of CS fixes
superdweebie May 22, 2013
0288cc2
more CS fixes
superdweebie May 22, 2013
7d92054
final cs fixes, I think
superdweebie May 22, 2013
888253f
Fix final php 5.3 issue
superdweebie May 22, 2013
b8d6fe1
Coverage annotation correction
superdweebie May 22, 2013
77b97ae
Fix default cache service name
superdweebie May 22, 2013
7eab5c5
Add missing use
superdweebie May 22, 2013
5b17a94
Name changes for Adapter\ObjectRepository Storage\ObjectRepository Pa…
superdweebie May 22, 2013
e3811c0
Improve and correct upgarde guide
superdweebie May 22, 2013
346713e
Formatting corrections for upgrade guide
superdweebie May 22, 2013
246b840
Formatting corrections for upgrade guide
superdweebie May 22, 2013
a4c88ca
Formatting corrections for upgrade guide
superdweebie May 22, 2013
0d7f587
Correct test coverage annotation
superdweebie May 22, 2013
af15ebd
Correct test coverage annotation
superdweebie May 22, 2013
d641b17
I missed a
superdweebie May 22, 2013
a0c18c2
Remove whitespace at end of line
superdweebie May 22, 2013
a09bc71
Lots of small tidy ups
superdweebie May 23, 2013
ca1e7dd
Move Factory namespace to Builder
superdweebie May 23, 2013
6539115
Remove all fluent interfaces
superdweebie May 23, 2013
cb94c2f
Refactor cache creation
superdweebie May 24, 2013
863e74f
Correct old class name;
superdweebie May 24, 2013
5639c0c
Removed Memcache Builder and Options classes. Other small improvement…
superdweebie May 25, 2013
807cd6c
Remove default from MemcacheCacheFactory
superdweebie May 25, 2013
9fe9f5d
Fix tests after rebase. CS fixes
superdweebie May 25, 2013
bb7e020
Tidy up module.config.php
superdweebie May 26, 2013
3875f8b
Change class name DoctrineObject to ObjectHydrator
superdweebie May 26, 2013
21a779e
Corrections for UPGRADE.md, and branch alias for composer.json
superdweebie May 29, 2013
b8cb316
Correct bug in FileSystemCacheFactory
superdweebie May 31, 2013
c2afd5f
Correct docblock
superdweebie Jun 4, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# 1.0

* Dependency to zendframework has been bumped from `~2.1` to `~2.2`
* Dependency to doctrine/common has been bumped from `>=2.3,<2.5-dev` to `>=2.4,<2.6-dev`
* Class name changes:
- `DoctrineModule\ServiceFactory\AbstractDoctrineServiceFactory` -> `DoctrineModule\ServiceFactory\DoctrineServiceAbstractFactory`
- `DoctrineModule\Authentication\Adapter\ObjectRepository` -> `DoctrineModule\Authentication\Adapter\ObjectRepositoryAdapter`
- `DoctrineModule\Authentication\Storage\ObjectRepository` -> `DoctrineModule\Authentication\Storage\ObjectRepositoryStorage`
- `DoctrineModule\Paginator\Adatper\Collection` -> `DoctrineModule\Paginator\Adatper\CollectionAdapter`
- `DoctrineModule\Paginator\Adatper\Selectable` -> ``DoctrineModule\Paginator\Adatper\SelectableAdater`
- `DoctrineModule\Stdlib\Hydrator\DoctrineObject` -> `DoctrineModule\Stdlib\Hydrator\ObjectHydrator`
- All `DoctrineModule\Options\*.php` -> `DoctrineModule\Options\*Options.php`
* Any fluent interfaces have been removed.
* Configuration has changed significantly. Most services are created by `DoctrineModule\ServiceFactory\DoctrineServiceAbstractFactory`,
and expects configuration to follow this pattern:
- All service names should start with `doctrine.`.
- All service names should use `.` to delimit words in the service name
- All service names should survive `Zend\ServiceManager\ServiceManager`'s cannonacalization process unchanged.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, still for homogeneity purpose I'd like some service keys to be renamed. For instance doctrine.eventmanager to doctrine.event_manager.

The solution would be to override the canonicalizeName in the factory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bakura10 can't work - already went through it in detail

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ? We had this problem in ZfrRest with application/json and it works by overriding canonicalizeName.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bakura10 that only because we had our own service container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think about creating a domain specific ServiceManager for doctrine, but the extra complexity didn't seem to be worth the modest benefit. Even if we did, and peered it to the main ServiceManager, we would still have the alias problem for anything pulled through the main ServiceManager.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@superdweebie indeed, even a peering service locator has that problem :(

If they do not, getting the service directly will work, but aliases will not. In practice, this means service names should be all lower case,
and should not include the characters `_-\ /`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any way to force this via exception? Maybe in the abstract factory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could check if $name === $requestedName and if not, then throw an exception. Might be a little too heavy handed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@superdweebie that disallows aliases though (now that I think of it) guess it's a problem to be thought carefully after this PR

- If a service with name `doctrine.foo.bar.baz` is requested, then `DoctrineServiceAbstractFactory` will get the service
called `doctrine.factory.foo.bar` from the ServiceManager. The `doctrine.factory.foo.bar` instance must be an object implementing
`DoctrineModule\Factory\AbstractFactoryInterface`. `$instanace::create($options)` will be called to create the oringally
requested `doctrine.foo.bar.baz` service. The `$options` passed to `create` will be an array taken from
the application config: `$config['doctrine']['foo']['bar']['baz']`s.
- For example in the config options for the default EventManager should be placed in
`$config['doctrine']['eventmanager']['default']`. The EventManager will be created by a
`DoctrineModule\Factory\EventManagerFactory` which is fetched from the ServiceManager with the service
name `doctrine.factory.eventmanager`. To get a configured instance of the default EventManager call
`$serviceManager->get('doctrine.eventmanager.default')`.
* Configuration for authentication services has been rearranged to follow the pattern above, with separate
config keys for `adapter`, `storage`, and `service`. See `module.config.php`.
* Authentication configuration no longer supports setting `objectRepository`. You must set both `objectManager` and
`identityClass`. This significantly simplifies the code, and allows a flat config for easy caching.
* Most of the factories that were in `DoctrineModule\Service` have been moved to `DoctrineModule\Builder`. This is because
they are not actual service factories to be consumed by the ServiceManager. Rather they are consumed by `DoctrineServiceAbstractFactory`.
* When configuring drivers, the cache key must now be a full service name. eg `doctrine.cache.array`.
* When configuring a driver chain, the `$options->drivers` array may contain driver instances, or complete service names.

eg:

'driver' => array(
'default' => array(
'drivers' => array(
'My\Namespace' => 'doctrine.driver.mydriver'
),
),
'mydriver' => array(
'class' => 'Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver',
'paths' => array('path/to/my/namespace')
),
),

# 0.8.0

* Dependency to zendframework has been bumped from `2.*` to `~2.1`
Expand Down
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@
"name": "Michaël Gallego",
"email": "mic.gallego@gmail.com",
"homepage": "http://www.michaelgallego.fr"
},
{
"name": "Tim Roediger",
"email": "superdweebie@gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"doctrine/common": ">=2.3,<2.5-dev",
"symfony/console": "~2.1",
"zendframework/zend-authentication": "~2.1",
"zendframework/zend-cache": "~2.1",
"zendframework/zend-paginator": "~2.1",
"zendframework/zend-stdlib": "~2.1",
"zendframework/zend-mvc": "~2.1",
"zendframework/zend-servicemanager": "~2.1",
"zendframework/zend-validator": "~2.1"
"doctrine/common": ">=2.4,<2.6-dev",
"symfony/console": "~2.2",
"zendframework/zend-authentication": "~2.2",
"zendframework/zend-cache": "~2.2",
"zendframework/zend-paginator": "~2.2",
"zendframework/zend-stdlib": "~2.2",
"zendframework/zend-mvc": "~2.2",
"zendframework/zend-servicemanager": "~2.2",
"zendframework/zend-validator": "~2.2"
},
"require-dev": {
"phpunit/phpunit": "~3.7",
"squizlabs/php_codesniffer": "1.4.*",
"zendframework/zendframework": "~2.1"
"zendframework/zendframework": "~2.2"
},
"suggest": {
"doctrine/data-fixtures": "Data Fixtures if you want to generate test data or bootstrap data for your deployments"
Expand All @@ -59,7 +63,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.9.x-dev"
"dev-develop": "1.0.x-dev"
}
},
"bin": [
Expand Down
95 changes: 43 additions & 52 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,85 +21,76 @@
'doctrine' => array(
'cache' => array(
'apc' => array(
'class' => 'Doctrine\Common\Cache\ApcCache',
'namespace' => 'DoctrineModule',
),
'array' => array(
'class' => 'Doctrine\Common\Cache\ArrayCache',
'namespace' => 'DoctrineModule',
),
'filesystem' => array(
'class' => 'Doctrine\Common\Cache\FilesystemCache',
'directory' => 'data/DoctrineModule/cache',
'namespace' => 'DoctrineModule',
// 'directory' => 'data/DoctrineModule/cache',
),
'memcache' => array(
'class' => 'Doctrine\Common\Cache\MemcacheCache',
'instance' => 'my_memcache_alias',
'namespace' => 'DoctrineModule',
'instance' => 'my_memcache_instance',
),
'memcached' => array(
'class' => 'Doctrine\Common\Cache\MemcachedCache',
'instance' => 'my_memcached_alias',
'namespace' => 'DoctrineModule',
'instance' => 'my_memcached_instance',
),
'redis' => array(
'class' => 'Doctrine\Common\Cache\RedisCache',
'instance' => 'my_redis_alias',
'namespace' => 'DoctrineModule',
),
'wincache' => array(
'class' => 'Doctrine\Common\Cache\WinCacheCache',
'namespace' => 'DoctrineModule',
),
'xcache' => array(
'class' => 'Doctrine\Common\Cache\XcacheCache',
'namespace' => 'DoctrineModule',
),
'zenddata' => array(
'class' => 'Doctrine\Common\Cache\ZendDataCache',
'namespace' => 'DoctrineModule',
),
),

//These authentication settings are a hack to tide things over until version 1.0
//Normall doctrineModule should have no mention of odm or orm
'authentication' => array(
//default authentication options should be set in either the odm or orm modules
'odm_default' => array(),
'orm_default' => array(),
),
'authenticationadapter' => array(
'odm_default' => true,
'orm_default' => true,
),
'authenticationstorage' => array(
'odm_default' => true,
'orm_default' => true,
),
'authenticationservice' => array(
'odm_default' => true,
'orm_default' => true,
)
),

// Factory mappings - used to define which factory to use to instantiate a particular doctrine
// service type
'doctrine_factories' => array(
'cache' => 'DoctrineModule\Service\CacheFactory',
'eventmanager' => 'DoctrineModule\Service\EventManagerFactory',
'driver' => 'DoctrineModule\Service\DriverFactory',
'authenticationadapter' => 'DoctrineModule\Service\Authentication\AdapterFactory',
'authenticationstorage' => 'DoctrineModule\Service\Authentication\StorageFactory',
'authenticationservice' => 'DoctrineModule\Service\Authentication\AuthenticationServiceFactory',
'adapter' => array(
'default' => array(
'object_manager' => 'doctrine.objectmanager.default',
'identity_class' => 'Application\Model\User',
'identity_property' => 'username',
'credential_property' => 'password'
)
),
'storage' => array(
'default' => array(
'object_manager' => 'doctrine.objectmanager.default',
'identity_class' => 'Application\Model\User',
)
),
'service' => array(
'default' => array(
'adapter' => 'doctrine.authentication.adapter.default',
'storage' => 'doctrine.authentication.storage.default'
)
)
)
),

'service_manager' => array(
'invokables' => array(
'doctrine.builder.eventmanager' => 'DoctrineModule\Builder\EventManagerBuilder',
'doctrine.builder.driver' => 'DoctrineModule\Builder\DriverBuilder',
'doctrine.builder.authentication.repository' => 'DoctrineModule\Builder\Authentication\RepositoryBuilder',
'doctrine.builder.authentication.adapter' => 'DoctrineModule\Builder\Authentication\AdapterBuilder',
'doctrine.builder.authentication.storage' => 'DoctrineModule\Builder\Authentication\StorageBuilder',
'doctrine.builder.authentication.service' => 'DoctrineModule\Builder\Authentication\AuthenticationServiceBuilder',
),
'factories' => array(
'doctrine.cli' => 'DoctrineModule\Service\CliFactory',
'doctrine.cache.apc' => 'DoctrineModule\Service\Cache\ApcCacheFactory',
'doctrine.cache.array' => 'DoctrineModule\Service\Cache\ArrayCacheFactory',
'doctrine.cache.filesystem' => 'DoctrineModule\Service\Cache\FilesystemCacheFactory',
'doctrine.cache.memcache' => 'DoctrineModule\Service\Cache\MemcacheCacheFactory',
'doctrine.cache.memcached' => 'DoctrineModule\Service\Cache\MemcachedCacheFactory',
'doctrine.cache.redis' => 'DoctrineModule\Service\Cache\RedisCacheFactory',
'doctrine.cache.wincache' => 'DoctrineModule\Service\Cache\WincacheCacheFactory',
'doctrine.cache.xcache' => 'DoctrineModule\Service\Cache\XcacheCacheFactory',
'doctrine.cache.zenddata' => 'DoctrineModule\Service\Cache\ZendDataCacheFactory',
'doctrine.cli' => 'DoctrineModule\Service\CliFactory',
),
'abstract_factories' => array(
'DoctrineModule' => 'DoctrineModule\ServiceFactory\AbstractDoctrineServiceFactory',
'DoctrineModule' => 'DoctrineModule\Service\DoctrineServiceAbstractFactory',
),
),

Expand Down
6 changes: 3 additions & 3 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ class Module
'factories' => array(
'Zend\Authentication\AuthenticationService' => function($serviceManager) {
// If you are using DoctrineORMModule:
return $serviceManager->get('doctrine.authenticationservice.orm_default');
return $serviceManager->get('doctrine.authenticationservice.default');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 !

I still want a doctrine.objectmanager.default key... =) Would be super nice for third party modules taht can't assume if the user is using ODM or ORM, but want to provide a deafult object manager.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on that - could be an alias set by the last loaded module

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly my thought :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.


// If you are using DoctrineODMModule:
return $serviceManager->get('doctrine.authenticationservice.odm_default');
return $serviceManager->get('doctrine.authenticationservice.default');
}
)
);
}
}
```

Please note that Iam using here a ``Zend\Authentication\AuthenticationService`` name, but it can be anything else (``my_auth_service``…). However, using the name ``Zend\Authentication\AuthenticationService`` will allow it to be recognised by the ZF2 view helper.
Please note that I am using here a ``Zend\Authentication\AuthenticationService`` name, but it can be anything else (``my_auth_service``…). However, using the name ``Zend\Authentication\AuthenticationService`` will allow it to be recognised by the ZF2 view helper.

#### Using the AuthenticationService

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace DoctrineModule\Authentication\Adapter;

use DoctrineModule\Options\Authentication as AuthenticationOptions;
use DoctrineModule\Options\Authentication\AdapterOptions;
use Zend\Authentication\Adapter\AbstractAdapter;
use Zend\Authentication\Adapter\Exception;
use Zend\Authentication\Result as AuthenticationResult;
Expand All @@ -33,7 +33,7 @@
* @author Tim Roediger <superdweebie@gmail.com>
* @author Michaël Gallego <mic.gallego@gmail.com>
*/
class ObjectRepository extends AbstractAdapter
class ObjectRepositoryAdapter extends AbstractAdapter
{
/**
* @var AuthenticationOptions
Expand Down Expand Up @@ -63,14 +63,13 @@ public function __construct($options = array())
*/
public function setOptions($options)
{
if (!$options instanceof AuthenticationOptions) {
$options = new AuthenticationOptions($options);
if (!$options instanceof AdapterOptions) {
$options = new AdapterOptions($options);
}

$this->options = $options;
return $this;
}

/**
* @return AuthenticationOptions
*/
Expand All @@ -89,7 +88,6 @@ public function getOptions()
public function setIdentityValue($identityValue)
{
$this->identity = $identityValue;
return $this;
}

/**
Expand All @@ -111,7 +109,6 @@ public function getIdentityValue()
public function setCredentialValue($credentialValue)
{
$this->credential = $credentialValue;
return $this;
}

/**
Expand All @@ -130,8 +127,7 @@ public function authenticate()
{
$this->setup();
$options = $this->options;
$identity = $options
->getObjectRepository()
$identity = $options->getRepository()
->findOneBy(array($options->getIdentityProperty() => $this->identity));

if (!$identity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace DoctrineModule\Authentication\Storage;

use DoctrineModule\Options\Authentication as AuthenticationOptions;
use DoctrineModule\Options\Authentication\StorageOptions;
use Zend\Authentication\Storage\StorageInterface;

/**
Expand All @@ -30,7 +30,7 @@
* @since 0.5.0
* @author Michaël Gallego <mic.gallego@gmail.com>
*/
class ObjectRepository implements StorageInterface
class ObjectRepositoryStorage implements StorageInterface
{

/**
Expand All @@ -45,14 +45,13 @@ class ObjectRepository implements StorageInterface
*/
public function setOptions($options)
{
if (!$options instanceof AuthenticationOptions) {
$options = new AuthenticationOptions($options);
if (!$options instanceof StorageOptions) {
$options = new StorageOptions($options);
}

$this->options = $options;
return $this;
}

/**
* Constructor
*
Expand Down Expand Up @@ -80,7 +79,7 @@ public function isEmpty()
public function read()
{
if (($identity = $this->options->getStorage()->read())) {
return $this->options->getObjectRepository()->find($identity);
return $this->options->getRepository()->find($identity);
}

return null;
Expand All @@ -89,21 +88,21 @@ public function read()
/**
* Will return the key of the identity. If only the key is needed, this avoids an
* unnecessary db call
*
*
* @return mixed
*/
public function readKeyOnly()
{
return $identity = $this->options->getStorage()->read();
}

/**
* @param object $identity
* @return void
*/
public function write($identity)
{
$metadataInfo = $this->options->getClassMetadata();
$metadataInfo = $this->options->getObjectManager()->getClassMetadata($this->options->getIdentityClass());
$identifierValues = $metadataInfo->getIdentifierValues($identity);

$this->options->getStorage()->write($identifierValues);
Expand Down
Loading