Conversation
/cc @rivaros |
returning null means 'skip this menuitem' |
@rivaros ok thanks, I get that now. |
I opt for having link types really;
then you can couple the different behaviors to a class or constant at least. |
sjopet: what would you propose for an API? |
this is what we currently have: https://github.com/sjopet/cmf-stuff I just noticed my colleague added some comments in the interface that describe the purpose. keep in mind the BaseMenuItem which is extended, is a very old version. |
Hello, |
No there's only one type of menuItem but it can link to different things.
The form type I mentioned in the previous comment is just for adding the link to the menu item. So if you choose internal from the type selection dropdown you would see a tree selector to select the document to link to. if you select external you should see a a simpel text input field and when 'no link' is selected you wo'nt see any fields. |
->method('generate') | ||
->will($this->throwException(new RouteNotFoundException('test'))); | ||
|
||
$this->factory->createItem('foobar', array()); |
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.
$this->assertNull()?
i like the refactoring you propose here. can you rebase on latest master and maybe have an assertion in the test, then lets merge! @sjopet regarding the form type for editing menu items: sounds like a useful thing. glad if you can PR that into the admin (note that there is currently another PR by @dantleech introducing menu roots as specific document types - just to avoid conflicts) |
@sjopet yes - this is exactly what I want to implement too. I.e. I want the "route target" to be a radio selection in the UI - and for that we need to store the I was going to have a look at this quite soon, maybe today. |
well the linkType could be implicit by only having one of the 3 ever set at the same time. storing linkType explicitly is redundant, and its problematic if people add their own additional things. i would prefer to make this a UI thing and just document the precedence in case people use an inferior UI that allows to generate potentially ambigous situations. |
I think the main benefit of a imo the user should be able to explicitly choose between multiple target/link types, and the values of these types should not be dependant on which one is currently "in use". Also, incase I didn't mention it, I want to improve the UI by making the target selection a RADIO select, and I think adding the |
I have to agree with dan here. I don't think this has to give problems with a different UI if you make the linkType a mandatory field or give it a default value. |
alright guys, you win :-) |
Regarding the migration, I have just made a PR for the |
Conflicts: ContentAwareFactory.php
ok. I have fixed the test, granted its a bit of an obfuscated one, but will hopefully revisit this with refactoring discussed here. Good to merge for me. |
I don't like declaring options in the constructor, its not very flexible. Have changed to a method call and also fixed the test.
Also, I don't understand this logic:
Surely that should be
if $this->allowEmptyItems === true return null
?. Throwing an exception would seem to indicate that empty items are not allowed. Also, can we be more concise with the naming - what are we allowing here? What is an empty item? The logic would seem to indicate "allowRouteNotFound" - but is maybe more acurate if we refactor it to "allowEmptyContent" ?Just my thoughts.