Skip to content

Conversation

@dg
Copy link
Member

@dg dg commented Feb 25, 2015

Two different things.

  1. replaced PresenterFactory dependency on DI with simple callback.
  • dependency on DIC is bad (it is the only one dependency on DIC in whole framework)
  • current PresenterFactory constructor is different in 2.2 and 2.3, so there will still be BC break
  • partially solves Added presenter mapper #16
  1. new invalidLinkMode

Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of people are inheriting the class and this might make an unnecesary BC Break. It would be imho better to add sane default value to the property and create setter, just like @klimesf had it.

@dg dg force-pushed the pull-invalid branch 2 times, most recently from 99a6ccb to 1efbc92 Compare February 25, 2015 13:17
@dg dg changed the title InvalidLinkMode: changed invalid link handling [WIP] PresenterFactory as callback & changed invalid link handling [WIP] Feb 25, 2015
@dg dg force-pushed the pull-invalid branch 3 times, most recently from fba832b to a2ca4e9 Compare February 25, 2015 14:05
@klimesf
Copy link
Contributor

klimesf commented Feb 25, 2015

👍

Copy link

Choose a reason for hiding this comment

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

Typehint for $container?

What does $touchToRebuild mean? What should be the value? A comment would be nice.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added typehint.

@dg dg force-pushed the pull-invalid branch 2 times, most recently from 1503fcc to fc4e514 Compare February 25, 2015 14:53
@hrach
Copy link
Contributor

hrach commented Feb 25, 2015

  • first commit contains changes with invalid link hadling, probably bug
  • at least invalid link handling should be postponed to 2.4

PresenterFactory:

  • current proposed design doesn't make sense at all,
  • there is nothing wrong to have a dependency on DIC, if there is a interface and possibility for own replacement.
  • create Factory, which in fact deosn't create a instance, is wrong. Passing logic through clousure is wrong. In the end, the dependency on the DIC is still present, in static Helper.
  • Corrent solution should be:
    • provide default implementation without DIC.
    • provide DIC implementation in bridges namespace. (edit: which will be automatically injected into DIC...)

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the closure, but I don't like that it's static class, when it doesn't have to be static class.

you could have created

class PresenterFactoryCallback
{
    public function __construct(/* deps */);
    public function __invoke($class);
}

and attach it like

$presenterFactory = $container->addDefinition($this->prefix('presenterFactory'))
    ->setFactory('Nette\Application\PresenterFactory', [
        new Nette\DI\Statement('Nette\Bridges\ApplicationDI\PresenterFactoryCallback')
    ])

IMHO a lot nicer, what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is fine. I take this more as a cosmetic detail, which can be changed at any time.

@dg
Copy link
Member Author

dg commented Feb 25, 2015

@hrach I see no changes in invalid link handling in first commit.

This can be of course postponed to 2.4, but it seems to me unnecessary to wait a year before invalid links will throw warnings.

ad design: to create interface & its implementation where can be used simple callback is possible, but over complicated.

@fprochazka
Copy link
Contributor

I'm 👍 for warnings on invalid links. They don't kill production and I wanna know about them.

@hrach
Copy link
Contributor

hrach commented Feb 25, 2015

@dg sorry, I missread.

ad design: to create interface & its implementation where can be used simple callback is possible, but over complicated.

That's more Filip's proposal than mine. I see no reason to create another interface, when one is present. It's IPresenterFactory. It's totally ok to have one imlementaion dependent on DIC:

@dg
Copy link
Member Author

dg commented Feb 25, 2015

It's totally ok to have one imlementaion dependent on DIC:

I agree, the motivation was to get rid of changes in constructor, #66 (comment)

@dg dg force-pushed the pull-invalid branch 3 times, most recently from 1981bdd to 2772c8d Compare February 25, 2015 16:11
- triggers warnings on production
- warning on development are configurable via 'silentLinks'
dg added a commit that referenced this pull request Feb 25, 2015
PresenterFactory as callback & changed invalid link handling [WIP]
@dg dg merged commit 3c63c03 into nette:master Feb 25, 2015
@dg dg deleted the pull-invalid branch February 25, 2015 17:51
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.

6 participants