-- Andrew Ballard <[email protected]> wrote
(on Wednesday, 03 June 2009, 09:47 AM -0400):
> I have been looking over the data mapper pattern used in the current
> Quickstart. I like the separation of the data model from the storage,
> but I have a question.
> 
> In the guestbook model, setId() and setCreated() are declared public.
> I realize this is necessary in the example because the values are
> being set by the mapper, which is external to the domain model class.
> However, I would think that it would be desirable some properties such
> as these one to be generally read-only. Is there any way to control
> which external classes are able to use these methods? Java has a
> package scope that would work, but PHP doesn't even have a concept of
> packages in its OO implementation.

PHP doesn't have such a concept. One way to get around it is to only
allow setting of particular properties by passing them to the
constructor, which is a technique I've often seen.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to