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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to