Re: CakeAdvent 2014
Thank you José, it's awesome! Em qui, 4 de dez de 2014 01:17, Jose Diaz-Gonzalez j...@savant.be escreveu: Hi All! My name is Jose Diaz-Gonzalez, one of the core developers of CakePHP. You may have seen me in some of your codebases (especially if you use cakephp-upload) or from homebrew-php. But I'm not here about that. Like last year http://josediazgonzalez.com/2013/12/01/testing-your-cakephp-plugins-with-travis/, we're having a CakePHP Advent Calendar. 25 posts about CakePHP in the month of December. But unlike last years - which were self-contained tutorials - this years is a series of 3 tutorials where we will build fully working applications. If you've bought my CakePHP 2 book http://josediazgonzalez.com/cakephp-book/, it's in the same style of writing with a bit less hand-holding. These three tutorials will be 7 posts each, and completely free. Wanted to use bake but found it hard? Need to know how to implement events in a production application? Confused about how to integrate payment processing in your application? Do you want to build api's but are having a bad time? These tutorials are for you. Consider them a present from the core developers to the CakePHP community. I'll be posting a new post each day, and will be updating this thread with each one. Since I forget sometimes about google groups, feel free to beat me to the punch. Here are the first three in the series: - Introducing the CakePHP Advent Calendar 2014 http://bit.ly/cakeadvent-2014-1 - Designing an anonymous issue tracker in CakePHP http://bit.ly/cakeadvent-2014-2 - Customizing Bake in CakePHP 3 http://bit.ly/cakeadvent-2014-3 Let me know how you like the tutorials - or not - and how I can improve in comments on the posts or in this thread. Happy holidays! Jose -- 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. -- 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: In CakePHP 3, how do I bake admin controller?
In your config/routes.php add this: Router::prefix('admin', function ($routes) { $routes-fallbacks(); }); In AppController.php: class AppController extends Controller { public function initialize() { $this-loadComponent('Auth') } public function beforeFilter(Event $event) { if ($this-request-prefix === null) { $this-Auth-allow(); } } public function isAuthorized($user) { if ($this-request-prefix === 'admin') { return (bool)$user['role'] === 'admin'; } } } In src/Controller/Admin/UsersController.php namespace App\Controller\Admin; use App\Controller\AppController; class UsersController extends AppController { public function index() { $users = $this-paginate(); $this-set(compact('users')); } } Put the view template in src/Template/Admin/Users/index.ctp --cesar El miércoles, 3 de diciembre de 2014 13:55:20 UTC-2, frocco escribió: I want to create admin controller with view Thanks -- 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: Formatting of entities and maintaing different entity versions
Thanks for your post. This looks like a pretty good solution. It's also fairly clean. These two sections of the book also have good examples on using the mapReduce and formatResult methods: http://book.cakephp.org/3.0/en/orm/query-builder.html#adding-calculated-fields http://book.cakephp.org/3.0/en/orm/query-builder.html#modifying-results-with-map-reduce -- Steve On Wednesday, December 3, 2014 8:34:02 AM UTC+1, José Lorenzo wrote: There are a few ways of accomplishing this, but since we could say foursquare is command based (Depending on the url you visit you get compact or full) I would say the easiest is to apply data transformers from the controller, and use the hidden properties feature of the entities to display the correct amount of data: The entity: class Venue extends Entity { public function showCompact() { $this-_hidden = ['foo', 'bar', 'baz']; } } The Controller: class VenuesController extends AppController { public function explore() { // The Venues should be in compact format for this action $venues = $this-Venues-find('myCustomFinder')-formatResults(new SpecialFormatter('compact')); $this-set('venues', $venues); } } The Formatter: class SpecialFormatter { public function __construct($mode) { $this-mode = $mode; } public function __invoke($results) { return $results-map(function($entity) { if ($this-mode === 'compact') { $entity-showCompact(); } return $entity; }); } } When the results are rendered to son, each of th entities will only show the properties that are not hidden. With a bit more work you can improve this idea so you can tell the formatter to also be applied in associations or any nested property with different modes. On Tuesday, December 2, 2014 3:46:38 PM UTC+1, Steve Tauber wrote: With the introduction of entities in v3, I think there is the potential to solve a problem that I see come up having to do with the consistent formatting/versioning of entities. I have worked on a couple of projects that involve taking entities and creating different versions of the same entity. An example would be something like Foursquare's *User Object* which has a *Mini Object*, a *Compact Object*, and a *Complete Object*. [ https://developer.foursquare.com/docs/responses/user]. After retrieving data, I want to take the entities returned and format them all to the correct type, including the related models; e.g. Photos have their own versions. If we were to recreate the Foursquare api in CakePhp, we can use the ORM to give us the correct fields and related data, but then we might still need to do formatting. For instance, Photos will have it's own versions. This code could live as methods on the models. You could have User-formatMiniObject which then knows to return a stripped down entity. That *User Mini Object* would also convert the Photo field into a *Photo Mini Object* instead of a *Photo Compact Object*. This seems rather messy though. In 2.x, I currently use Containable to limit my fields but then I have messy, non DRY code that is intersecting the fields I need, and then formatting data for the related models. I think it would be useful to somehow declare these different versions on the entity. You could say that a *User Mini Object* has id, firstName, lastName, and photo field which is a *Photo Mini Object*. In the Photo model, I could declare that in order to create a *Photo Mini Object*, I need to call a method which will use my ImageStorage component to find the URLs. Or Perhaps, it's just a simple entity with id and url directly from the database. The main scenario where I've encountered this are building APIs with consistent data types which are returned. There might be users objects but due to permissions or privacy a subset of the data is returned to the end user. The API is rigidly defined and so the end user expects certain fields depending on the version of the entity returned. Thoughts? -- Steve -- 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.
List composite index baking index view
Hello everybody, At the very bake verify that the iterated field is a table index or not , I could make it through the $ schema [ $ field ] [ key ] , but the composite indexes are not listed. Has somehow gave can know if that field is index of some composite key ? -- 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: In CakePHP 3, how do I bake admin controller?
Thanks, But when I use bake, will it generate the controller under admin? On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote: I want to create admin controller with view Thanks -- 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: In CakePHP 3, how do I bake admin controller?
After bake just move Templates and Controllers to Admin directory and adjust the Controller namespace El jueves, 4 de diciembre de 2014 14:03:02 UTC-2, frocco escribió: Thanks, But when I use bake, will it generate the controller under admin? On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote: I want to create admin controller with view Thanks -- 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: In CakePHP 3, how do I bake admin controller?
No need to move anything Just use bake correctly as documented: cake bake ... --prefix admin That will create it in the right places. Am Donnerstag, 4. Dezember 2014 17:38:46 UTC+1 schrieb cesar calvo: After bake just move Templates and Controllers to Admin directory and adjust the Controller namespace El jueves, 4 de diciembre de 2014 14:03:02 UTC-2, frocco escribió: Thanks, But when I use bake, will it generate the controller under admin? On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote: I want to create admin controller with view Thanks -- 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: In CakePHP 3, how do I bake admin controller?
Thanks, Did not know about the --prefix admin Liking version 3 alot, have used yii and laravel before, also django On Wednesday, December 3, 2014 10:55:20 AM UTC-5, frocco wrote: I want to create admin controller with view Thanks -- 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: CakeAdvent 2014
For those following allowing, here is the third post in our 7-part tutorial series: - Schema Migrations with CakePHP 3 http://bit.ly/cakeadvent-2014-4 Let me know in the comments or here what parts of CakePHP you'd like me to cover, and enjoy! On Thu, Dec 4, 2014 at 6:04 AM, Leandro Machado Pereira llperei...@gmail.com wrote: Thank you José, it's awesome! Em qui, 4 de dez de 2014 01:17, Jose Diaz-Gonzalez j...@savant.be escreveu: Hi All! My name is Jose Diaz-Gonzalez, one of the core developers of CakePHP. You may have seen me in some of your codebases (especially if you use cakephp-upload) or from homebrew-php. But I'm not here about that. Like last year http://josediazgonzalez.com/2013/12/01/testing-your-cakephp-plugins-with-travis/, we're having a CakePHP Advent Calendar. 25 posts about CakePHP in the month of December. But unlike last years - which were self-contained tutorials - this years is a series of 3 tutorials where we will build fully working applications. If you've bought my CakePHP 2 book http://josediazgonzalez.com/cakephp-book/, it's in the same style of writing with a bit less hand-holding. These three tutorials will be 7 posts each, and completely free. Wanted to use bake but found it hard? Need to know how to implement events in a production application? Confused about how to integrate payment processing in your application? Do you want to build api's but are having a bad time? These tutorials are for you. Consider them a present from the core developers to the CakePHP community. I'll be posting a new post each day, and will be updating this thread with each one. Since I forget sometimes about google groups, feel free to beat me to the punch. Here are the first three in the series: - Introducing the CakePHP Advent Calendar 2014 http://bit.ly/cakeadvent-2014-1 - Designing an anonymous issue tracker in CakePHP http://bit.ly/cakeadvent-2014-2 - Customizing Bake in CakePHP 3 http://bit.ly/cakeadvent-2014-3 Let me know how you like the tutorials - or not - and how I can improve in comments on the posts or in this thread. Happy holidays! Jose -- 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. -- 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. -- 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.