Re: set(compact('whatever'))
On Jan 26, 11:05 pm, brian bally.z...@gmail.com wrote: On Mon, Jan 26, 2009 at 10:23 PM, Nate nate.ab...@gmail.com wrote: This has already been covered many times in the mailing list. Please search before posting next time. Thanks. Yeah, yeah. Meaning, you're fed up with people complaining about the Cake devs' seemingly-arbitrary decisions, like enforcing coding styles on others. Whatever. I guess it'd bug me, too. FWIW, I'm sure there's a very good reason. I take back the inane comment. Sorry for being so melodramatic. Nope, there's actually no good reason, and it is a pretty stupid idea. That's why I'm removing it in the next release. And I didn't search for this because I didn't know that Inflector had anything to do with my problem when I started this thread. You could have searched the mailing list for set() and variable names or set and variables. In either case, the answer would have been in the first few results. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
Nate, read the first post in this thread. It wasn't as simple as that. Sometimes, the just search the list remark doesn't wash. I did do a search after your earlier comment (that is, once I realised that Inflector was involved and so could refine the search). I found 2 threads which discussed the issue. Yet, in neither of them was there an explanation as to why. Anyway, no biggie. On Wed, Jan 28, 2009 at 10:31 AM, Nate nate.ab...@gmail.com wrote: On Jan 26, 11:05 pm, brian bally.z...@gmail.com wrote: On Mon, Jan 26, 2009 at 10:23 PM, Nate nate.ab...@gmail.com wrote: This has already been covered many times in the mailing list. Please search before posting next time. Thanks. Yeah, yeah. Meaning, you're fed up with people complaining about the Cake devs' seemingly-arbitrary decisions, like enforcing coding styles on others. Whatever. I guess it'd bug me, too. FWIW, I'm sure there's a very good reason. I take back the inane comment. Sorry for being so melodramatic. Nope, there's actually no good reason, and it is a pretty stupid idea. That's why I'm removing it in the next release. And I didn't search for this because I didn't know that Inflector had anything to do with my problem when I started this thread. You could have searched the mailing list for set() and variable names or set and variables. In either case, the answer would have been in the first few results. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
I think the issue is PHP and not Cake. To demonstrate the problem, try this... public function setStuff($foo, $bar, $something_else) { $foo = $foo; $bar = $bar; $something_else = $something_else; $this-controller-set(compact('foo', 'bar', 'something_else')); } And I have no idea why PHP behaves that way, but it does. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
Yeah, I guess that screws with the symbol table. I agree that seems a bit buggy. But I don't follow your logic here. I'm not doing what you have in your example. It's Cake, not PHP, that has the unexpected behavior in my case. Anyway, I figured out how to get around it, documentation be damned. On Tue, Jan 27, 2009 at 2:15 PM, rtconner rtcon...@gmail.com wrote: I think the issue is PHP and not Cake. To demonstrate the problem, try this... public function setStuff($foo, $bar, $something_else) { $foo = $foo; $bar = $bar; $something_else = $something_else; $this-controller-set(compact('foo', 'bar', 'something_else')); } And I have no idea why PHP behaves that way, but it does. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
No, wait ... I have no idea at all what you're referring to. I just realised that i had a typo when i ran what you posted. AFAICT, doing this: $foo = $foo; $bar = $bar; $something_else = $something_else; ... has absolutely no effect. I thought you were trying to point out some PHP strangeness even though the lines are completely unnecessary. If, instead you mean the, Undefined variable: something_else ... notice, that's Cake doing that. And that's precisely what this is all about. Cake's set() method passes the var name to Inflector, which camelizes it. Again, though, the workaround is to pass false as the second param. On Tue, Jan 27, 2009 at 3:58 PM, brian bally.z...@gmail.com wrote: Yeah, I guess that screws with the symbol table. I agree that seems a bit buggy. But I don't follow your logic here. I'm not doing what you have in your example. It's Cake, not PHP, that has the unexpected behavior in my case. Anyway, I figured out how to get around it, documentation be damned. On Tue, Jan 27, 2009 at 2:15 PM, rtconner rtcon...@gmail.com wrote: I think the issue is PHP and not Cake. To demonstrate the problem, try this... public function setStuff($foo, $bar, $something_else) { $foo = $foo; $bar = $bar; $something_else = $something_else; $this-controller-set(compact('foo', 'bar', 'something_else')); } And I have no idea why PHP behaves that way, but it does. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
So I just got a clue and stuck this right after my call to the component: die(debug($this-viewVars)); It turns out that Cake sets loose Inflector upon the var names! What kind of inane feature is that?!? And no flag to keep it from doing so! I think I'm going to have to break down and alter Cake core for this. Please, someone talk me down from the ledge and explain to me why this isn't a bug and I really should appreciate it. On Mon, Jan 26, 2009 at 6:54 PM, brian bally.z...@gmail.com wrote: I'm putting together a component to move a bunch of logic out of one of my controllers. The component has a method whose sole purpose is to set a number of vars for a view that's tightly-coupled to the component. I wanted to do it this way because there are several places where these are required to be set, though the values come from different places. This way, I can pass the values t the component and have it set everything the way it requires. Anyway, my component method looks something like: public function setStuff($foo, $bar, $something_else) { $this-controller-set(compact('foo', 'bar', 'something_else')); } The component also has this startup method: function startup($controller) { $this-controller = $controller; } (and, of course, a $controller member var) Unfortunately, this doesn't appear to be working--I'm getting undefined vars in the view. Is there any reason why I couldn't set view vars from the component like this? I know the vars are available in the symbol table, of course, though I did put a debug(compact(...)) in there, just to be sure. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
I was ruminating over the code while having dinner just now and remembered something. I realised that set() does provide a way to avoid Inflector having its way with one's var names: 00640 foreach ($data as $name = $value) { 00641 if ($name === 'title') { 00642 $this-pageTitle = $value; 00643 } else { 00644 if ($two === null is_array($one)) { 00645 $this-viewVars[Inflector::variable($name)] = $value; 00646 } else { 00647 $this-viewVars[$name] = $value; 00648 } 00649 } 00650 } I just needed to pass false as the second param. 3 cheers for undocumented features! On Mon, Jan 26, 2009 at 7:09 PM, brian bally.z...@gmail.com wrote: So I just got a clue and stuck this right after my call to the component: die(debug($this-viewVars)); It turns out that Cake sets loose Inflector upon the var names! What kind of inane feature is that?!? And no flag to keep it from doing so! I think I'm going to have to break down and alter Cake core for this. Please, someone talk me down from the ledge and explain to me why this isn't a bug and I really should appreciate it. On Mon, Jan 26, 2009 at 6:54 PM, brian bally.z...@gmail.com wrote: I'm putting together a component to move a bunch of logic out of one of my controllers. The component has a method whose sole purpose is to set a number of vars for a view that's tightly-coupled to the component. I wanted to do it this way because there are several places where these are required to be set, though the values come from different places. This way, I can pass the values t the component and have it set everything the way it requires. Anyway, my component method looks something like: public function setStuff($foo, $bar, $something_else) { $this-controller-set(compact('foo', 'bar', 'something_else')); } The component also has this startup method: function startup($controller) { $this-controller = $controller; } (and, of course, a $controller member var) Unfortunately, this doesn't appear to be working--I'm getting undefined vars in the view. Is there any reason why I couldn't set view vars from the component like this? I know the vars are available in the symbol table, of course, though I did put a debug(compact(...)) in there, just to be sure. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
This has already been covered many times in the mailing list. Please search before posting next time. Thanks. On Jan 26, 8:31 pm, brian bally.z...@gmail.com wrote: I was ruminating over the code while having dinner just now and remembered something. I realised that set() does provide a way to avoid Inflector having its way with one's var names: 00640 foreach ($data as $name = $value) { 00641 if ($name === 'title') { 00642 $this-pageTitle = $value; 00643 } else { 00644 if ($two === null is_array($one)) { 00645 $this-viewVars[Inflector::variable($name)] = $value; 00646 } else { 00647 $this-viewVars[$name] = $value; 00648 } 00649 } 00650 } I just needed to pass false as the second param. 3 cheers for undocumented features! On Mon, Jan 26, 2009 at 7:09 PM, brian bally.z...@gmail.com wrote: So I just got a clue and stuck this right after my call to the component: die(debug($this-viewVars)); It turns out that Cake sets loose Inflector upon the var names! What kind of inane feature is that?!? And no flag to keep it from doing so! I think I'm going to have to break down and alter Cake core for this. Please, someone talk me down from the ledge and explain to me why this isn't a bug and I really should appreciate it. On Mon, Jan 26, 2009 at 6:54 PM, brian bally.z...@gmail.com wrote: I'm putting together a component to move a bunch of logic out of one of my controllers. The component has a method whose sole purpose is to set a number of vars for a view that's tightly-coupled to the component. I wanted to do it this way because there are several places where these are required to be set, though the values come from different places. This way, I can pass the values t the component and have it set everything the way it requires. Anyway, my component method looks something like: public function setStuff($foo, $bar, $something_else) { $this-controller-set(compact('foo', 'bar', 'something_else')); } The component also has this startup method: function startup($controller) { $this-controller = $controller; } (and, of course, a $controller member var) Unfortunately, this doesn't appear to be working--I'm getting undefined vars in the view. Is there any reason why I couldn't set view vars from the component like this? I know the vars are available in the symbol table, of course, though I did put a debug(compact(...)) in there, just to be sure. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: set(compact('whatever'))
On Mon, Jan 26, 2009 at 10:23 PM, Nate nate.ab...@gmail.com wrote: This has already been covered many times in the mailing list. Please search before posting next time. Thanks. Yeah, yeah. Meaning, you're fed up with people complaining about the Cake devs' seemingly-arbitrary decisions, like enforcing coding styles on others. Whatever. I guess it'd bug me, too. FWIW, I'm sure there's a very good reason. I take back the inane comment. Sorry for being so melodramatic. And I didn't search for this because I didn't know that Inflector had anything to do with my problem when I started this thread. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---