Cakephp Unit testing:using fixtures in components
Hi, Iam writing test cases for one component ,need to use fixtures in compoment. my code is Class SampleComponentTest extends TestCase { public $component = null; public $controller = null; public $fixtures = ['app.cities','plugin.sampleplugin.states']; public function setUp() { parent::setUp(); $request = new Request(); $response = new Response(); $this->controller = $this->getMock( 'Cake\Controller\Controller', [], [$request, $response] ); $registry = new ComponentRegistry($this->controller); $this->component = new SampleComponent($registry); } } And i need to use two fixtures ,one is from app and another is from plugin. when i run the code i got followign exception "Exception: Referenced fixture class "SamplePlugin\Test\Fixture\StatesFixture" not found. Fixture "plugin.sampleplugin.states" was referenced in test case "App\Test\TestCase\Controller\Component\SampleComponentTest". in [D:\Projects\xampp\htdocs\testapp\vendor\ cakephp\cakephp\src\TestSuite\Fixture\FixtureManager.php, line 213]". please provide the solutions to that how to use fixtures in component with sample code/ doubts 1)$this->component is mock object or direct object> 2)what is second parameter of getMock() method(if i provide empty it giving the error,above i replaced with empty) 3) -- 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 https://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.
Re: Lazy loading components
Thanks for your answer! Keep up the great work! Atentamente, Gonçalo Marrafa On 18 March 2015 at 12:12, euromark wrote: > They need to be able to run initialize() and startup() before any action, > so thats hard to do. > And yes, micro-opt. without a real value IMO :) > > Mark > > > Am Mittwoch, 18. März 2015 11:53:14 UTC+1 schrieb Gonçalo Marrafa: > >> Hi there! >> >> Is there a way to enable lazy loading of components? As far as i can tell >> (i'm using 2.6.3) all components listed in $components variable are >> loaded and initialized when the controller is loaded. Shouldn't it use the >> same logic as models in which models are only loaded and initialized when >> used? Am i doing something wrong? >> >> As an example, if i have a controller that uses the Paginator component >> in one action but has ten actions, in all nine other actions the component >> is created without need. Maybe micro-optimizing but still >> >> Thanks in advance. >> >> Gonçalo. >> >> -- > 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 a topic in the > Google Groups "CakePHP" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/cake-php/Zx-uECAHoBo/unsubscribe. > To unsubscribe from this group and all its topics, 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: Lazy loading components
They need to be able to run initialize() and startup() before any action, so thats hard to do. And yes, micro-opt. without a real value IMO :) Mark Am Mittwoch, 18. März 2015 11:53:14 UTC+1 schrieb Gonçalo Marrafa: > > Hi there! > > Is there a way to enable lazy loading of components? As far as i can tell > (i'm using 2.6.3) all components listed in $components variable are > loaded and initialized when the controller is loaded. Shouldn't it use the > same logic as models in which models are only loaded and initialized when > used? Am i doing something wrong? > > As an example, if i have a controller that uses the Paginator component in > one action but has ten actions, in all nine other actions the component is > created without need. Maybe micro-optimizing but still > > Thanks in advance. > > Gonçalo. > > -- 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.
Lazy loading components
Hi there! Is there a way to enable lazy loading of components? As far as i can tell (i'm using 2.6.3) all components listed in $components variable are loaded and initialized when the controller is loaded. Shouldn't it use the same logic as models in which models are only loaded and initialized when used? Am i doing something wrong? As an example, if i have a controller that uses the Paginator component in one action but has ten actions, in all nine other actions the component is created without need. Maybe micro-optimizing but still Thanks in advance. Gonçalo. -- 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: Angular/Polymer web components and CakePHP
Good thoughts. The downside of familiarity, of course, is that I could be missing out on something better by sticking to what I know best. You are right about the V layer though. On 22 Sep 2014, at 12:52, Dr. Tarique Sani wrote: > You mean should you learn an entire new framework so that you could have one > layer less :D > > Whenever I get such projects the temptation is strong to go with some of the > so called REST api frameworks but I keep coming back to cake for the > familiarity and flexibility. Imaging if you did want a V layer at a later > date... > > Just my 2c > > T > > On Mon, Sep 22, 2014 at 2:27 PM, Jeremy Burns > wrote: > Canvassing some opinion... > > I'm just about to start a project that has an Angular and/or Polymer web > components front end, so the API only ever needs to send JSON responses and > receive normal posts/get requests. As such, there is no need for the 'V' part > of an MVC framework. I know CakePHP can do this very well (I've already built > one) but is it still considered the best/an ideal framework for this purpose? > > -- > 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. -- 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: Angular/Polymer web components and CakePHP
You mean should you learn an entire new framework so that you could have one layer less :D Whenever I get such projects the temptation is strong to go with some of the so called REST api frameworks but I keep coming back to cake for the familiarity and flexibility. Imaging if you did want a V layer at a later date... Just my 2c T On Mon, Sep 22, 2014 at 2:27 PM, Jeremy Burns wrote: > Canvassing some opinion... > > I'm just about to start a project that has an Angular and/or Polymer web > components front end, so the API only ever needs to send JSON responses and > receive normal posts/get requests. As such, there is no need for the 'V' > part of an MVC framework. I know CakePHP can do this very well (I've > already built one) but is it still considered the best/an ideal framework > for this purpose? > > -- > 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.
Angular/Polymer web components and CakePHP
Canvassing some opinion... I'm just about to start a project that has an Angular and/or Polymer web components front end, so the API only ever needs to send JSON responses and receive normal posts/get requests. As such, there is no need for the 'V' part of an MVC framework. I know CakePHP can do this very well (I've already built one) but is it still considered the best/an ideal framework for this purpose? -- 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: Custom components not working on cakephp 3
Thank you Jose Lorenzo. Regards, Jipson On Thursday, 31 July 2014 14:45:08 UTC+1, José Lorenzo wrote: > > You're missing the namespace declaration: > > namespace App\Controller\Component; > > On Thursday, July 31, 2014 3:36:34 PM UTC+2, Jipson Thomas wrote: >> >> Hi , >> I have created a component using the following code on >> src/Controller/Component/JtfilterComponent.php file >> >> > use Cake\Controller\Component; >> class JtfilterComponent extends Component { >> public function doComplexOperation($amount1, $amount2) { >> return $amount1 + $amount2; >> } >> } >> >> >> And on my controller file I added the following code >> >> public $components = ['Paginator','Jtfilter']; >> >> When I am trying to access the controller I am getting the following >> error. >> >> >> Missing Component >> >> *Error: * *JtfilterComponent* could not be found. >> >> *Error: * Create the class *JtfilterComponent* below in file: >> src/Controller/Component/JtfilterComponent.php >> >> > class JtfilterComponent extends Component { >> >> } >> >> *Notice: * If you want to customize this error message, create >> src/Template/Error/missing_component.ctp >> Stack Trace >> Would you please help me to fix this? >> >> Regards, >> Jipson >> > -- 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: Custom components not working on cakephp 3
You're missing the namespace declaration: namespace App\Controller\Component; On Thursday, July 31, 2014 3:36:34 PM UTC+2, Jipson Thomas wrote: > > Hi , > I have created a component using the following code on > src/Controller/Component/JtfilterComponent.php file > > use Cake\Controller\Component; > class JtfilterComponent extends Component { > public function doComplexOperation($amount1, $amount2) { > return $amount1 + $amount2; > } > } > > > And on my controller file I added the following code > > public $components = ['Paginator','Jtfilter']; > > When I am trying to access the controller I am getting the following error. > > > Missing Component > > *Error: * *JtfilterComponent* could not be found. > > *Error: * Create the class *JtfilterComponent* below in file: > src/Controller/Component/JtfilterComponent.php > > class JtfilterComponent extends Component { > > } > > *Notice: * If you want to customize this error message, create > src/Template/Error/missing_component.ctp > Stack Trace > Would you please help me to fix this? > > Regards, > Jipson > -- 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.
Custom components not working on cakephp 3
Hi , I have created a component using the following code on src/Controller/Component/JtfilterComponent.php file 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.
Testing components
I have a component that is called from the UsersController and a few others. Code in the component calls a find on the User model via the controller: $user = $this->Controller->User->findById($userId); How do I set up a reference to the UsersController inside the component test case so I can call a function of the component within the test case? -- 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: Best Practice Question - Components
I would say that calculations, and verification of amounts would be perfect functionality to place on the model. You wouldn't normally need a controller to determine the sum of items in an order, so why put it in a controller. For a shopping cart, you still might use a model to store the cart contents and cart items. You might query the cart to see what the total value is. This is not a calculation that the controller would need to make, so you wouldn't need to do it in a component either. All business logic for an entity should stay with the entity, and the model is the perfect place for that. What you might put in the component is functionality to load a cart that is attached to the session, or clear the cart from the session, if the user requests it, or save cart modifications to the session at the end the controller lifecycle. Interesting to note, in CakePHP 3.0, the model will be split between an Entity and a Table. The Table will take care of the schema, and typical database/CRUD operations, while the Entity will concentrate more on the business logic side of things. Regards Reuben Helms On Thu, Nov 7, 2013 at 10:08 AM, Kristen M wrote: > Yeah, the point of the exercise is to do things the "Cake Way" and take > advantage of all things automagical and Cake. ;) > > After puzzling over the docs for a bit and realizing it's not bad form to > have a controller use multiple models, I decided that splitting the > existing classes into a model and a component was probably the "correct" > solution. The model handles all the data, while the component contains > common functions all controllers that use the model will need, like > calculations and verification of amounts. > > > > > -- > 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 a topic in the > Google Groups "CakePHP" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/cake-php/M6i0tin0b5Q/unsubscribe. > To unsubscribe from this group and all its topics, 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/groups/opt_out. > -- 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/groups/opt_out.
Re: Best Practice Question - Components
Yeah, the point of the exercise is to do things the "Cake Way" and take advantage of all things automagical and Cake. ;) After puzzling over the docs for a bit and realizing it's not bad form to have a controller use multiple models, I decided that splitting the existing classes into a model and a component was probably the "correct" solution. The model handles all the data, while the component contains common functions all controllers that use the model will need, like calculations and verification of amounts. -- 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/groups/opt_out.
Re: Best Practice Question - Components
If you have existing class that work, then you could include them as Vendor code, and have your controllers call their find and save functions. However, doing things the CakePHP way, you'll probably want to convert those classes to Models, rather than Components. Models are where your business logic and validation rules go. I used to think that anything required by more than one controller should go into a component, but I'm thinking that components are for things that need to plug into the controller lifecycle. On Wednesday, 6 November 2013 06:03:19 UTC+10, Kristen M wrote: > > I'm not a new programmer (I'd say advanced beginner/intermediate) but I'm > quite new to Cake and MVC in general. > > I've decided best way to learn CakePHP and MVC is to take an existing > (functional, live) project and port it to Cake for kicks. Get the grand > tour of all the basics. > > In my existing project I have a number of utility classes that are used by > the other classes. 2 of them are an Item class and a Banking class. Item > obviously contains all the information about a user's inventory, plus > handles updating/deducting items, as well as using items. Banking does just > that- tracks a user's currency and handles transactions. Banking is used > between the Shop systems, Item is used by Shop and various action classes. > So I need a way to share their functionality between all the various other > controllers that require them. > > Simple example would be the user wants to buy an item from the shop, have > to verify the item is in stock, the item's price, that the player has the > currency to pay for it, deliver the item, deduct the payment and deduct the > item from shop inventory. While a different Controller (say, Toll Bridge) > needs the Banking functions to verify the user has the funds to pay the > toll, then debit the transaction. > > It SOUNDS like what I need to do is to create Banking & Item Components, > then the other controllers can make use of them as needed. However, this > would also require including various queries to chat with the database. The > CakePHP example on Components only shows a simple math operation with > passed params, and says nothing about if using Components as little > "bundles" of functionality that involve their own validations and database > interactions (although this is strongly implied) There is some conversation > on the 'net that what actually needs to happen is Banking and Item should > be controllers, and they get imported as needed. > > What's the best way to go about this? > -- 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/groups/opt_out.
Best Practice Question - Components
I'm not a new programmer (I'd say advanced beginner/intermediate) but I'm quite new to Cake and MVC in general. I've decided best way to learn CakePHP and MVC is to take an existing (functional, live) project and port it to Cake for kicks. Get the grand tour of all the basics. In my existing project I have a number of utility classes that are used by the other classes. 2 of them are an Item class and a Banking class. Item obviously contains all the information about a user's inventory, plus handles updating/deducting items, as well as using items. Banking does just that- tracks a user's currency and handles transactions. Banking is used between the Shop systems, Item is used by Shop and various action classes. So I need a way to share their functionality between all the various other controllers that require them. Simple example would be the user wants to buy an item from the shop, have to verify the item is in stock, the item's price, that the player has the currency to pay for it, deliver the item, deduct the payment and deduct the item from shop inventory. While a different Controller (say, Toll Bridge) needs the Banking functions to verify the user has the funds to pay the toll, then debit the transaction. It SOUNDS like what I need to do is to create Banking & Item Components, then the other controllers can make use of them as needed. However, this would also require including various queries to chat with the database. The CakePHP example on Components only shows a simple math operation with passed params, and says nothing about if using Components as little "bundles" of functionality that involve their own validations and database interactions (although this is strongly implied) There is some conversation on the 'net that what actually needs to happen is Banking and Item should be controllers, and they get imported as needed. What's the best way to go about this? -- 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/groups/opt_out.
Re: Best Practise: Use Utilmethods in Controllers, Views, Components...
Hi Lowbass, good idea! I will go this way. Also this solution seems to be very "maintain-friendly" ;) Thanks for your answer. Best regards, Kai. Am 17.03.2013 18:15, schrieb lowpass: > I used to put this sort of thing in bootstrap.php but lately I've been > putting a file in the app/Lib directory and including it at the end of > bootstrap. > > On Fri, Mar 15, 2013 at 11:44 AM, kaiszy wrote: >> Hi! >> >> I have several Utility Routines that i wan't to use in all Objects (Models, >> Controllers, Views,...). >> >> For example i have a small Method called "getDataFromArray" that fetch a >> element from an Array or throws a CakeException if the key doesnt exists. >> Because of DRY i wan't to use it in *. >> >> What is best practice to do so ? >> >> Thanks! >> >> Best regards, >> Kai. >> >> -- >> 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?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > -- Kai Szymanski Theodor-Heuss-Allee 21 28215 Bremen EMail k...@codebiz.de / Web http://www.codebiz.de Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail und der darin enthaltenen Informationen sind nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Best Practise: Use Utilmethods in Controllers, Views, Components...
I've been doing the same as cricket, an additional perk is it's easier to maintain, cleaner and easier to unit test. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Best Practise: Use Utilmethods in Controllers, Views, Components...
I used to put this sort of thing in bootstrap.php but lately I've been putting a file in the app/Lib directory and including it at the end of bootstrap. On Fri, Mar 15, 2013 at 11:44 AM, kaiszy wrote: > Hi! > > I have several Utility Routines that i wan't to use in all Objects (Models, > Controllers, Views,...). > > For example i have a small Method called "getDataFromArray" that fetch a > element from an Array or throws a CakeException if the key doesnt exists. > Because of DRY i wan't to use it in *. > > What is best practice to do so ? > > Thanks! > > Best regards, > Kai. > > -- > 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?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Best Practise: Use Utilmethods in Controllers, Views, Components...
Hi! I have several Utility Routines that i wan't to use in all Objects (Models, Controllers, Views,...). For example i have a small Method called "getDataFromArray" that fetch a element from an Array or throws a CakeException if the key doesnt exists. Because of DRY i wan't to use it in *. What is best practice to do so ? Thanks! Best regards, Kai. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Problem with using components when Importing a Controller
yeah, better to hack the component into the model layer. in your model methods probably sth like: App::import('Core', 'Controller'); App::import('Component', 'Email'); $this->Email = new EmailComponent(null); $this->Email->initialize(new Controller()); ... and with 2.x you can than refactor it into sth clean :) Am Donnerstag, 21. Februar 2013 15:39:54 UTC+1 schrieb david...@gmail.com: > > > > On Thursday, February 21, 2013 2:20:00 PM UTC+2, euromark wrote: >> >> Even with Cake1.3 you dont import and abuse controllers this way. >> You need to refactor those controller methods into clean model methods >> and only re-use those. >> > > Since we are talking about sending e-mails which uses the Email component > the only options are to abuse controllers or models (as models are not > supposed to use components). I can try moving the code into the model and > using App::Import to get the Email component and see if it is set up > correctly that way. I have a work around as I showed in the code I > included originally so I don't have a lot of incentive to reorganize the > code now. > > The primary question is, if you have a facility like App::Import shouldn't > the result be fully functional? > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Problem with using components when Importing a Controller
On Thursday, February 21, 2013 2:20:00 PM UTC+2, euromark wrote: > > Even with Cake1.3 you dont import and abuse controllers this way. > You need to refactor those controller methods into clean model methods and > only re-use those. > Since we are talking about sending e-mails which uses the Email component the only options are to abuse controllers or models (as models are not supposed to use components). I can try moving the code into the model and using App::Import to get the Email component and see if it is set up correctly that way. I have a work around as I showed in the code I included originally so I don't have a lot of incentive to reorganize the code now. The primary question is, if you have a facility like App::Import shouldn't the result be fully functional? -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Problem with using components when Importing a Controller
Even with Cake1.3 you dont import and abuse controllers this way. You need to refactor those controller methods into clean model methods and only re-use those. Am Donnerstag, 21. Februar 2013 11:52:09 UTC+1 schrieb david...@gmail.com: > > I have a controller EmailNotifications which I am accessing using > App::Import('Controller', 'EmailNotifications'); > > The EmailNotifications controller uses the Email component > var $components = array('Email', 'RequestHandler'); > > When I import the controller I use the following code: > // Load the Email Notification controller > App::Import('Controller', 'EmailNotifications'); > $EmailNotification = new EmailNotificationsController(); > $EmailNotification->constructClasses(); > > Inside of the notify method of the EmailNotificationsController I use the > Email component > $this->Email->reset(); > $this->Email->to = $Notify['EmailNotification']['email_address']; > $this->Email->subject = ucwords("$Subject ($Activity)"); > $this->Email->replyTo = > $Notify['EmailNotification']['email_address']; > $this->Email->from = $Notify['EmailNotification']['email_address']; > $this->Email->template = $Template; > $this->Email->sendAs = 'text'; > // Since this is being used via App::Import the Controller is not > properly set > // so we set it here > $this->Email->Controller = $this; > $Ret = $this->Email->send(); > > If I do not manually set $this->Email->Controller = $this before calling > send the variables I have set earlier in the code are not exported to the > email view. > > From reading the manual I understood that calling constructClasses would > initialize any models and components used by the controller. However, the > components do not seem to be initialized correctly. > > Is there something else I am supposed to do in order for this to work > correctly? Is this a bug? I am using CakePHP 1.3.10 > > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Problem with using components when Importing a Controller
I have a controller EmailNotifications which I am accessing using App::Import('Controller', 'EmailNotifications'); The EmailNotifications controller uses the Email component var $components = array('Email', 'RequestHandler'); When I import the controller I use the following code: // Load the Email Notification controller App::Import('Controller', 'EmailNotifications'); $EmailNotification = new EmailNotificationsController(); $EmailNotification->constructClasses(); Inside of the notify method of the EmailNotificationsController I use the Email component $this->Email->reset(); $this->Email->to = $Notify['EmailNotification']['email_address']; $this->Email->subject = ucwords("$Subject ($Activity)"); $this->Email->replyTo = $Notify['EmailNotification']['email_address']; $this->Email->from = $Notify['EmailNotification']['email_address']; $this->Email->template = $Template; $this->Email->sendAs = 'text'; // Since this is being used via App::Import the Controller is not properly set // so we set it here $this->Email->Controller = $this; $Ret = $this->Email->send(); If I do not manually set $this->Email->Controller = $this before calling send the variables I have set earlier in the code are not exported to the email view. >From reading the manual I understood that calling constructClasses would initialize any models and components used by the controller. However, the components do not seem to be initialized correctly. Is there something else I am supposed to do in order for this to work correctly? Is this a bug? I am using CakePHP 1.3.10 -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Use Configure::read in $components
Then you should go with crickets approach and pass those values in afterwards (either via attributes or setters) Am Mittwoch, 20. Februar 2013 12:17:05 UTC+1 schrieb Julien Itard: > > Because all my Configure::write('Settings.*) are in my beforeFilter .. I > load a modal to get the settings that's why this is not in bootstrap > > Le mercredi 20 février 2013 12:12:16 UTC+1, Julien Itard a écrit : >> >> Hello, >> it seems that i can't use Configure::read() here, it return an empty >> string.. >> >> My code : >> >> public function constructClasses() { >> $this->components['TeamSpeak3.TeamSpeak3'] = array( >> 'uri' => >> 'serverquery://'.Configure::read("Settings.teamspeak_query_user").':'.Configure::read('Settings.teamspeak_query_password').'@'.Configure::read('Settings.teamspeak_ip').':10011/?server_port='.Configure::read('Settings.teamspeak_port').'&no_query_clients=1'); >> >> parent::constructClasses(); >> } >> >> This code return : >> serverquery://:@:10011/?server_port=&no_query_clients=1 >> >> Le mercredi 20 février 2013 11:16:22 UTC+1, euromark a écrit : >>> >>> unless he needs the uri in initialized() than this would be too late. >>> then one might have to overwrite constructClasses(): >>> >>> public function constructClasses() { >>> $this->components['TeamSpeak3.TeamSpeak3'] = array( >>> 'uri' => Configure::read('Settings.ts_uri)); >>> >>> parent::constructClasses(); >>> } >>> >>> Just don't put it in $components then. >>> >>> Am Mittwoch, 20. Februar 2013 01:10:21 UTC+1 schrieb cricket: >>>> >>>> On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard >>>> wrote: >>>> > Hi there, >>>> > here is my AppController : >>>> > >>>> > public $components = array( >>>> > 'TeamSpeak3.TeamSpeak3' => array( >>>> > 'uri' => Configure::read('Settings.ts_uri) >>>> > ) >>>> > ); >>>> > >>>> > I need to use a configure here but it doesn't work ... any idea ? >>>> > >>>> > Thx from France :) >>>> >>>> Salut, >>>> >>>> You can't do that when declaring a class variable because it depends >>>> on runtime info. >>>> >>>> public $components = array( >>>> 'TeamSpeak3.TeamSpeak3' >>>> ); >>>> >>>> function beforeFilter() { >>>> $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri); >>>> } >>>> >>> -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Use Configure::read in $components
Because all my Configure::write('Settings.*) are in my beforeFilter .. I load a modal to get the settings that's why this is not in bootstrap Le mercredi 20 février 2013 12:12:16 UTC+1, Julien Itard a écrit : > > Hello, > it seems that i can't use Configure::read() here, it return an empty > string.. > > My code : > > public function constructClasses() { > $this->components['TeamSpeak3.TeamSpeak3'] = array( > 'uri' => > 'serverquery://'.Configure::read("Settings.teamspeak_query_user").':'.Configure::read('Settings.teamspeak_query_password').'@'.Configure::read('Settings.teamspeak_ip').':10011/?server_port='.Configure::read('Settings.teamspeak_port').'&no_query_clients=1'); > > parent::constructClasses(); > } > > This code return : serverquery://:@:10011/?server_port=&no_query_clients=1 > > Le mercredi 20 février 2013 11:16:22 UTC+1, euromark a écrit : >> >> unless he needs the uri in initialized() than this would be too late. >> then one might have to overwrite constructClasses(): >> >> public function constructClasses() { >> $this->components['TeamSpeak3.TeamSpeak3'] = array( >> 'uri' => Configure::read('Settings.ts_uri)); >> >> parent::constructClasses(); >> } >> >> Just don't put it in $components then. >> >> Am Mittwoch, 20. Februar 2013 01:10:21 UTC+1 schrieb cricket: >>> >>> On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard >>> wrote: >>> > Hi there, >>> > here is my AppController : >>> > >>> > public $components = array( >>> > 'TeamSpeak3.TeamSpeak3' => array( >>> > 'uri' => Configure::read('Settings.ts_uri) >>> > ) >>> > ); >>> > >>> > I need to use a configure here but it doesn't work ... any idea ? >>> > >>> > Thx from France :) >>> >>> Salut, >>> >>> You can't do that when declaring a class variable because it depends >>> on runtime info. >>> >>> public $components = array( >>> 'TeamSpeak3.TeamSpeak3' >>> ); >>> >>> function beforeFilter() { >>> $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri); >>> } >>> >> -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Use Configure::read in $components
Hello, it seems that i can't use Configure::read() here, it return an empty string.. My code : public function constructClasses() { $this->components['TeamSpeak3.TeamSpeak3'] = array( 'uri' => 'serverquery://'.Configure::read("Settings.teamspeak_query_user").':'.Configure::read('Settings.teamspeak_query_password').'@'.Configure::read('Settings.teamspeak_ip').':10011/?server_port='.Configure::read('Settings.teamspeak_port').'&no_query_clients=1'); parent::constructClasses(); } This code return : serverquery://:@:10011/?server_port=&no_query_clients=1 Le mercredi 20 février 2013 11:16:22 UTC+1, euromark a écrit : > > unless he needs the uri in initialized() than this would be too late. > then one might have to overwrite constructClasses(): > > public function constructClasses() { > $this->components['TeamSpeak3.TeamSpeak3'] = array( > 'uri' => Configure::read('Settings.ts_uri)); > > parent::constructClasses(); > } > > Just don't put it in $components then. > > Am Mittwoch, 20. Februar 2013 01:10:21 UTC+1 schrieb cricket: >> >> On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard >> wrote: >> > Hi there, >> > here is my AppController : >> > >> > public $components = array( >> > 'TeamSpeak3.TeamSpeak3' => array( >> > 'uri' => Configure::read('Settings.ts_uri) >> > ) >> > ); >> > >> > I need to use a configure here but it doesn't work ... any idea ? >> > >> > Thx from France :) >> >> Salut, >> >> You can't do that when declaring a class variable because it depends >> on runtime info. >> >> public $components = array( >> 'TeamSpeak3.TeamSpeak3' >> ); >> >> function beforeFilter() { >> $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri); >> } >> > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Use Configure::read in $components
unless he needs the uri in initialized() than this would be too late. then one might have to overwrite constructClasses(): public function constructClasses() { $this->components['TeamSpeak3.TeamSpeak3'] = array( 'uri' => Configure::read('Settings.ts_uri)); parent::constructClasses(); } Just don't put it in $components then. Am Mittwoch, 20. Februar 2013 01:10:21 UTC+1 schrieb cricket: > > On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard > > > wrote: > > Hi there, > > here is my AppController : > > > > public $components = array( > > 'TeamSpeak3.TeamSpeak3' => array( > > 'uri' => Configure::read('Settings.ts_uri) > > ) > > ); > > > > I need to use a configure here but it doesn't work ... any idea ? > > > > Thx from France :) > > Salut, > > You can't do that when declaring a class variable because it depends > on runtime info. > > public $components = array( > 'TeamSpeak3.TeamSpeak3' > ); > > function beforeFilter() { > $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri); > } > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Use Configure::read in $components
On Tue, Feb 19, 2013 at 4:00 PM, Julien Itard wrote: > Hi there, > here is my AppController : > > public $components = array( > 'TeamSpeak3.TeamSpeak3' => array( > 'uri' => Configure::read('Settings.ts_uri) > ) > ); > > I need to use a configure here but it doesn't work ... any idea ? > > Thx from France :) Salut, You can't do that when declaring a class variable because it depends on runtime info. public $components = array( 'TeamSpeak3.TeamSpeak3' ); function beforeFilter() { $this->TeamSpeak3->uri = Configure::read(Settings.ts_uri); } -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Use Configure::read in $components
Hi there, here is my AppController : public $components = array( 'TeamSpeak3.TeamSpeak3' => array( 'uri' => Configure::read('Settings.ts_uri) ) ); I need to use a configure here but it doesn't work ... any idea ? Thx from France :) -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Git submodule for behaviors/components/helpers
Makes perfect sense when someone else says it... :D :D I was just unsure if Plugin/behaviors work without PluginAppModel or sth else to work properly... Thanks Tiago, I'm a happy little baker now... -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Git submodule for behaviors/components/helpers
You should use it as a plugin... that's the right way since it IS a CakePHP plugin. There's no need to you get the behavior and inject it in your app (like in app/Model/Behaviors). Just: /project/$ git submodule add url-to-repo app/Plugin/StateMachine and then init the behavior as $actsAs => "StateMachine.StateMachine" That's correct! :) -- ***Thiago Belem* Desenvolvedor Rio de Janeiro - RJ - Brasil *Assando Sites* - Curso online de *CakePHP* assando-sites.com.br <http://goo.gl/b1EEd> thiagobelem.net cont...@thiagobelem.net *Skype / gTalk **»* thiago.belem.web *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt On Fri, Feb 8, 2013 at 6:49 PM, Vanja Dizdarević wrote: > I wish to add a behavior (for example Finite state > machine<https://github.com/burriko/cakephp-state-machine-behavior>) > to a project. > > I would like to use Git submodule functionality, but it seems impossible > due to repo folder structure. > > If I do (example): > /project/$ git clone url-to-repo app/Model/Behavior/StateMachine > > I would end up with > /project/app/Model/Behavior/StateMachine/Model/Behavior/StateMachineBehavior.php > > Checking out the repo as a plugin might work? > >/project/$ git submodule add url-to-repo app/Plugin/StateMachine > >and then init the behavior as $actsAs => "StateMachine.StateMachine" > > But I'm not sure if this is good practice... > > > How would you guys do this? > > (The same goes for Components and Helpers) > > P.S.: I know that it's easier to just download the file and put it in > app/Behaviors, but I am making a deployment version for many different > projects and it's crucial to be able to checkout updates later via git. > > -- > 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?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Git submodule for behaviors/components/helpers
I wish to add a behavior (for example Finite state machine<https://github.com/burriko/cakephp-state-machine-behavior>) to a project. I would like to use Git submodule functionality, but it seems impossible due to repo folder structure. If I do (example): /project/$ git clone url-to-repo app/Model/Behavior/StateMachine I would end up with /project/app/Model/Behavior/StateMachine/Model/Behavior/StateMachineBehavior.php Checking out the repo as a plugin might work? /project/$ git submodule add url-to-repo app/Plugin/StateMachine and then init the behavior as $actsAs => "StateMachine.StateMachine" But I'm not sure if this is good practice... How would you guys do this? (The same goes for Components and Helpers) P.S.: I know that it's easier to just download the file and put it in app/Behaviors, but I am making a deployment version for many different projects and it's crucial to be able to checkout updates later via git. -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Components vs Helpers vs Utilities
On Fri, Jan 25, 2013 at 4:53 PM, tron wrote: > Im trying to wrap my head around utilzing some functionality at all levels > of MVC. Right now, I'm writing a component that performs several date > functions for my app (the date utility is insufficient for what Im doing). > The problem is I need the these functions in both my models and views as > well. I'd imagine writing my own Utility is the best option as it can be > used anywhere but they seem "off limits" as they are only contained within > the Lib. I also cant find any information on writing a Utility. Yes, I could > just go write one and add it to Lib/Utilities but I'm looking for some > feedback on this issue as I've faced it several times. If you need to share > functionality between all layers of the MVC, is using utilities the only way > to do it without having to load a component/helper/behavior on the fly? If CakeTime doesn't have what you want you could extend it. app/Lib/Utility/MyTime.php : App::uses('CakeTime', 'Utility'); class MyTime extends CakeTime { public function foo($bar = null) { } } In your controller/Model/View : App::uses('MyTime', 'Utility'); ... $foo = MyTime::foo($bar); But if all you want/need is a plain function (ie. no class) you could just put in bootstrap.php -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: Components vs Helpers vs Utilities
I am having difficulty thinking of a time when I would need the same function to be called in my model and my view. On my current project, I am also needing to manipulate my dates as I have a non standard way of saving them in the database. What I have done is manipulated them in the controller using a Component so these functions can used in different controllers. I get the data from the model, use the functions in my component to manipulate the data and then pass that to the view, which displays it as is. Is that similar to what you are trying or am I misunderstanding your goals? ~Michael -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Components vs Helpers vs Utilities
Im trying to wrap my head around utilzing some functionality at all levels of MVC. Right now, I'm writing a component that performs several date functions for my app (the date utility is insufficient for what Im doing). The problem is I need the these functions in both my models and views as well. I'd imagine writing my own Utility is the best option as it can be used anywhere but they seem "off limits" as they are only contained within the Lib. I also cant find any information on writing a Utility. Yes, I could just go write one and add it to Lib/Utilities but I'm looking for some feedback on this issue as I've faced it several times. If you need to share functionality between all layers of the MVC, is using utilities the only way to do it without having to load a component/helper/behavior on the fly? 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Problem with reusing components
Hello For a couple of hours I am having a hard time to use one component in another. I used the steps from the cookbook but when i call the method of a component i get an error - calling a member of a non object. I'm really frustrated and really dont know what to do. Both components are normally loaded via the page controller but not one from the other. If someone could handle it i would be super greatful. file: app/Controler/Component/UrlUploadComponent.php FileUpload->Upload($data); //ERROR HERE break; default: $this->embedStorage->Store($data); break; } } } } ?> -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
Ok, now works. Thanks -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
You should make the component extend 'Component' class. 2012/1/3 Salines : > http://bin.cakephp.org/view/1662957875 > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
http://bin.cakephp.org/view/1662957875 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
No, I did not forget to add I modify Neil Crookes twitter component to use in CakePHP 2.0.x -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
did you forget to add var $components = array('Session') to this component? that's probably it On 3 Jan., 02:04, Salines wrote: > Undefined property: TwitterAuthComponent::$Session > [*APP/Plugin/Twitter/Controller/Component/TwitterAuthComponent.php*, line > *133*] > > Fatal error: Call to a member function check() on a non-object in > /home/nix/localhost.dev/cms/Plugin/Twitter/Controller/Component/TwitterAuth > Component.php > on line 133 > > public function accessTokenSession() {//line 133 *return > $this->Session->check('Twitter.Auth.oauth_token') && > $this->Session->check('Twitter.Auth.oauth_token_secret');* > > > > > > > > } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: cakephp 2.0.4: How to use Session Component in Plugin Components?
Undefined property: TwitterAuthComponent::$Session [*APP/Plugin/Twitter/Controller/Component/TwitterAuthComponent.php*, line *133*] Fatal error: Call to a member function check() on a non-object in /home/nix/localhost.dev/cms/Plugin/Twitter/Controller/Component/TwitterAuthComponent.php on line 133 public function accessTokenSession() {//line 133 *return $this->Session->check('Twitter.Auth.oauth_token') && $this->Session->check('Twitter.Auth.oauth_token_secret');* } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
cakephp 2.0.4: How to use Session Component in Plugin Components?
Hello, i have trouble to use Session component inside my plugin components. How to load session component? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: using components inside custom authorize object (CakePHP 2)
or $this->controller()->Components->Session->read() -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Question about why components etc are added the way they are
On Oct 26, 6:21 am, Greg Skerman wrote: > I've been asked a question to which I don't immediately have a (good) > answer... > > why is it in cake that this: > > public $components = array('AuthComponent'); > > is preferred over > > public $Auth; > > public function __construct() { > $this->Auth = new AuthComponent(); > > } > > I actually really like the way its done in Cake, but have been told its > "less readable" (a point I disagree with) > > wondering if there is any major technical reason for favoring one over the > other. Curiosity more than anything...Is it purely to reduce lines of code? > or to make code generation easier? or to facilitate testing?... in 2.0 Lazy loading. The classes you declare are not instanciated until you use them. In 1.3 and before it has various benefits, one of which is: if you used your __construct code your app would flat out break because you're overriding a method, giving it a different signature, and not calling parent etc. AD -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Question about why components etc are added the way they are
My 2p, as a newbie to Cake: As a failrly old hand at PHP but someone who has avoided OOP (and MVC) up 'til recently, seeing: public $components = array('AuthComponent'); makes prefect sense to me, whereas using the constructpr functions seems... odd, complex and unnecessary. I guess all that is probably completely contrary for someone who has been using OOP techniques for a very long time. It's certainly less code and to me at leasty is a quicker and more easily accessible to my eye. P. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: using components inside custom authorize object (CakePHP 2)
I actually came to this: $this->_Collection->Session->read(''); as I'm sure that Session is always loaded because I have it in my AppController, but I wasn't sure if accessing _Collection directly is the right way to do or not. thanks anyway :) -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: using components inside custom authorize object (CakePHP 2)
I used: CakeSession::write('Auth.Plugins', $user_plugins); Should I be using: $session = $this->_Collection->load('Session'); $session->write('Auth.Plugins', $user_plugins); ? TIA d//t On Oct 25, 10:23 pm, José Lorenzo wrote: > In any method of your custom object you ca do something like this, it will > load the component or return the already instantiated one. > > $session = $this->_Collection->load('Session'); -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Question about why components etc are added the way they are
I've been asked a question to which I don't immediately have a (good) answer... why is it in cake that this: public $components = array('AuthComponent'); is preferred over public $Auth; public function __construct() { $this->Auth = new AuthComponent(); } I actually really like the way its done in Cake, but have been told its "less readable" (a point I disagree with) wondering if there is any major technical reason for favoring one over the other. Curiosity more than anything...Is it purely to reduce lines of code? or to make code generation easier? or to facilitate testing?... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: using components inside custom authorize object (CakePHP 2)
In any method of your custom object you ca do something like this, it will load the component or return the already instantiated one. $session = $this->_Collection->load('Session'); -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
using components inside custom authorize object (CakePHP 2)
Hi again, I was working on a custom authorize object in conjunction with new Auth component, that I ran into the need to use Session component there, I tried to use $components array but it didn't worked. I suppose there should be a way to do that, can anybody help me? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
migrating components to 2.0
the migration guide states the new params of components class PrgComponent extends Component { function __construct(ComponentCollection $collection, $settings = array()) { parent::__construct($collection, $settings); } } but if you have old components you used in shells, etc you got (just an example) in this shell: $prg = new PrgComponent($controllerOrWhatever); how could one update this to 2.0? maybe $prg = new PrgComponent(new ComponentCollection); ? in the long run this ought to be a Lib of course. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: call components from shell.
Never mind i decided to do php way in shell if (! $conn = mysql_connect( 'localhost', $db_name, $db_pwd ) ) { echo 'Could not connect to mysql'; continue; }else{ $this -> connection = $conn; } if( mysql_select_db( $db_name, $conn ) ){ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: call components from shell.
Also Can't even save the model in cake. $rpg[ 'ReviewPanelGroup' ][ 'account_id' ] = $account_id; $rpg[ 'ReviewPanelGroup' ][ 'department_id' ] = $department_id; $rpg[ 'ReviewPanelGroup' ][ 'survey_id' ] = $review_id; $this -> ReviewPanelGroup -> save( $rpg ); Is there anyway to split out the SQL just for a particular line? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
call components from shell.
Within my Employee Manager Component, I have the folowing function . function get_manager( $department ){ $this -> controller -> loadModel( "Account" ); $this -> controller -> Account -> useDbConfig = $this -> controller -> db_name; $sql = "SELECT * FROM accounts Account LEFT JOIN account_roles AccountRole ON Account.id = AccountRole.accounts_id LEFT JOIN employees Employee on Account.id = Employee.accounts_id WHERE AccountRole.departments_id = " . $department . " AND AccountRole.roles_id in ( 7, 6, 4 )"; return $this -> controller -> Account -> Query( $sql ); } how can I call this from the shell script? I am getting the following error and can't get it work. Fatal error: ConnectionManager::getDataSource - Non-existent data source in /cake/libs/model/connection_manager.php on line 109 [~]# ConnectionManager::getDataSource - Non-existent data source In the shell I call the component like this $this -> controller = new AppController(); $this -> controller -> components = $this-> components; $this -> empManager = new EmployeeManagerComponent(null); $this -> empManager -> startup( $this -> controller ); $manager_obj = $this -> empManager -> get_manager( $department_id ); -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Load components in components
Thanks a lot. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Load components in components
I asked in cakephp IRC, A person answer is not: > [11:05] it will not be slow, I believe it passes those around via reference > >[11:05] so you have nothing to worry about -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Load components in components
if i use and create much components and that components use other components .It will make app is very slow? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Load components in components
in app_controller.php load Session, Auth components. And in posts_controller.php, i use CustomComponent with $components = array('Session','Auth'); Then do CustomComponent must reload Session, Auth? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Why cake not build a good procedure for load components behaviour , help ?
I known it's possible.. but, do you think that your plugin is dependent with AppController ? and you must know the AppController if you would make a PLuginAppController ? If CMS projects plugin develop by others and core by authors... So if PluginOneAppController joined with AppController.. developer plugin never know my AppController? it's will be "loss couple" if cake create a function for Hook components, helper.. and each plugin never have dependent with core app.. :-) thanks in advance.. Jan On Aug 10, 10:08 pm, euromark wrote: > as far as I know, this is already done this way. > they will be "joined" between AppController PluginAppController > Controller in this order > or did you experience it otherwise? > it would surprise me because it works this way since several years in > my apps. > > On 10 Aug., 15:01, vcrack wrote: > > > Hello all, my name Jan.. I'm Indonesian.. > > I've used cake in my projects.. I've following cake since in cake > > 1.1.8 till now. > > > currently, I'm develop project which a lot of feature and I think in > > plugin.. cause, plugin is more independent, I guess. > > But, I have a question.. > > > Why cake doesn't make a function to hook Components, Helpers, > > Behaviour? > > Why only create a attribute var $components, var $helpers , var > > $actsAs ? > > it's likely will override with child class.. > > > for example, in my project. I have a AutoLogin Component.. I wanna use > > this components to all controllers. > > So, in AppController I have var $components = > > array('AutoLogin','Another', .....); > > > afterwards, my patner make calendar plugin in my project, and in > > calendar plugin, he make CalendarFilter Components. and it's will use > > in all controllers calendar plugin. so he make var $components = > > array('CalendarFilter','Another'); > > > Well, it's will be override my AutoLogin Component. > > Okey, why he don't copy var $components from my AppController? > > oh, it's okey.. but do you think if my project is a CMS project? > > and users isn't a programmers ? > > and users install more than one plugin? > > > so, Why cake doesn't make a function to Hook components, helpers, and > > behaviors? > > > Please excuse my poor English.. thanks in advance.. > > > Jan > > >http://jan.web.idhttp://idcakephp.org -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: small bug in auth components
Try $this->Auth->fields['username'] = 'email'; On 10 aug, 00:58, muslimbit wrote: > There is an error in the auth components when i init the username auth > field only in beforfilter function : > > $this->Auth->fields = array( > 'username' => 'email' > ); > > i get a notice : > > Notice (8): Undefined index: password [CORE\cake\libs\controller > \components\auth.php, line 382] -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Why cake not build a good procedure for load components behaviour , help ?
as far as I know, this is already done this way. they will be "joined" between AppController PluginAppController Controller in this order or did you experience it otherwise? it would surprise me because it works this way since several years in my apps. On 10 Aug., 15:01, vcrack wrote: > Hello all, my name Jan.. I'm Indonesian.. > I've used cake in my projects.. I've following cake since in cake > 1.1.8 till now. > > currently, I'm develop project which a lot of feature and I think in > plugin.. cause, plugin is more independent, I guess. > But, I have a question.. > > Why cake doesn't make a function to hook Components, Helpers, > Behaviour? > Why only create a attribute var $components, var $helpers , var > $actsAs ? > it's likely will override with child class.. > > for example, in my project. I have a AutoLogin Component.. I wanna use > this components to all controllers. > So, in AppController I have var $components = > array('AutoLogin','Another', .); > > afterwards, my patner make calendar plugin in my project, and in > calendar plugin, he make CalendarFilter Components. and it's will use > in all controllers calendar plugin. so he make var $components = > array('CalendarFilter','Another'); > > Well, it's will be override my AutoLogin Component. > Okey, why he don't copy var $components from my AppController? > oh, it's okey.. but do you think if my project is a CMS project? > and users isn't a programmers ? > and users install more than one plugin? > > so, Why cake doesn't make a function to Hook components, helpers, and > behaviors? > > Please excuse my poor English.. thanks in advance.. > > Jan > > http://jan.web.idhttp://idcakephp.org -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Why cake not build a good procedure for load components behaviour , help ?
Hello all, my name Jan.. I'm Indonesian.. I've used cake in my projects.. I've following cake since in cake 1.1.8 till now. currently, I'm develop project which a lot of feature and I think in plugin.. cause, plugin is more independent, I guess. But, I have a question.. Why cake doesn't make a function to hook Components, Helpers, Behaviour? Why only create a attribute var $components, var $helpers , var $actsAs ? it's likely will override with child class.. for example, in my project. I have a AutoLogin Component.. I wanna use this components to all controllers. So, in AppController I have var $components = array('AutoLogin','Another', .); afterwards, my patner make calendar plugin in my project, and in calendar plugin, he make CalendarFilter Components. and it's will use in all controllers calendar plugin. so he make var $components = array('CalendarFilter','Another'); Well, it's will be override my AutoLogin Component. Okey, why he don't copy var $components from my AppController? oh, it's okey.. but do you think if my project is a CMS project? and users isn't a programmers ? and users install more than one plugin? so, Why cake doesn't make a function to Hook components, helpers, and behaviors? Please excuse my poor English.. thanks in advance.. Jan http://jan.web.id http://idcakephp.org -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: small bug in auth components
I understand that you get an error in your case - my question is, do you want to authenticate a user only by the user entering his/her e- mail address? For that is what you are trying to do! Auth is supposed to have to field names in the fields variable, but you are only giving it one! See the CakePHP book for a short description of the fields variable at: http://book.cakephp.org/#!/view/1267/fields Please clarify what you are trying to do :) Enjoy, John On 10 Aug., 00:58, muslimbit wrote: > There is an error in the auth components when i init the username auth > field only in beforfilter function : > > $this->Auth->fields = array( > 'username' => 'email' > ); > > i get a notice : > > Notice (8): Undefined index: password [CORE\cake\libs\controller > \components\auth.php, line 382] -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
small bug in auth components
There is an error in the auth components when i init the username auth field only in beforfilter function : $this->Auth->fields = array( 'username' => 'email' ); i get a notice : Notice (8): Undefined index: password [CORE\cake\libs\controller \components\auth.php, line 382] -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: List of PlugIns, Behaviours, Components and Helpers
http://cakepackages.com/ By Jose diaz gonzalezgonzalez the code is available on github too - S On 30 Jun 2011 12:42, "Jens Dittrich" wrote: > Does anyone know a List somewhere in the web of cakePHP PlugIns, Components, > Behaviours and Helpers besides the ones delivered in the CakePHP release? > Googleing the web and searching through GitHub repositories of some > developers is always an option, but a kind of central list with the > possibility to search for keywords would be great. I am thinking of > something like jQuerys PlugIn list. > > regards, > Jens > > -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. > > > 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: List of PlugIns, Behaviours, Components and Helpers
i only know of http://cakepackages.com/ which is buggy, partly outdated and not really actively maintained but might still be helpful On 30 Jun., 13:42, Jens Dittrich wrote: > Does anyone know a List somewhere in the web of cakePHP PlugIns, Components, > Behaviours and Helpers besides the ones delivered in the CakePHP release? > Googleing the web and searching through GitHub repositories of some > developers is always an option, but a kind of central list with the > possibility to search for keywords would be great. I am thinking of > something like jQuerys PlugIn list. > > regards, > Jens -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
List of PlugIns, Behaviours, Components and Helpers
Does anyone know a List somewhere in the web of cakePHP PlugIns, Components, Behaviours and Helpers besides the ones delivered in the CakePHP release? Googleing the web and searching through GitHub repositories of some developers is always an option, but a kind of central list with the possibility to search for keywords would be great. I am thinking of something like jQuerys PlugIn list. regards, Jens -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Why Can't Components See Methods from App_Controller?
On Thu, Apr 7, 2011 at 5:02 PM, David wrote: > I've got a component to do some common functions for a number of > controllers. When I'm in those controllers, I can use globally-common > functions from the app_controller. But when I'm in a component called > by a controller, those functions from the app_controller aren't > available. Isn't that sort of the point of the app_controller, and > since a component is under a controller, shouldn't it be able to > access? I don't quite understand why $this loses all its information > once you roll into a component. > > Why is this the case (interested in the theory behind this part of the > MVC), and is there a best practice way to access things from the > app_controller in a component? Components don't extend controllers. But the controller is passed to the component's initialize() and startup() methods. class FooComponent extends Object { private $__Controller; function startup(&$controller) { $this->__Controller = $controller; } } -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Why Can't Components See Methods from App_Controller?
I've got a component to do some common functions for a number of controllers. When I'm in those controllers, I can use globally-common functions from the app_controller. But when I'm in a component called by a controller, those functions from the app_controller aren't available. Isn't that sort of the point of the app_controller, and since a component is under a controller, shouldn't it be able to access? I don't quite understand why $this loses all its information once you roll into a component. Why is this the case (interested in the theory behind this part of the MVC), and is there a best practice way to access things from the app_controller in a component? Thanks. --David -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Bug when using ClassRegistry::init for Components
i usually use App::import('Component', 'Plugin.Something'); and manually create a new object On 23 Mrz., 00:35, labianchin wrote: > Hi, guys. > > I pretend to load and initialize a component (e.g. > SomethingComponent), so I use something like: > ClassRegistry::init('Plugin.Something', 'Component') > > The problem is that as in the line 140 of the file class-registry > (http://api.cakephp.org/view_source/class-registry/#line-99) we have > if (class_exists($class) || App::import($type, $pluginPath . > $class)) { > ${$class} =& new $class($settings); > > We'll I think this block of code is not considering the naming > convetions of CakePHP and it should be something like: > if (class_exists($class) || App::import($type, $pluginPath . > $class)) { > if (in_array($type, array('Behavior', 'Component', > 'Controller'))){ > $class .= $type; > } > ${$class} =& new $class($settings); > > Am I right or should I use it in a different way? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Bug when using ClassRegistry::init for Components
Hi, guys. I pretend to load and initialize a component (e.g. SomethingComponent), so I use something like: ClassRegistry::init('Plugin.Something', 'Component') The problem is that as in the line 140 of the file class-registry (http://api.cakephp.org/view_source/class-registry/#line-99) we have if (class_exists($class) || App::import($type, $pluginPath . $class)) { ${$class} =& new $class($settings); We'll I think this block of code is not considering the naming convetions of CakePHP and it should be something like: if (class_exists($class) || App::import($type, $pluginPath . $class)) { if (in_array($type, array('Behavior', 'Component', 'Controller'))){ $class .= $type; } ${$class} =& new $class($settings); Am I right or should I use it in a different way? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Loading components inside components and keeping the initialize() stack order
Because the SecondaryComponent::specialMethod() method is proper to the SecondaryComponent, I don't want to put code in MainComponent that should be be in SecondaryComponent. I would like to keep all code relating to SecondaryComponent inside SecondaryComponent. On 16 fév, 19:24, Miles J wrote: > Why don't you just place the specialMethod() code into initialize()? > Since thats basically what you are trying to achieve. > > On Feb 16, 2:51 am, Pixelastic wrote: > > > Hello, > > > I'm writing a MainComponent that will need a SecondaryComponent in > > order to correctly work. > > I want to call some of SecondaryComponent::specialMethod() in > > MainComponent::initialize(), but this method can only correctly work > > if SecondaryComponent::initialize() is itself called first. > > > Diving into code-land, here is what I mean. > > > class FoosController extends AppController { > > var $components = array('MainComponent); > > > } > > > class MainComponent extends Object { > > var $components = array('SecondaryComponent'); > > > function initialize(&$controller, $options) { > > $this->SecondaryComponent->specialMethod(); > > } > > > } > > > class SecondaryComponent extends Object { > > > function initialize(&$controller, $options) { > > // Some really important stuff must go here > > } > > > function specialMethod() { > > // This method can't work properly if the initialize() > > method hasn't > > be fired first > > } > > > } > > > I expected the stack order to call SecondaryComponent::initialize() > > then MainComponent::initialize() but it appears to call > > MainComponent::initialize() and then SecondaryComponent::initialize(), > > causing SecondaryComponent::specialMethod() to fail. > > > I "fixed" it by manually calling $this->SecondaryComponent->initialize() in > > MainComponent::initialize(), but I still wonder if > > > there would be a more cakish way of doing that. > > I'm not sure if this behavior is a bug, a design decision, an > > ommission or simply a wrong approach of myself. > > > Has anyone some insight of this ? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Loading components inside components and keeping the initialize() stack order
Why don't you just place the specialMethod() code into initialize()? Since thats basically what you are trying to achieve. On Feb 16, 2:51 am, Pixelastic wrote: > Hello, > > I'm writing a MainComponent that will need a SecondaryComponent in > order to correctly work. > I want to call some of SecondaryComponent::specialMethod() in > MainComponent::initialize(), but this method can only correctly work > if SecondaryComponent::initialize() is itself called first. > > Diving into code-land, here is what I mean. > > class FoosController extends AppController { > var $components = array('MainComponent); > > } > > class MainComponent extends Object { > var $components = array('SecondaryComponent'); > > function initialize(&$controller, $options) { > $this->SecondaryComponent->specialMethod(); > } > > } > > class SecondaryComponent extends Object { > > function initialize(&$controller, $options) { > // Some really important stuff must go here > } > > function specialMethod() { > // This method can't work properly if the initialize() method > hasn't > be fired first > } > > } > > I expected the stack order to call SecondaryComponent::initialize() > then MainComponent::initialize() but it appears to call > MainComponent::initialize() and then SecondaryComponent::initialize(), > causing SecondaryComponent::specialMethod() to fail. > > I "fixed" it by manually calling $this->SecondaryComponent->initialize() in > MainComponent::initialize(), but I still wonder if > > there would be a more cakish way of doing that. > I'm not sure if this behavior is a bug, a design decision, an > ommission or simply a wrong approach of myself. > > Has anyone some insight of this ? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Loading components inside components and keeping the initialize() stack order
Hello, I'm writing a MainComponent that will need a SecondaryComponent in order to correctly work. I want to call some of SecondaryComponent::specialMethod() in MainComponent::initialize(), but this method can only correctly work if SecondaryComponent::initialize() is itself called first. Diving into code-land, here is what I mean. class FoosController extends AppController { var $components = array('MainComponent); } class MainComponent extends Object { var $components = array('SecondaryComponent'); function initialize(&$controller, $options) { $this->SecondaryComponent->specialMethod(); } } class SecondaryComponent extends Object { function initialize(&$controller, $options) { // Some really important stuff must go here } function specialMethod() { // This method can't work properly if the initialize() method hasn't be fired first } } I expected the stack order to call SecondaryComponent::initialize() then MainComponent::initialize() but it appears to call MainComponent::initialize() and then SecondaryComponent::initialize(), causing SecondaryComponent::specialMethod() to fail. I "fixed" it by manually calling $this->SecondaryComponent- >initialize() in MainComponent::initialize(), but I still wonder if there would be a more cakish way of doing that. I'm not sure if this behavior is a bug, a design decision, an ommission or simply a wrong approach of myself. Has anyone some insight of this ? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Setting up initialization values to components, AuthComponent
Ok, i've found how to initialize parameters for the controller. It was not difficult, actually, it's in the book. I paste my code here: lass AppController extends Controller { var $components = array( 'Auth' => array( 'authorize' => 'controller' ) ); function beforeFilter(){ $this->Auth->allow('*'); } function isAuthorized(){ return false; } } The problem now is that i have to create a beforeFilter method in any controller, even it's blank. I mean, if there's no beforeFilter in my controller, Auth does not call to isAuthorized. So, my custom controllers should all implement beforeFilter. It's a litte frustrating. With this code, Auth doesn't check isAuthorized: class CarsController extends AppController { var $name = 'Cars'; function isAuthorized(){ debug(' Nobody will call me'); return false; } } Do you know why is it? On Jan 17, 6:39 pm, Santiago Basulto wrote: > Hello people! > > I'm facing a problem with Auth component. I've a minor level of > security in my site, that is checked in the isAuthorized() method of > my AppController. I've there a simple switch that checks some options. > > The thing is that i need to declare a beforeFilter() in every > controller and set inside that method the following statement > "$this->Auth->authorize = 'controller'" to get Auth to call > isAuthorized. > > I was wondering if there's some way of made that call "application > wide". I mean, anyway to initialize the Auth component, where to do > it, to make that (authorize = controller) the default. I tryied to do > that in the method beforeFilter() of my AppController class, but it's > not working. > > Altought i've found a way, that is to make this call on AppController > beforeFilter() method: > $this->Auth->isAuthorized('controller',$this); > > It works, but don't think it's a good way to do this. I've seen in the > AuthComponent that there are some interesting methods that should be > useful: initialize() and startup() > > Does anyone where to call them? > > Thanks everybody! > > -- > Santiago Basulto.- Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Setting up initialization values to components, AuthComponent
Hello people! I'm facing a problem with Auth component. I've a minor level of security in my site, that is checked in the isAuthorized() method of my AppController. I've there a simple switch that checks some options. The thing is that i need to declare a beforeFilter() in every controller and set inside that method the following statement "$this->Auth->authorize = 'controller'" to get Auth to call isAuthorized. I was wondering if there's some way of made that call "application wide". I mean, anyway to initialize the Auth component, where to do it, to make that (authorize = controller) the default. I tryied to do that in the method beforeFilter() of my AppController class, but it's not working. Altought i've found a way, that is to make this call on AppController beforeFilter() method: $this->Auth->isAuthorized('controller',$this); It works, but don't think it's a good way to do this. I've seen in the AuthComponent that there are some interesting methods that should be useful: initialize() and startup() Does anyone where to call them? Thanks everybody! -- Santiago Basulto.- Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
I'll take a look at that, thanks! :-) On Tue, Jan 4, 2011 at 7:24 PM, Miles J wrote: > @Joshua - Yes but if you put everything into a single plugin, then the > problem is solved. You are *not* including all those files in the app, > you are just making them available. They are included once you add > them to the $helpers, $components array, etc. A great example is the > CakeDC utils plugin: https://github.com/CakeDC/utils > > On Jan 4, 7:42 am, Joshua Muheim wrote: >> @Mark: this does seem very pragmatic. But what if you want to provide >> your stuff to others so that they can use different parts of your >> tools and don't want to include everything into your project? But >> certain parts are depending on each other, so you can't just provide a >> download to every single file? >> >> Maybe soft links are the solution? Can SVN/GIT manage something like that? >> >> On Tue, Jan 4, 2011 at 4:14 PM, euromark wrote: >> > yep, >> > i use a "tools" plugin containing all those files >> > one "svn:external" for all :) >> >> > On 4 Jan., 13:24, Joshua Muheim wrote: >> >> Short answer! I will look into it. Thanks. :-) >> >> >> On Tue, Jan 4, 2011 at 1:12 PM, AD7six wrote: >> >> >> > On Jan 4, 12:33 pm, psybear83 wrote: >> >> >> Hey everybody >> >> >> >> I wonder how to structure my shared components, behaviors, plugins >> >> >> etc. in my Subversion repository? I include them as externals in many >> >> >> different projects, and because I can't point to single files as >> >> >> externals (but only to directories) I can't simply use a structure >> >> >> like >> >> >> >> - components/ >> >> >> - behaviors/ >> >> >> - plugins/ >> >> >> >> etc. So at the moment my repository is cluttered up with folders and >> >> >> subfolders but misses a clean structure... Are there any "rules of >> >> >> thumb" or best practices on how to structure it? How do you guys do >> >> >> it? >> >> >> > use plugins. >> >> >> > AD >> >> >> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others >> >> > with their CakePHP related questions. >> >> >> > 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 athttp://groups.google.com/group/cake-php?hl=en >> >> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others >> > with their CakePHP related questions. >> >> > 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 >> > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
@Joshua - Yes but if you put everything into a single plugin, then the problem is solved. You are *not* including all those files in the app, you are just making them available. They are included once you add them to the $helpers, $components array, etc. A great example is the CakeDC utils plugin: https://github.com/CakeDC/utils On Jan 4, 7:42 am, Joshua Muheim wrote: > @Mark: this does seem very pragmatic. But what if you want to provide > your stuff to others so that they can use different parts of your > tools and don't want to include everything into your project? But > certain parts are depending on each other, so you can't just provide a > download to every single file? > > Maybe soft links are the solution? Can SVN/GIT manage something like that? > > On Tue, Jan 4, 2011 at 4:14 PM, euromark wrote: > > yep, > > i use a "tools" plugin containing all those files > > one "svn:external" for all :) > > > On 4 Jan., 13:24, Joshua Muheim wrote: > >> Short answer! I will look into it. Thanks. :-) > > >> On Tue, Jan 4, 2011 at 1:12 PM, AD7six wrote: > > >> > On Jan 4, 12:33 pm, psybear83 wrote: > >> >> Hey everybody > > >> >> I wonder how to structure my shared components, behaviors, plugins > >> >> etc. in my Subversion repository? I include them as externals in many > >> >> different projects, and because I can't point to single files as > >> >> externals (but only to directories) I can't simply use a structure > >> >> like > > >> >> - components/ > >> >> - behaviors/ > >> >> - plugins/ > > >> >> etc. So at the moment my repository is cluttered up with folders and > >> >> subfolders but misses a clean structure... Are there any "rules of > >> >> thumb" or best practices on how to structure it? How do you guys do > >> >> it? > > >> > use plugins. > > >> > AD > > >> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > >> > with their CakePHP related questions. > > >> > 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 > >> > athttp://groups.google.com/group/cake-php?hl=en > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > 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 > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
@Mark: this does seem very pragmatic. But what if you want to provide your stuff to others so that they can use different parts of your tools and don't want to include everything into your project? But certain parts are depending on each other, so you can't just provide a download to every single file? Maybe soft links are the solution? Can SVN/GIT manage something like that? On Tue, Jan 4, 2011 at 4:14 PM, euromark wrote: > yep, > i use a "tools" plugin containing all those files > one "svn:external" for all :) > > On 4 Jan., 13:24, Joshua Muheim wrote: >> Short answer! I will look into it. Thanks. :-) >> >> >> >> >> >> >> >> On Tue, Jan 4, 2011 at 1:12 PM, AD7six wrote: >> >> > On Jan 4, 12:33 pm, psybear83 wrote: >> >> Hey everybody >> >> >> I wonder how to structure my shared components, behaviors, plugins >> >> etc. in my Subversion repository? I include them as externals in many >> >> different projects, and because I can't point to single files as >> >> externals (but only to directories) I can't simply use a structure >> >> like >> >> >> - components/ >> >> - behaviors/ >> >> - plugins/ >> >> >> etc. So at the moment my repository is cluttered up with folders and >> >> subfolders but misses a clean structure... Are there any "rules of >> >> thumb" or best practices on how to structure it? How do you guys do >> >> it? >> >> > use plugins. >> >> > AD >> >> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others >> > with their CakePHP related questions. >> >> > 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 >> > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
yep, i use a "tools" plugin containing all those files one "svn:external" for all :) On 4 Jan., 13:24, Joshua Muheim wrote: > Short answer! I will look into it. Thanks. :-) > > > > > > > > On Tue, Jan 4, 2011 at 1:12 PM, AD7six wrote: > > > On Jan 4, 12:33 pm, psybear83 wrote: > >> Hey everybody > > >> I wonder how to structure my shared components, behaviors, plugins > >> etc. in my Subversion repository? I include them as externals in many > >> different projects, and because I can't point to single files as > >> externals (but only to directories) I can't simply use a structure > >> like > > >> - components/ > >> - behaviors/ > >> - plugins/ > > >> etc. So at the moment my repository is cluttered up with folders and > >> subfolders but misses a clean structure... Are there any "rules of > >> thumb" or best practices on how to structure it? How do you guys do > >> it? > > > use plugins. > > > AD > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > 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 > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
Short answer! I will look into it. Thanks. :-) On Tue, Jan 4, 2011 at 1:12 PM, AD7six wrote: > > > On Jan 4, 12:33 pm, psybear83 wrote: >> Hey everybody >> >> I wonder how to structure my shared components, behaviors, plugins >> etc. in my Subversion repository? I include them as externals in many >> different projects, and because I can't point to single files as >> externals (but only to directories) I can't simply use a structure >> like >> >> - components/ >> - behaviors/ >> - plugins/ >> >> etc. So at the moment my repository is cluttered up with folders and >> subfolders but misses a clean structure... Are there any "rules of >> thumb" or best practices on how to structure it? How do you guys do >> it? > > use plugins. > > AD > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
On Jan 4, 12:33 pm, psybear83 wrote: > Hey everybody > > I wonder how to structure my shared components, behaviors, plugins > etc. in my Subversion repository? I include them as externals in many > different projects, and because I can't point to single files as > externals (but only to directories) I can't simply use a structure > like > > - components/ > - behaviors/ > - plugins/ > > etc. So at the moment my repository is cluttered up with folders and > subfolders but misses a clean structure... Are there any "rules of > thumb" or best practices on how to structure it? How do you guys do > it? use plugins. AD Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
How do you guys structure your shared components/behaviors/plugins repository (Subversion)? --psybear
Hey everybody I wonder how to structure my shared components, behaviors, plugins etc. in my Subversion repository? I include them as externals in many different projects, and because I can't point to single files as externals (but only to directories) I can't simply use a structure like - components/ - behaviors/ - plugins/ etc. So at the moment my repository is cluttered up with folders and subfolders but misses a clean structure... Are there any "rules of thumb" or best practices on how to structure it? How do you guys do it? Thanks a lot for help Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Configure before components initialize - startupProcess() or constructClasses() a good idea?
Hi there, i've recently stepped into a problem with Session component configuration, i needed to be able to set the Session path and save path for a specific plugin, it's a separate app in the app and runs under a different user, and so i needed to separate the sessions, otherwise it would always throw permission errors when trying to access/delete session temp files, etc. To make a long story short, components may cause/require the session to start on initialization (popular ex. DebugKit), and so one needs to do the configuration earlier. Am i right that the only options are constructClasses() and startupProcess()? I couldn't find any other possible point to hook in, though i'm wondering if this is really the right way to do it? Regards Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
@Miles: oh no for sure I won't! That's exactly what I was expecting from CakePHP <2.0 already... :-P On Tue, Nov 16, 2010 at 7:24 PM, Miles J wrote: > Well you're going to hate Cake 2.0 which is getting rid of the error > system in place of exceptions :P > > On Nov 16, 12:47 am, Joshua Muheim wrote: >> Thank you for your replies. I was not aware that false is returned, so >> I'm taking back my accusation that CakePHP is lazy. Still I'd like to >> have an option that CakePHP automatically cries when in development >> mode... >> >> On Sat, Nov 13, 2010 at 5:32 PM, mark_story wrote: >> > Also App::import() returns false when an import fails. If you are >> > interested in whether or not things succeed, you could check the >> > return value of the method. >> >> > -Mark >> >> > On Nov 12, 5:05 am, psybear83 wrote: >> >> Hi all >> >> >> I don't get it why CakePHP doesn't complain about stuff like when one >> >> specifies missing components or fixtures: >> >> >> var $components = array('SomeNotExistingComponent'); >> >> var $fixtures = array('app.this_fixture_does_not_exist'); >> >> App::import('Lib', 'TheresNoSuchFileInLib'); >> >> >> All the three lines do not result in any error, and I guess there's >> >> more of that like $uses or stuff, but I didn't investigate this any >> >> further. >> >> >> Can anyone tell me why CakePHP just doesn't care about stuff like >> >> that? Seems vry unresponsible to me... >> >> >> Thanks for any hints >> >> Josh >> >> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others >> > with their CakePHP related questions. >> >> > 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 >> > athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
Well you're going to hate Cake 2.0 which is getting rid of the error system in place of exceptions :P On Nov 16, 12:47 am, Joshua Muheim wrote: > Thank you for your replies. I was not aware that false is returned, so > I'm taking back my accusation that CakePHP is lazy. Still I'd like to > have an option that CakePHP automatically cries when in development > mode... > > On Sat, Nov 13, 2010 at 5:32 PM, mark_story wrote: > > Also App::import() returns false when an import fails. If you are > > interested in whether or not things succeed, you could check the > > return value of the method. > > > -Mark > > > On Nov 12, 5:05 am, psybear83 wrote: > >> Hi all > > >> I don't get it why CakePHP doesn't complain about stuff like when one > >> specifies missing components or fixtures: > > >> var $components = array('SomeNotExistingComponent'); > >> var $fixtures = array('app.this_fixture_does_not_exist'); > >> App::import('Lib', 'TheresNoSuchFileInLib'); > > >> All the three lines do not result in any error, and I guess there's > >> more of that like $uses or stuff, but I didn't investigate this any > >> further. > > >> Can anyone tell me why CakePHP just doesn't care about stuff like > >> that? Seems vry unresponsible to me... > > >> Thanks for any hints > >> Josh > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > 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 > > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
Thank you for your replies. I was not aware that false is returned, so I'm taking back my accusation that CakePHP is lazy. Still I'd like to have an option that CakePHP automatically cries when in development mode... On Sat, Nov 13, 2010 at 5:32 PM, mark_story wrote: > Also App::import() returns false when an import fails. If you are > interested in whether or not things succeed, you could check the > return value of the method. > > -Mark > > On Nov 12, 5:05 am, psybear83 wrote: >> Hi all >> >> I don't get it why CakePHP doesn't complain about stuff like when one >> specifies missing components or fixtures: >> >> var $components = array('SomeNotExistingComponent'); >> var $fixtures = array('app.this_fixture_does_not_exist'); >> App::import('Lib', 'TheresNoSuchFileInLib'); >> >> All the three lines do not result in any error, and I guess there's >> more of that like $uses or stuff, but I didn't investigate this any >> further. >> >> Can anyone tell me why CakePHP just doesn't care about stuff like >> that? Seems vry unresponsible to me... >> >> Thanks for any hints >> Josh > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: A Matter of Discipline (Components and Models)
On Sun, Nov 14, 2010 at 7:42 AM, O.J. Tibi wrote: > Hi all, > > Cutting to the chase: > > 1.) I'm writing code in a controller now. > 2.) I need "raw" data (text from a cookie/s) managed by a custom > component (that could use the built-in Cookie component). > 3.) The cookie's value will be used to retrieve associated data from a > particular model. > 4.) The resulting record's primary key (id) will be set into $this- >>data as an association (e.g., $this->data['User']['foreign_id'] = > $resultRecord['SampleModel']['id']) > 5.) Save $this->data into the final model. > > I'm thinking of doing an App::import('Model') inside my custom > component, OR doing an App::import('Component') in my lookup model, > since "fat models and skinny controllers" is an often preached > discipline. These approaches feel dirty because accessing a model > inside a component, and accessing components inside models are not > generally recommended methods of writing manageable code. > > I'm also thinking of writing the coupling code inside the controller, > although it would make the controller a little fatter ("keep it short, > stupid" is another discipline I'm striving to practice diligently). > Loose-coupling in the long run will make it easier to maintain and add > new features, but I'm not sure if writing the bulk of the code in the > controller is worth it. > > Can you guys suggest how you approach this dilemma, or at least point > me where to look for techniques? Take advantage of the fact that components' callbacks are handed a ref to the controller. You've got several choices: public function initialize(&$Controller, $settings = array()) {} public function startup(&$Controller) {} public function beforeRender(&$Controller) {} Given that, it should be a cinch to get at $Controller's data. You just need to figure out which requests are the ones you want to act upon, then if $Controller->data is empty or not. Additionally, you can use the controller's model to get at its associated model. $this->Controller->Model->OtherModel->find(...) Perhaps even better, put the find() in one of the models. If doing that, one might as well put it in the first instead of dealing with the chain inside the component: $fk = $this->Controller->Model->someMethod($cookie_value); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
A Matter of Discipline (Components and Models)
Hi all, Cutting to the chase: 1.) I'm writing code in a controller now. 2.) I need "raw" data (text from a cookie/s) managed by a custom component (that could use the built-in Cookie component). 3.) The cookie's value will be used to retrieve associated data from a particular model. 4.) The resulting record's primary key (id) will be set into $this- >data as an association (e.g., $this->data['User']['foreign_id'] = $resultRecord['SampleModel']['id']) 5.) Save $this->data into the final model. I'm thinking of doing an App::import('Model') inside my custom component, OR doing an App::import('Component') in my lookup model, since "fat models and skinny controllers" is an often preached discipline. These approaches feel dirty because accessing a model inside a component, and accessing components inside models are not generally recommended methods of writing manageable code. I'm also thinking of writing the coupling code inside the controller, although it would make the controller a little fatter ("keep it short, stupid" is another discipline I'm striving to practice diligently). Loose-coupling in the long run will make it easier to maintain and add new features, but I'm not sure if writing the bulk of the code in the controller is worth it. Can you guys suggest how you approach this dilemma, or at least point me where to look for techniques? Cheers, OJ Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
Also App::import() returns false when an import fails. If you are interested in whether or not things succeed, you could check the return value of the method. -Mark On Nov 12, 5:05 am, psybear83 wrote: > Hi all > > I don't get it why CakePHP doesn't complain about stuff like when one > specifies missing components or fixtures: > > var $components = array('SomeNotExistingComponent'); > var $fixtures = array('app.this_fixture_does_not_exist'); > App::import('Lib', 'TheresNoSuchFileInLib'); > > All the three lines do not result in any error, and I guess there's > more of that like $uses or stuff, but I didn't investigate this any > further. > > Can anyone tell me why CakePHP just doesn't care about stuff like > that? Seems vry unresponsible to me... > > Thanks for any hints > Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
It will error out when you try to access a component that doesn't exist. Adding an invalid string to an array should not cause CakePHP to barf errors. On Nov 12, 10:09 am, cricket wrote: > On Fri, Nov 12, 2010 at 5:05 AM, psybear83 wrote: > > Hi all > > > I don't get it why CakePHP doesn't complain about stuff like when one > > specifies missing components or fixtures: > > > var $components = array('SomeNotExistingComponent'); > > var $fixtures = array('app.this_fixture_does_not_exist'); > > App::import('Lib', 'TheresNoSuchFileInLib'); > > > All the three lines do not result in any error, and I guess there's > > more of that like $uses or stuff, but I didn't investigate this any > > further. > > It would have taken you all of ... four seconds? ... to add 'Foo' to > some controller's $uses array and load up a route pointing to it. > > For those who can't bear the suspense: Cake will complain that the > table for the model is missing. Remember that Cake can "virtualize" a > model, so a missing model class is not necessarily a show-stopper. > > > Can anyone tell me why CakePHP just doesn't care about stuff like > > that? Seems vry unresponsible to me... > > It's not that Cake "doesn't care"--it'll simply return false when, eg. > failing to load a missing component. What's "unresponsible" is listing > components, plugins, etc. that don't exist. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
On Fri, Nov 12, 2010 at 5:05 AM, psybear83 wrote: > Hi all > > I don't get it why CakePHP doesn't complain about stuff like when one > specifies missing components or fixtures: > > var $components = array('SomeNotExistingComponent'); > var $fixtures = array('app.this_fixture_does_not_exist'); > App::import('Lib', 'TheresNoSuchFileInLib'); > > All the three lines do not result in any error, and I guess there's > more of that like $uses or stuff, but I didn't investigate this any > further. It would have taken you all of ... four seconds? ... to add 'Foo' to some controller's $uses array and load up a route pointing to it. For those who can't bear the suspense: Cake will complain that the table for the model is missing. Remember that Cake can "virtualize" a model, so a missing model class is not necessarily a show-stopper. > Can anyone tell me why CakePHP just doesn't care about stuff like > that? Seems vry unresponsible to me... It's not that Cake "doesn't care"--it'll simply return false when, eg. failing to load a missing component. What's "unresponsible" is listing components, plugins, etc. that don't exist. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
CakePHP should be more strict with unclean configuration, e.g. when specifying missing components! --psybear
Hi all I don't get it why CakePHP doesn't complain about stuff like when one specifies missing components or fixtures: var $components = array('SomeNotExistingComponent'); var $fixtures = array('app.this_fixture_does_not_exist'); App::import('Lib', 'TheresNoSuchFileInLib'); All the three lines do not result in any error, and I guess there's more of that like $uses or stuff, but I didn't investigate this any further. Can anyone tell me why CakePHP just doesn't care about stuff like that? Seems vry unresponsible to me... Thanks for any hints Josh Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: beforeFilter() after initialization of components but before beforeRender? --psybear
Well, I found a way to implement another controller hook that is called between initialization of components and execution of action logic: _afterComponentsInitialization(); } } You think this is a good way? :-) On Fri, Nov 12, 2010 at 10:59 AM, Joshua Muheim wrote: > Oh, and by the way: why is the "filter" in beforeFilter resp. > afterFilter? beforeRender makes sense to me, but beforeFilter seems a > strange name to me... > > On Fri, Nov 12, 2010 at 10:30 AM, Joshua Muheim wrote: >> I'm using a component called SimpleAuth and SimpleAcl (instead of the >> standard Auth and Acl ones because they are too complicated for my >> small project). >> >> SimpleAuth features a getActiveUser() method which returns the >> currently logged in user. This method calls $this->Controller, which >> is only available when the component's startup(...) method was called >> from CakePHP. >> >> In my view I'd like to have a $user object contains all the user's >> data and which can also handle stuff like $user->isAllowedTo(...) or >> $user->isGuest(). I have created some UserProxy class for this: >> >> class UserProxy { >> var $auth; >> var $acl; >> var $guestId = 1; >> >> function __construct($auth, $acl) { >> $this->auth = $auth; >> $this->acl = $acl; >> $this->user = $this->auth->getActiveUser(); // This line will be >> important! >> } >> >> function name() { >> return $this->user['User']['name']; >> } >> >> function isGuest() { >> return $this->user['User']['id'] == $this->guestId; >> } >> } >> >> To automatically have this $user object available in my views, I want >> to set it in a beforeFilter(). >> >> function _prepareUser() { >> $this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl); >> $this->set('user', $this->user); >> } >> >> This requires the SimpleAuth and SimpleAcl components to already be >> initalized, because in $this->auth->getActiveUser() in the constructor >> of UserProxy the SimpleAuth components needs access to the controller >> and the session: >> >> function getActiveUser() { >> if >> ($activeUserId=$this->Controller->Session->read($this->userModel.'.id')) >> { >> ... >> } >> ... >> } >> >> And because the startup() method doesn't seem to be called at this >> time already, I get the following error: >> >> Warning: Trying to get property of non-object >> [APP/controllers/components/simple_auth.php, line 120] >> SimpleAuthComponent::getActiveUser() - >> APP/controllers/components/simple_auth.php, line 120 >> UserProxy::__construct() - APP/controllers/app_controller.php, line 10 >> AppController::_prepareUser() - APP/controllers/app_controller.php, line 37 >> AppController::beforeFilter() - APP/controllers/app_controller.php, line 28 >> Controller::startupProcess() - >> CORE/cake/libs/controller/controller.php, line 526 >> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187 >> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 >> [main] - APP/webroot/index.php, line 83 >> >> Fatal error: Call to a member function read() on a non-object in >> /Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php >> on line 120 >> >> So I need a filter that's called before the components are initialized >> (that's the beforeFilter()) and a filter that's called after the >> initialization of the components but before the controller and view >> codes are processed. >> >> So @Miles: no, the beforeFilter() can't be executed after the >> components' initialization, because often we set component-specific >> parameters in the beforeFilter, like >> >> function beforeFilter() { >> $this->Security->blackHoleCallback = '_blackHole'; >> parent::beforeFilter(); >> } >> >> Anyone got an idea on how to accomplish this? IMHO there should be a >> beforeComponents() and an afterComponents() filter... >> >> On Thu, Nov 11, 2010 at 8:43 PM, Miles J wrote: >>> Also forgot to mention that there is an afterFilter() as well. >>> >>> On Nov 11, 10:30 am, Miles J wrote: >>>> Components are initialized before they get to beforeFilter(), so >>>> beforeFilter() should work fine. >>
Re: beforeFilter() after initialization of components but before beforeRender? --psybear
Oh, and by the way: why is the "filter" in beforeFilter resp. afterFilter? beforeRender makes sense to me, but beforeFilter seems a strange name to me... On Fri, Nov 12, 2010 at 10:30 AM, Joshua Muheim wrote: > I'm using a component called SimpleAuth and SimpleAcl (instead of the > standard Auth and Acl ones because they are too complicated for my > small project). > > SimpleAuth features a getActiveUser() method which returns the > currently logged in user. This method calls $this->Controller, which > is only available when the component's startup(...) method was called > from CakePHP. > > In my view I'd like to have a $user object contains all the user's > data and which can also handle stuff like $user->isAllowedTo(...) or > $user->isGuest(). I have created some UserProxy class for this: > > class UserProxy { > var $auth; > var $acl; > var $guestId = 1; > > function __construct($auth, $acl) { > $this->auth = $auth; > $this->acl = $acl; > $this->user = $this->auth->getActiveUser(); // This line will be important! > } > > function name() { > return $this->user['User']['name']; > } > > function isGuest() { > return $this->user['User']['id'] == $this->guestId; > } > } > > To automatically have this $user object available in my views, I want > to set it in a beforeFilter(). > > function _prepareUser() { > $this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl); > $this->set('user', $this->user); > } > > This requires the SimpleAuth and SimpleAcl components to already be > initalized, because in $this->auth->getActiveUser() in the constructor > of UserProxy the SimpleAuth components needs access to the controller > and the session: > > function getActiveUser() { > if ($activeUserId=$this->Controller->Session->read($this->userModel.'.id')) > { > ... > } > ... > } > > And because the startup() method doesn't seem to be called at this > time already, I get the following error: > > Warning: Trying to get property of non-object > [APP/controllers/components/simple_auth.php, line 120] > SimpleAuthComponent::getActiveUser() - > APP/controllers/components/simple_auth.php, line 120 > UserProxy::__construct() - APP/controllers/app_controller.php, line 10 > AppController::_prepareUser() - APP/controllers/app_controller.php, line 37 > AppController::beforeFilter() - APP/controllers/app_controller.php, line 28 > Controller::startupProcess() - > CORE/cake/libs/controller/controller.php, line 526 > Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187 > Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 > [main] - APP/webroot/index.php, line 83 > > Fatal error: Call to a member function read() on a non-object in > /Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php > on line 120 > > So I need a filter that's called before the components are initialized > (that's the beforeFilter()) and a filter that's called after the > initialization of the components but before the controller and view > codes are processed. > > So @Miles: no, the beforeFilter() can't be executed after the > components' initialization, because often we set component-specific > parameters in the beforeFilter, like > > function beforeFilter() { > $this->Security->blackHoleCallback = '_blackHole'; > parent::beforeFilter(); > } > > Anyone got an idea on how to accomplish this? IMHO there should be a > beforeComponents() and an afterComponents() filter... > > On Thu, Nov 11, 2010 at 8:43 PM, Miles J wrote: >> Also forgot to mention that there is an afterFilter() as well. >> >> On Nov 11, 10:30 am, Miles J wrote: >>> Components are initialized before they get to beforeFilter(), so >>> beforeFilter() should work fine. >>> >>> https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c... >>> >>> On Nov 11, 9:24 am, Bogdan Bursuc wrote: >>> >>> > Why do you need one ? >>> >>> > On Thu, Nov 11, 2010 at 7:18 PM, psybear83 wrote: >>> > > Hi all >>> >>> > > Is there a filter that runs after the initialization of components but >>> > > before beforeRender? >>> >>> > > Thanks for help >>> > > Josh >>> >>> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others >>> > > with their CakePHP re
Re: beforeFilter() after initialization of components but before beforeRender? --psybear
I'm using a component called SimpleAuth and SimpleAcl (instead of the standard Auth and Acl ones because they are too complicated for my small project). SimpleAuth features a getActiveUser() method which returns the currently logged in user. This method calls $this->Controller, which is only available when the component's startup(...) method was called from CakePHP. In my view I'd like to have a $user object contains all the user's data and which can also handle stuff like $user->isAllowedTo(...) or $user->isGuest(). I have created some UserProxy class for this: class UserProxy { var $auth; var $acl; var $guestId = 1; function __construct($auth, $acl) { $this->auth = $auth; $this->acl = $acl; $this->user = $this->auth->getActiveUser(); // This line will be important! } function name() { return $this->user['User']['name']; } function isGuest() { return $this->user['User']['id'] == $this->guestId; } } To automatically have this $user object available in my views, I want to set it in a beforeFilter(). function _prepareUser() { $this->user = new UserProxy($this->SimpleAuth, $this->SimpleAcl); $this->set('user', $this->user); } This requires the SimpleAuth and SimpleAcl components to already be initalized, because in $this->auth->getActiveUser() in the constructor of UserProxy the SimpleAuth components needs access to the controller and the session: function getActiveUser() { if ($activeUserId=$this->Controller->Session->read($this->userModel.'.id')) { ... } ... } And because the startup() method doesn't seem to be called at this time already, I get the following error: Warning: Trying to get property of non-object [APP/controllers/components/simple_auth.php, line 120] SimpleAuthComponent::getActiveUser() - APP/controllers/components/simple_auth.php, line 120 UserProxy::__construct() - APP/controllers/app_controller.php, line 10 AppController::_prepareUser() - APP/controllers/app_controller.php, line 37 AppController::beforeFilter() - APP/controllers/app_controller.php, line 28 Controller::startupProcess() - CORE/cake/libs/controller/controller.php, line 526 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 187 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171 [main] - APP/webroot/index.php, line 83 Fatal error: Call to a member function read() on a non-object in /Users/josh/Sites/working_tests/checking_out_simple_auth_and_simple_acl/app/controllers/components/simple_auth.php on line 120 So I need a filter that's called before the components are initialized (that's the beforeFilter()) and a filter that's called after the initialization of the components but before the controller and view codes are processed. So @Miles: no, the beforeFilter() can't be executed after the components' initialization, because often we set component-specific parameters in the beforeFilter, like function beforeFilter() { $this->Security->blackHoleCallback = '_blackHole'; parent::beforeFilter(); } Anyone got an idea on how to accomplish this? IMHO there should be a beforeComponents() and an afterComponents() filter... On Thu, Nov 11, 2010 at 8:43 PM, Miles J wrote: > Also forgot to mention that there is an afterFilter() as well. > > On Nov 11, 10:30 am, Miles J wrote: >> Components are initialized before they get to beforeFilter(), so >> beforeFilter() should work fine. >> >> https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c... >> >> On Nov 11, 9:24 am, Bogdan Bursuc wrote: >> >> > Why do you need one ? >> >> > On Thu, Nov 11, 2010 at 7:18 PM, psybear83 wrote: >> > > Hi all >> >> > > Is there a filter that runs after the initialization of components but >> > > before beforeRender? >> >> > > Thanks for help >> > > Josh >> >> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others >> > > with their CakePHP related questions. >> >> > > 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.comFor >> > > more options, visit this group at >> > >http://groups.google.com/group/cake-php?hl=en >> >> > -- >> > Thanks, >> > Bogdan Iulian Bursuc > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this
Re: beforeFilter() after initialization of components but before beforeRender? --psybear
Also forgot to mention that there is an afterFilter() as well. On Nov 11, 10:30 am, Miles J wrote: > Components are initialized before they get to beforeFilter(), so > beforeFilter() should work fine. > > https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/c... > > On Nov 11, 9:24 am, Bogdan Bursuc wrote: > > > Why do you need one ? > > > On Thu, Nov 11, 2010 at 7:18 PM, psybear83 wrote: > > > Hi all > > > > Is there a filter that runs after the initialization of components but > > > before beforeRender? > > > > Thanks for help > > > Josh > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others > > > with their CakePHP related questions. > > > > 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.comFor > > > more options, visit this group at > > >http://groups.google.com/group/cake-php?hl=en > > > -- > > Thanks, > > Bogdan Iulian Bursuc Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: beforeFilter() after initialization of components but before beforeRender? --psybear
Components are initialized before they get to beforeFilter(), so beforeFilter() should work fine. https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/controller.php#L525 On Nov 11, 9:24 am, Bogdan Bursuc wrote: > Why do you need one ? > > > > On Thu, Nov 11, 2010 at 7:18 PM, psybear83 wrote: > > Hi all > > > Is there a filter that runs after the initialization of components but > > before beforeRender? > > > Thanks for help > > Josh > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > > with their CakePHP related questions. > > > 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.comFor > > more options, visit this group at > >http://groups.google.com/group/cake-php?hl=en > > -- > Thanks, > Bogdan Iulian Bursuc Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: beforeFilter() after initialization of components but before beforeRender? --psybear
Why do you need one ? On Thu, Nov 11, 2010 at 7:18 PM, psybear83 wrote: > Hi all > > Is there a filter that runs after the initialization of components but > before beforeRender? > > Thanks for help > Josh > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > -- Thanks, Bogdan Iulian Bursuc Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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