Skip to content

Zf3 & ZfcUser 3 support#27

Open
Danielss89 wants to merge 5 commits into
mtudor:masterfrom
Danielss89:zf3
Open

Zf3 & ZfcUser 3 support#27
Danielss89 wants to merge 5 commits into
mtudor:masterfrom
Danielss89:zf3

Conversation

@Danielss89
Copy link
Copy Markdown
Contributor

You should probably tag a new major release as this is breaking for people using ZfcUser 2 or 1

@mtudor
Copy link
Copy Markdown
Owner

mtudor commented Mar 22, 2018

Thanks for the PRs Daniel, just wanted to let you know I've seen them and will have a look over as soon as I can with a view to a merge :)

@lenada lenada mentioned this pull request Mar 27, 2018
@lenada
Copy link
Copy Markdown
Contributor

lenada commented Apr 5, 2018

@mtudor is there anything I can do to get this PR merged/released? Would a code review from my side help?
I do not want to stress! I really appreciate your effort for creating and maintaining this module.
Also kudos to @Danielss89 for the zf3 updates.

@mtudor
Copy link
Copy Markdown
Owner

mtudor commented Apr 8, 2018

Hi @lenada - appreciate the offer and the intent "not to stress" :) I might take you up on it but give me a little time to do an initial skim over first just in case to save you any wasted work. Just getting my dev environment back up (had to reinstall) and then I'll get onto this (hopefully in the next 7 days). Please do feel free to drop me a prod if things go quiet on my end, though I will try to make sure they don't! ;)

@lenada
Copy link
Copy Markdown
Contributor

lenada commented Apr 18, 2018

@mtudor dropping you a prod 🤓
I did some further testing requiring this branch/PR as a package via composer (defining https://github.com/Danielss89/ZfcUserImpersonate.git under repositories). Except some minor autoloading issues this works fine within my zf3 test project. I will add some code comments regarding the autoloading.

Copy link
Copy Markdown
Contributor

@lenada lenada left a comment

Choose a reason for hiding this comment

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

@Danielss89 good work 👍, see minor comments below

Comment thread autoload_classmap.php
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'ZfcUserImpersonate\Module' => __DIR__ . '/Module.php',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest moving the current Module.php to src/ZfcUserImpersonate/Module.php and adding a /Module.php containing

<?php
require_once __DIR__ . '/src/ZfcUserImpersonate/Module.php';

That way we can omit the classmap in composer.json and the module becomes fully PSR-0/4 compliant.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yep - I'm up for this. Do you think we ought to go PSR-4 and change the base directory from src/ZfcUserImpersonate to just src/. Is that more in-line with the standard these days?

If we move the files, a second PR makes more sense I would think.

Comment thread Module.php
{
public function getConfig($env = null)
{
return include __DIR__ . '/config/module.config.php';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When applying the require_once approach, as described below, /../../ need to be added to the config file include.

Copy link
Copy Markdown
Owner

@mtudor mtudor Apr 19, 2018

Choose a reason for hiding this comment

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

Pending the decisions on PSR-0 / PSR-4.

@mtudor
Copy link
Copy Markdown
Owner

mtudor commented Apr 18, 2018

Just finishing off some critical day job stuff and then will aim to jump on this - thanks for the prod :)

Copy link
Copy Markdown
Owner

@mtudor mtudor left a comment

Choose a reason for hiding this comment

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

A few small tweaks and I think we're good to go. Thanks for your work on this @Danielss89, and for the review @lenada :)

Comment thread autoload_classmap.php
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'ZfcUserImpersonate\Module' => __DIR__ . '/Module.php',
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yep - I'm up for this. Do you think we ought to go PSR-4 and change the base directory from src/ZfcUserImpersonate to just src/. Is that more in-line with the standard these days?

If we move the files, a second PR makes more sense I would think.

Comment thread Module.php
{
public function getConfig($env = null)
{
return include __DIR__ . '/config/module.config.php';
Copy link
Copy Markdown
Owner

@mtudor mtudor Apr 19, 2018

Choose a reason for hiding this comment

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

Pending the decisions on PSR-0 / PSR-4.

Comment thread Module.php
use ZfcUserImpersonate\Module\AbstractModule;

class Module extends AbstractModule
class Module implements ConfigProviderInterface
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

So, to clarify as much for me as anyone (but also as a sanity check), now that we don't have any closures in the service and controller config, we no longer require the getControllerConfig(...), getServiceConfig(...) and getViewHelperConfig(...) functions that the AbstractModule provides. Therefore you've essentially removed the AbstractModule functionality (it's based on our https://github.com/tccltd/TccAbstractModule, btw, and we tend to use it for getting up and running quickly). If I've understood the reasoning correctly, I agree that for a vendor module we should aim to be optimised and so the removal makes sense. If I understand correctly as well, we now have the benefit that all of the config is cached?

Finally, we're dropping autoloader related stuff because nowadays composer should really take care of all of that?

'zfcuserimpersonate_adminController' => \ZfcUserImpersonate\Factory\Controller\AdminControllerFactory::class,
'zfcuser' => \ZfcUserImpersonate\Factory\Controller\UserControllerFactory::class,
)
);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This all looks great, including the two new factory classes. I've been wanting to do that for a while so really appreciate this change!

Comment thread config/service/service.config.php Outdated
'zfcuserimpersonate_module_options' => \ZfcUserImpersonate\Factory\Service\ModuleOptionsFactory::class,
'zfcuserimpersonate_user_service' => \ZfcUserImpersonate\Factory\Service\UserServiceFactory::class,
),
'view_helpers' => include('viewhelper.config.php'),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

***** Make a decision on this new style of config separation *****

Comment thread Module.php
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\Mvc\MvcEvent;
use Zend\View\Model\ViewModel;
use ZfcUserImpersonate\Module\AbstractModule;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This can go now, right (AbstractModule has gone)?

Comment thread config/module.config.php
),
),
),
),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I wonder if we ought to leave this in module.config.routes.php and require it as you have done with controller, service and viewhelper configs?

@@ -7,21 +7,14 @@
*/

use Zend\Authentication\Storage\Session;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No need for this use anymore either right?

@@ -11,15 +11,7 @@

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can get rid of the use statements above now these are handled in the factories?

@@ -10,26 +10,7 @@

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can get rid of the use statement above now this is handled in the factory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants