rules icon indicating copy to clipboard operation
rules copied to clipboard

Added code for refining item context

Open stephenpurkiss opened this issue 9 years ago • 4 comments

Initial code for refining item context. See https://www.drupal.org/node/2281083#comment-9834577

Posting for visibility and testing.

stephenpurkiss avatar Apr 23 '15 12:04 stephenpurkiss

Will try to get on the regular IRC meeting, meanwhile here's where I'm at on this:

https://www.drupal.org/node/2281083#comment-9866613

So here's where my thinking's at currently:

  • from what I can tell, 7 allows you to alter the type of a list item. It uses the same alter hook for many similar functions such as add item to list, list contains, etc. With my limited knowledge of form api I can't tell whether it allows for the type of the item being added to the list (or whatever the function is) to be altered or not, but my hunch is it doesn't. Should it? That's another question - if alter hooks are there for enabling the complete control over types at runtime then yes, it should.
  • in 8 we should allow for refining configs on all available places, i.e. type of item and type of each item in list. I don't currently know how to achieve this in code, hence why posting update here before I spend days figuring out something which is wrong ;) It does beg the question though that surely if all this alter 'hook' is allowing for is changing of type then it could be extracted to a level higher up as 'type' should be discoverable?

Still reading up on various discussions around this so no doubt more will become clear as has done in the past week!

stephenpurkiss avatar Apr 26 '15 15:04 stephenpurkiss

OK I think I've got this working thanks to @tstoeckler who was here in spain today.

My next question is this covers refining the context for the item, not the list. In 7 you couldn't alter the item context, only the list. So I'm presuming I need to add code to alter context of the list? Do I need to step through each item in the list to achieve this? Some pointer would be good - I'm done for the day here but will continue tomorrow/next week.

stephenpurkiss avatar May 22 '15 15:05 stephenpurkiss

OK I've done the changes recommended but now stuck at what needs mocking in the test. I realise now we're not using getDataTypeId but getDataType so changed that but still no joy. Tried mocking all the things - getContext, getContextData and getDataDefinition, but that made no difference, still coming back as 'any' type.

stephenpurkiss avatar Jun 28 '15 21:06 stephenpurkiss

Am looking at ContextTest.php and see a whole setup routine for mocking context definitions and can see it's a bit more involved so will investigate that further

stephenpurkiss avatar Jun 28 '15 21:06 stephenpurkiss