Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

create custom exception/error handling mechanism #192

Merged
merged 1 commit into from
Nov 7, 2014

Conversation

ElectricMaxxx
Copy link
Member

As a follow up from #177

Would like to spice up the frontend test only by adding one more level in the routes/contents created in the FixtureLoader to see both ancestor and parent suggestions.

@ElectricMaxxx
Copy link
Member Author

Feel free to merge, when you like it. You can see the purpose of this PR in the Frontend Test.
One typo in a route serves a list of suggestions - parent and ancestor.
In an application i would customize the template, wanted to check the result only.

@ElectricMaxxx
Copy link
Member Author

Btw: depending when you want to tag, i will implement both (alternate locale too) in the Sandbox this or next night. Lastest monday Morning in train.

@lsmith77
Copy link
Member

lsmith77 commented Oct 4, 2014

@wouterj I will leave review with you, ok? just make sure to only merge things that are certain to have no big side effects at this point in the RC phase.

@ElectricMaxxx
Copy link
Member Author

@wouterj i think i have all line endings in New files this time :-)

@lsmith77 this PR should have no side effects. Its a feature beside to the common behavior of this bundle (SEO metadata).

@ElectricMaxxx
Copy link
Member Author

But if "activated" in an cms with PHPCR it will provide a big help for error pages. And an example to extend it for the use with other persistence implementations.

break;
}
}
$group = null !== $group ? $group : 'default';
Copy link
Member

Choose a reason for hiding this comment

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

$group = $group ?: 'default';

@wouterj
Copy link
Member

wouterj commented Oct 5, 2014

As said, I don't understand the name "BestMatcher".

I also think the 2 current BestMatchers are redundant and one can fullfill the job as good as 2 can.

@wouterj
Copy link
Member

wouterj commented Oct 5, 2014

We should also have a way to switch of core best matchers imo

@ElectricMaxxx
Copy link
Member Author

BestMatcher

@dbu and i came to that name. They are responsible for computing the best matches for a wrong url or just a typo.

Why are ther two?

Cause both are doing a different job and are registered separately by a tag. You can add your own matcher and call them what ever you want and let them do what ever you want. Btw: different matchers mean different groups. I would suggest to create a grouped output, like

<div>
    <ul>
        {% for group, matchs in best_matches %}
                {% for match in matchs %}
                    <li>{{ group }} - {{ match.name }}</li>
                {% endfor %}
        {% endfor %}
    </ul>
</div>

The presentation model/controller creates an array like that as data for the template.

switch core of

Yes and No. First the complete behavior is activated, when you add our Controller/Presentation as exception controller in the twig config. Second, the core ones are actived only, when choosing cmf_seo.persistence.phpcr: true. But i can imagine to not load the best_matcher.xml when a config like cmf_seo.disable_core_matcher: false exists. So you can use own matcher without being forced to use the core once in combination with phpcr.

* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\SeoBundle;
Copy link
Member

Choose a reason for hiding this comment

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

if this class acts as controller, i would put it in the Controller namespace of our bundle

@dbu
Copy link
Member

dbu commented Oct 6, 2014

i would add configuration options for cmf_seo.error.phpcr_parent_matcher.enabled and cmf_seo.error.phpcr_ancestor_matcher.enabled or something like this. we probably don't need config for the feature per se, as it won't do anything when not reconfiguring the error controller in the application, right?

@dbu
Copy link
Member

dbu commented Oct 6, 2014

maybe we could have just one matcher class here, a ancestor mapper with a limit. to get a parent mapper you would use the ancestor with limit 1 ;-)

maybe rather than BestMatcher we could call this thing SuggestionProvider? its giving suggestions what page you might wanted to look at when you hit a 404 page.

@ElectricMaxxx
Copy link
Member Author

Right it does nothing.

But would have head aches with your config example. By enabling/disabling all i would just suppress the loading of a service Definition file, by enabling them as Single services i would have to create them manuallyin the extension class of suppress them in compiler Pass, where i do not have the config. =

@ElectricMaxxx
Copy link
Member Author

So you would see ancenstors as all children of a common parent?
I would See them as sibblings.

And again we would leave the meaning of grouped providers. By having them separate i you need the constraints: give me an array and a group name. And i pass that to the template. But with different logic in the providers? Maybe a ass. array with identifiers/groups as keys and nested array for the route suggestions? =

@ElectricMaxxx
Copy link
Member Author

So...
except the 2-in-1-SuggestionProvider story and the 1-insteadof-2-Enable-SuggestiongProvider story all open stuff should be fixed:

  • names: SuggestProvider instead of BestMatcher, even the tag
  • controller: instead of a presentation model it is a controller now
  • some CS and docBlock fixes

*
* @var array|SuggestionProviderInterface[]
*/
protected $chainOfSuggestions = array();
Copy link
Member

Choose a reason for hiding this comment

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

suggestionProviders or suggestionProviderChain?

@wouterj
Copy link
Member

wouterj commented Oct 7, 2014

As this is a huge feature, I'll properbly not make it into 1.2 (which is released this week)

@dbu
Copy link
Member

dbu commented Oct 7, 2014

yeah, rather get it right than rush it in.

@lsmith77 also raised the question if this actually belongs into the
SeoBundle or would merit a bundle of its own. its not tied to any other
features of the SeoBundle so it could be separated. while good 404 pages
is required for SEO, you could want good 404 pages without caring about
search engines.

@ElectricMaxxx
Copy link
Member Author

No problem, so i would be the first with a feature for 1.3 g

But will finish the open issues here this evening i think.

Then it will be your decission where to Merge.

@ElectricMaxxx
Copy link
Member Author

I would see it in SeoBundle as it is good for both SEO and for UX. Last can infect others to look into the CMF. Especially both SuggestionProvider, which are able to serve content right from the Heart of the CMF. =

@dbu
Copy link
Member

dbu commented Oct 9, 2014

looks sane to me. in conflict with master though.

as discussed, lets wait with merging until after the release and bump the version for this one.

@ElectricMaxxx
Copy link
Member Author

👍

@ElectricMaxxx ElectricMaxxx added this to the 1.2 milestone Oct 9, 2014
@lsmith77 lsmith77 removed this from the 1.2 milestone Oct 13, 2014
@lsmith77
Copy link
Member

this will have to wait for the next release cycle. btw also needs a rebase

@ElectricMaxxx
Copy link
Member Author

Ok.

spice up tests to see both parent and ancestor

little CS fix

more CS fixes

enabling core matcher/provider

rename BestMatcher -> SuggestionProvider

move presentation model -> controller, fix last namings (matcher -> suggest provider), fix tests

suggestion provider are able to add suggestions to the same group now, lists are merged

change name Ancestor -> Sibling for suggestion provider, fix adder for suggestion provider in controller - provider on equal groups are possible now.

enable both suggestion provider separately
@ElectricMaxxx
Copy link
Member Author

rebased and squashed. Created a 1.1 branch too. So feel free to merge when ok.

ElectricMaxxx added a commit that referenced this pull request Nov 7, 2014
create custom exception/error handling mechanism
@ElectricMaxxx ElectricMaxxx merged commit 0647f49 into master Nov 7, 2014
@ElectricMaxxx ElectricMaxxx deleted the rewrite-custom-exception-errors branch November 7, 2014 09:36
@dbu
Copy link
Member

dbu commented Nov 7, 2014

cool! @ElectricMaxxx did you do a doc PR as well? if not, can you please open an issue so we don't forget this? undocument features are unlucky...

@ElectricMaxxx
Copy link
Member Author

done in symfony-cmf/symfony-cmf-docs#606

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants