Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
OK, I've got it. I will have a look to compile() method. Thanks for your help Il 16/apr/2014 21:06 "José Lorenzo" ha scritto: > Yeah, it will execute it as many times as you iterate the results. If you > want to "cache" the results of a set of formatters call "compile()" on the > resulting collec

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread José Lorenzo
Yeah, it will execute it as many times as you iterate the results. If you want to "cache" the results of a set of formatters call "compile()" on the resulting collection. This is because it needs to make sure formatters are applied to all rows. On Wednesday, April 16, 2014 5:06:38 PM UTC+2, ba

Re: navigation menu using cakePhp tree

2014-04-16 Thread euromark
You can build tree based menus using the Tree helper See www.dereuromark.de/2013/02/17/cakephp-and-tree-structures/ echo $this->Tree->generate($categories); Am Dienstag, 15. April 2014 19:41:20 UTC+2 schrieb Naresh Kumar: > > > I am using CakePHP tree to generate my navigation menu . I have

Re: CakePHP 2.4 Auth->login() always return TRUE ... ?

2014-04-16 Thread euromark
You are like the 400th person who didnt read that part of the documentation in 2.x http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#identifying-users-and-logging-them-in (red warning box) if ($this->Auth->login($this->request->data['User'])) {} always logs this data in

Re: CakePHP 3.0.0 development preview 2 released

2014-04-16 Thread euromark
I can't. Am Mittwoch, 16. April 2014 14:34:56 UTC+2 schrieb steven lee: > > who can send me some video about cakephp? > > On Thursday, March 13, 2014 5:35:36 AM UTC+8, José Lorenzo wrote: >> >> The CakePHP core team is excited to announce the second development >> preview of CakePHP 3.0.0[1]. In

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
uhm... I found when it repeats twice. try $table = TableRegistry::get('Articles'); $table ->find() ->formatResults(function($r) { return $r->map(function($r) { debug('a'); return $r; }); }) ->first(); debug($table->toArray()); I have debug($table->toArray()); after the find chain. I suppose tha

Re: CakePHP 3.0.0 development preview 2 released

2014-04-16 Thread steven lee
who can send me some video about cakephp? On Thursday, March 13, 2014 5:35:36 AM UTC+8, José Lorenzo wrote: > > The CakePHP core team is excited to announce the second development > preview of CakePHP 3.0.0[1]. In the few months since 3.0.0-dev1, we've been > hard at work incorporating community

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread José Lorenzo
I just tested with this code and checked that the callback is executed only once: $table = TableRegistry::get('Articles'); $table ->find() ->formatResults(function($r) { return $r->map(function($r) { debug('a'); return $r; }); }) ->first(); On Wednesday, April 16, 2014 2:33:35 PM UTC+2, José Lor

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread José Lorenzo
Paste the full code where you see it being called twice, please. I will also check with my own code On Wednesday, April 16, 2014 2:23:54 PM UTC+2, bato wrote: > > ok it works! > > To me remain a mistery why using first() the callback in $results->map() > is called twice while not using first is

Re: Recommendation Algorithm in cakePHP

2014-04-16 Thread Борислав Събев Borislav Sabev
Business-related DATA-connected logic is best residing in the Model, yes but there are still other considerations. What if your logic was somehow VIew-related? For example you had to show some complex three-like structure and you wanted to pre-process it on the server? A model would do of course

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread Alberto Pagliarini
ok it works! To me remain a mistery why using first() the callback in $results->map() is called twice while not using first is called once. Could it be a bug? 2014-04-16 13:11 GMT+02:00 José Lorenzo : > Try this > > public findFlat($query, $options = []) { > return $query->formatResults(functi

Re: cake 3 - is it possible to use formatResults to stacking multiple operations like mapper/reducer?

2014-04-16 Thread José Lorenzo
Try this public findFlat($query, $options = []) { return $query->formatResults(function($results, $query) { return $results->map(function($row) { if ($row->content) { $row->set($row->content->toArray(), ['guard' => false]); $row->unsetProperty('content'); } return $row; }); }); } $row = $table->f

CakePHP 2.4 Auth->login() always return TRUE ... ?

2014-04-16 Thread MedAL
Hello,Iread the documentation to create a simple login form.each time I try to log in it returns true always; //UsersController public function login() { if ($this->Auth->user()) { $this->redirect($this->Auth->redirect()); } if ($this->request->is('post')) { $thi