Friday, December 23, 2011

Re: Using Model constants all over app

i found that one, too.

Just wondered if there is any better solution to it or to the whole
thing.

On Dec 23, 12:54 pm, euromark <dereurom...@googlemail.com> wrote:
> that's exactly how I do it:http://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-at...
>
> On 23 Dez., 11:23, func0der <funco...@web.de> wrote:
>
>
>
>
>
>
>
> > Hey guys,
>
> > i worked a lit with Magento in the last months.
> > They used, in my opinion, a really good way to configurate and/or
> > access for example status fields.
>
> > They had a table field for example for the status of an order.
> > 0 meant cancelled
> > 1 meant payed
> > 2 meant completed
>
> > In the Model they used constants for identifying these statuses (if
> > this is the plural of it)
>
> > class Order{
> >    const ORDER_STATUS_CANCELLED = 0;
> >    const ORDER_STATUS_PAYED = 1;
> >    const ORDER_STATUS_COMPLETED = 2;
>
> > }
>
> > So they could access these constants from as good as anyway with
> > Order::ORDER_STATUS_CANCELLED.
>
> > Is there a way to do so in cakephp?
> > I mean without requiring the class, using "new" and so on?
>
> > I need to access it from helpers, views, models, controllers and
> > everywhere.
>
> > Any idea?
>
> > Greetings
> > func0der

--
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: