Fluid interface
Permalink
It appears that none of these PageList filter or sort methods have a return value. It would be very convenient if they returned $this so that you could chain methods together. For example:
$pageList = new PageList(); $pages = $pageList->filterByIsApproved($cvIsApproved) ->filterByUserID($uID) ->sortByPublicDate() ->get();
I believe you can just do this:From a coding elegance point of view, I agree with you. However, it's not entirely necessary.
Yes, you can do it that way. Actually, you have to. I'm just saying that a fluent interface would be nice and it would not break backwards compatibility.
Again, I certainly agree.
You could always mod the core and submit a diff file to the c5 guys. I know Andrew has uploaded a number of mod's I've made to c5's Github account.
You could always mod the core and submit a diff file to the c5 guys. I know Andrew has uploaded a number of mod's I've made to c5's Github account.
Did anyone ever follow up on this? I come from the Rails world and returning a $this would definitely make it a lot quicker to write and easier to read. I find myself repeatedly instantiating PageLists, running all these filters having to write my pagelist variable name over and over again, only to pass it in to a foreach() and never use it again. I really don't need that reference to my pagelist staying in scope at any point after that. The whole thing would be nicer if I could just write it all inside my foreach() statement.