-
Notifications
You must be signed in to change notification settings - Fork 92
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
Move of factories from module.php to module.config.php #99
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
<?php | ||
return array( | ||
'doctrine' => array( | ||
'service_manager' => array( | ||
'factories' => array( | ||
'zfcuser_user_mapper' => 'ZfcUserDoctrineORM\Factory\UserMapperFactory', | ||
'zfcuser_module_options' => 'ZfcUserDoctrineORM\Factory\ModuleOptionsFactory', | ||
), | ||
'aliases' => array( | ||
'zfcuser_register_form_hydrator' => 'zfcuser_user_hydrator', | ||
'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a fallback for when the aliases isn't provided in the zfcuser.global.php? While the zfcuser.global.php(.dist) still overwrites the alias by default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are indeed unneeded and have been removed |
||
'zfcuser_doctrine_em' => 'Doctrine\ORM\EntityManager', | ||
), | ||
), | ||
'doctrine' => array( | ||
'driver' => array( | ||
'zfcuser_entity' => array( | ||
'class' => 'Doctrine\ORM\Mapping\Driver\XmlDriver', | ||
'paths' => __DIR__ . '/xml/zfcuser' | ||
'paths' => __DIR__ . '/xml/zfcuser', | ||
), | ||
|
||
'orm_default' => array( | ||
'drivers' => array( | ||
'ZfcUser\Entity' => 'zfcuser_entity' | ||
) | ||
) | ||
) | ||
'ZfcUser\Entity' => 'zfcuser_entity', | ||
), | ||
), | ||
), | ||
), | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
namespace ZfcUserDoctrineORM\Factory; | ||
|
||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use ZfcUserDoctrineORM\Options\ModuleOptions; | ||
|
||
class ModuleOptionsFactory implements FactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
|
||
return new ModuleOptions(isset($config['zfcuser']) ? $config['zfcuser'] : array()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace ZfcUserDoctrineORM\Factory; | ||
|
||
use Zend\Db; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
use Zend\Stdlib\Hydrator; | ||
use ZfcUser\Mapper; | ||
use ZfcUser\Options; | ||
|
||
class UserMapperFactory implements FactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
return new \ZfcUserDoctrineORM\Mapper\User( | ||
$serviceLocator->get('zfcuser_doctrine_em'), | ||
$serviceLocator->get('zfcuser_module_options') | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the FQCN?
Why? As it allows to easily refactor your code.
Why pass aliases into the factories array? If we want a Mapper\User, I rather get it by its FQCN instead of by a string as I've got to replace each string. Yet a good IDE will help you out anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but I wanted to keep the module as close as possible to the ZfcUser, but indeed, good practice for both modules would be to have the FQCN