application icon indicating copy to clipboard operation
application copied to clipboard

Generalized Route::getTargetPresenter()

Open JanTvrdik opened this issue 11 years ago • 24 comments

Allow using this optimization for other IRouter implementations.

Ideas for better names of anything are welcomed.

JanTvrdik avatar Nov 02 '14 15:11 JanTvrdik

static?

hrach avatar Nov 02 '14 15:11 hrach

We may implement the getTargetPresenters as well it for RouteList as well.


    function getTargetPresenters()
    {
        if ($this->cachedRoutes === NULL) $this->cachedRoutes = $this->buildCache();
        return empty($this->cachedRoutes['*']) ? array_keys($this->cachedRoutes) : NULL;
    }

JanTvrdik avatar Nov 02 '14 15:11 JanTvrdik

Sorry about previous comments. Without further change in RouteList it is major BC break for multiple presenters in single route?

mishak87 avatar Nov 02 '14 17:11 mishak87

@mishak87 Sorry, I have no idea what you mean. Please rephrase. This feature should be entirely without BC break.

JanTvrdik avatar Nov 02 '14 19:11 JanTvrdik

Original: FALSE skips adding anything, NULL adds default values and string one presenter if the item is Route instance.

Change: Adds interface returning multiple routes and removes FALSE branch while also renaming method to plural.

mishak87 avatar Nov 02 '14 21:11 mishak87

I still don't know what you are talking about. Are you suggesting something? Informing me of something? Are you stating facts?

JanTvrdik avatar Nov 02 '14 22:11 JanTvrdik

He means that you changed getTargetPresenter -> getTargetPresenters and it's return value. But getTargetPresenter is internal method, so it is not BC break.

dg avatar Nov 04 '14 23:11 dg

@dg Does this makes sense to you? Should I finish the implementation (e.g. write tests)?

JanTvrdik avatar Nov 05 '14 00:11 JanTvrdik

ping

JanTvrdik avatar Dec 11 '14 12:12 JanTvrdik

Even after more than one month I still think this is a great idea. Except for the interface name, that is terrible. cc @dg

JanTvrdik avatar Dec 15 '14 19:12 JanTvrdik

I'm not sure about the interface name, but I like the idea. :+1:

fprochazka avatar Dec 16 '14 13:12 fprochazka

I think that getTargetPresenters can be part of IRouter.

dg avatar Jan 18 '15 16:01 dg

That would solve the ugly IFixedTargetPresenters name. But it would be a nasty BC break. It would actually be so large BC break that if we choose to do it, we may as well break other things (I have few ideas).

JanTvrdik avatar Jan 18 '15 16:01 JanTvrdik

I would prefer to avoid BC break. This method can be in interface in v2.3 commented out and checked via method_exists.

dg avatar Jan 18 '15 16:01 dg

That seems reasonable.

JanTvrdik avatar Jan 18 '15 16:01 JanTvrdik

Typo in commit message: IRouter

dg avatar Jan 18 '15 16:01 dg

Yeah and it also does not have tests so we don't know whether it actually work. And I don't feel like writing them right now.

JanTvrdik avatar Jan 18 '15 17:01 JanTvrdik

Do you plan to merge this to 2.3?

JanTvrdik avatar Jan 31 '15 17:01 JanTvrdik

Yes, will you finish it?

dg avatar Feb 01 '15 12:02 dg

ping @JanTvrdik

dg avatar Feb 10 '15 05:02 dg

There is a potential issue with cache invalidation when combining multiple RouteList, i.e. the following test will fail:

$listA = new RouteList();
$listB = new RouteList();

Assert::same([], $listA->getTargetPresenters());
Assert::same([], $listB->getTargetPresenters());

$listB[] = new Route('about', 'About:default');

Assert::same(['About'], $listB->getTargetPresenters()); // this is OK
Assert::same(['About'], $listA->getTargetPresenters()); // this will fail

JanTvrdik avatar Jun 27 '15 11:06 JanTvrdik

One possible solution may be to disallow (throw exception) modifying RouteList once first URL has been generated (or more precisely once the cache is built).

JanTvrdik avatar Jun 27 '15 11:06 JanTvrdik

ping @JanTvrdik would you like to merge to 2.4 version?

chemix avatar Mar 29 '16 14:03 chemix

Yes. It would be awesome if anyone could finish this without me (I don't currently have the mental model for this ready anyway) but I can finish this if no one else finds the time.

JanTvrdik avatar Mar 29 '16 14:03 JanTvrdik