Comparable 2.xx to 3.xx functionality
Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use Cake\Utility\Security; use Cake\ORM\Entity; class UsersController extends AppController { Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated? Thanks for any replies. Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Comparable 2.xx to 3.xx functionality
There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' = array('email', 'password'))) Yes your controller looks just about right and it is very easy to understand what to expect as I read further. HTH T On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards goo...@bubbletoonz.com wrote: Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use Cake\Utility\Security; use Cake\ORM\Entity; class UsersController extends AppController { Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated? Thanks for any replies. Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- = Hire a CakePHP dev team : http://sanisoft.com = -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Comparable 2.xx to 3.xx functionality
Thanks, but neither seem to work... You suggested, $allTitles = $articles-find()-extract('title'); I tried $users-find()-extract('temp_key') but gives an error of Call to a member function find() on a non-object You suggested $this-User-validates(array('fieldList' = array('email', 'password'))) I tried $this-User-validates(array('fieldList' = array('email'))) but gives an error of Unknown method quot;validatesquot; I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know? In fact, I've just found an entry on validating in controllers in 'http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in 'http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it! Dave On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote: There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' = array('email', 'password'))) Yes your controller looks just about right and it is very easy to understand what to expect as I read further. HTH T On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards goo...@bubbletoonz.com javascript: wrote: Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use Cake\Utility\Security; use Cake\ORM\Entity; class UsersController extends AppController { Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated? Thanks for any replies. Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- = Hire a CakePHP dev team : http://sanisoft.com = -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Accessing Vendor classes in cakephp 3 Controller
You'll need to know the names of the classes and functions you want to use. Once you know that, using the mandrill library is exactly the same as using classes/functions from CakePHP. -mark -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
When do views render?
While trying to track down an error in a UsersController method: Notice (8): Undefined index: User [APP/Controller/UsersController.php, line ...] I've come back to an issue that has yet to clarify in my head, specifically, the line in the cakephp v2 controller documentation that says: ... once a controller action has completed, CakePHP will handle rendering and delivering the View. Seems to me this line in the documentation is incorrect. In fact, a controller renders a view and then control may return to the same controller method to process any form date submitted by the view. Am I wrong in my thinking? - James -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Comparable 2.xx to 3.xx functionality
I think to read a bit more of how php works, it will help you understand much better how to work with CakePHP. I don't know a good tutorial for learning PHP, though. You can also google about the new features in the language since PHP 5.3, specially the changes in 5.4 since you look confused about the use of square brackets. On Sunday, September 21, 2014 7:43:03 PM UTC+2, Dave Edwards wrote: Thanks, but neither seem to work... You suggested, $allTitles = $articles-find()-extract('title'); I tried $users-find()-extract('temp_key') but gives an error of Call to a member function find() on a non-object You suggested $this-User-validates(array('fieldList' = array('email', 'password'))) I tried $this-User-validates(array('fieldList' = array('email'))) but gives an error of Unknown method quot;validatesquot; I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know? In fact, I've just found an entry on validating in controllers in ' http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in ' http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it! Dave On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote: There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' = array('email', 'password'))) Yes your controller looks just about right and it is very easy to understand what to expect as I read further. HTH T On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards goo...@bubbletoonz.com wrote: Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use Cake\Utility\Security; use Cake\ORM\Entity; class UsersController extends AppController { Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated? Thanks for any replies. Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+u...@googlegroups.com. To post to this group, send email to cake...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout. -- = Hire a CakePHP dev team : http://sanisoft.com = -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
[OFF-TOPIC] Questionário de pesquisa sobre Ambiente de Desenvolvimento de Software / Questionnaire survey of Software Development Environment
Olá! Estou realizando uma pesquisa no IME-USP sobre Ambiente de Desenvolvimento de Software e preciso verificar uma hipótese , para isso elaborei um questionário . Agradeço se puder despender 5 min. respondendo a ele. A seguir o link: http://tinyurl.com/oykxyft Agradeço se puder compartilhar este email nas comunidades que participa. Muito obrigada! Abraços, --- *English version* Hello! I am conducting research at IME-USP on Environment Software Development and need to check a hypothesis, for it drew up a questionnaire. I appreciate if you can spend 5 min. responding to it. The following link: http://tinyurl.com/laa43oz I appreciate if you can share this email in participating communities. Thank you! hugs, *--* *Suelen Goularte Carvalho* *suelengc.com http://www.suelengc.com.br* | @suelengc -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Comparable 2.xx to 3.xx functionality
Thanks, I thought that this is where I may get some help over the new 'features' or ways of working in 3.xx, that I do not understand, and not told to go and read up on PHP - that's actually quite dismissive and patronising. What I actually need to understand is what you've done to Cake 3.xx. because I do not understand your new documentation - sorry for being so thick. I may be mistaken, but I thought that cake got it's name because using the framework was a 'piece of cake' i.e. simple to use - I'm afraid as a user of cake that this is no longer the case :( I do understand 2.xx and its' documentation... not 3.xx A a couple of examples, in 2.xx I could do this $key = $this-User-field('temp_key') now I have to do this /* something else needs to go here, but I haven't worked it out yet because I keep getting errors*/ $key = $users-find()-extract('temp_key') another example is that I could do this if ($this-User-validates(array('fieldList' = array('email' { } now I have to do this $users = TableRegistry::get('Users'); $user = $users-newEntity($this-request-data()); $valid = $users-validate($user, ['email']); if ($valid) { } Is this progress? With regards to square brackets, (now that I've looked it up), you could have simply said that in PHP 5.4 square brackets are a short syntax for array(), and whilst the old method will not be removed, we've decide to use them. I would have understood that - so I'm obviously not that thick. If we were all programmers to your standard, we wouldn't need to use a framework, but a framework *should* remove the hard work... Thanks for the reply. Dave On Sunday, 21 September 2014 21:03:00 UTC+1, José Lorenzo wrote: I think to read a bit more of how php works, it will help you understand much better how to work with CakePHP. I don't know a good tutorial for learning PHP, though. You can also google about the new features in the language since PHP 5.3, specially the changes in 5.4 since you look confused about the use of square brackets. On Sunday, September 21, 2014 7:43:03 PM UTC+2, Dave Edwards wrote: Thanks, but neither seem to work... You suggested, $allTitles = $articles-find()-extract('title'); I tried $users-find()-extract('temp_key') but gives an error of Call to a member function find() on a non-object You suggested $this-User-validates(array('fieldList' = array('email', 'password'))) I tried $this-User-validates(array('fieldList' = array('email'))) but gives an error of Unknown method quot;validatesquot; I wouldn't have thought that the second solution would have worked anyway as 3.xx seems to have done away with the use of the word array in favour of square brackets. why I don't know? In fact, I've just found an entry on validating in controllers in ' http://book.cakephp.org/3.0/en/orm/table-objects.html' why this isn't in 'http://book.cakephp.org/3.0/en/core-libraries/validation.html', I again don't know. This seems to be a common theme with the new docs, with a lot of useful information scattered across the docs in many different places and not always where you'd expect to find it! Dave On Sunday, 21 September 2014 13:29:55 UTC+1, Dr. Tarique Sani wrote: There are several ways to achieve what you want and they are all in the docs. Quoting a few lines from the V3 Book $allTitles = $articles-find()-extract('title'); //you can add a -where() to this $this-User-validates(array('fieldList' = array('email', 'password'))) Yes your controller looks just about right and it is very easy to understand what to expect as I read further. HTH T On Sun, Sep 21, 2014 at 4:23 PM, Dave Edwards goo...@bubbletoonz.com wrote: Hi, I am trying to write an app in 3.xx using functionality that I have previously used in 2.xx but despite scouring the docs, I cannot find the answers. Apologies if they are in there, but there seems to be 5x the amount of documentation especially around the new ORM. In 2.xx I could easily find the value of a single field e.g. $this-User-field('temp_key') Is there a 3.xx equivalent ? In 2.xx I could validate a field in a model e.g. $this-User-validates(array('fieldList' = array('email'))) Is there a 3.xx equivalent ? Lastly a general question. The top of my Users controller currently looks like this, and I've not yet finished it... namespace App\Controller; use App\Controller\AppController; use Cake\Network\Exception\ForbiddenException; use Cake\Event\Event; use Cake\ORM\TableRegistry; use Cake\Utility\Security; use Cake\ORM\Entity; class UsersController extends AppController { Does this look right, compared to the simplicity of 2.xx this now looks very unwieldy and complicated? Thanks for any replies. Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group.
3.0: Entity get/set mutators
i have several tables with an `active` column, and the Admin should be able to de/activate records to determine whether they related records are available in the application. Instead of constantly converting T/F or 1/0 to Active/Inactive, i wrote an Entity getter: protected function _getActive($active) { return $active ? 'Active' : 'Inactive'; } That's been working pretty well. The Entity-active property always provides the string. The problem is updating the data: SomeTableController gets a request like */some_table/active/2/1* to set ID 2 active (1): public function active($id, $active) { $entity = $this-SomeTable-get($id); $entity-active = $active; if ($this-SomeTable-save($entity)) { // Success! } else { // Fail! } } The problem: save() reports a successful save, but the database isn't updated. Scratch that: the `modified` column is updated, but not the `active` flag. If i kill _getActive() the update works, but i lose the convenience of the string representation. My *guess* is, i need a setter to handle the switch, but i'm not sure exactly how they work. The documentation (http://book.cakephp.org/3.0/en/orm/entities.html#Cake\ORM\Entity::set) for set mutators shows an example of setting some *other* entity property ('slug') using the 'title' property. But there's no example for mutating the property being called, and i don't know if that even makes sense... Along with no _setActive mutator, i also tried the following: protected function _setActive($active) { // $this-set('active', $active); -- Created loop condition fatal error. $this-_properties['active'] = $active; return $active; } No luck. It does the same as no setter: updates the entity (with updated active modified properties), but save() doesn't write the changed active property to the database. Any help? Thanks. -joe t. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.