Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:52:17+00:00 2026-06-11T14:52:17+00:00

I am developing an application in Zend Framework and have the following layers: controller,

  • 0

I am developing an application in Zend Framework and have the following layers: controller, service, domain model and mapper.

My domain objects need to be represented as arrays for several different purposes. For example, the mapper turns the object into an array prior to persisting it; the form requires an array as a parameter to its populate() method; and there are a few other examples too.

So, my question is, in what layer should I be doing the translation to an array? The translation for an object varies slightly depending on the context in which it is used, e.g. the object ID is not required when persisting a new object, but is required when persisting updates, or when populating a form.

As far as I can see there are two options. Option 1 is to do the translation in each component (i.e. the mapper, the form, etc). Option 2 is to put it in the domain object itself, and let the client code pass a parameter to determine which array variation they require, e.g. $array = $domObject->toArray('populateForm');

Option 1 would involve a fair amount of duplication, but it seems to adhere to the separation of concerns rule. Option 2 would avoid the duplication, but I’m not sure that my domain object should be concerned with representing itself in variety of different ways.

Perhaps the domain object should just produce a ‘vanilla’ array, and each component should tailor it for its own use? And another point relates to patterns. Should I be looking to apply the decorator or some other pattern?

Your thoughts are much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:52:18+00:00Added an answer on June 11, 2026 at 2:52 pm

    My thoughts on this are first, do you think you are doing this the right way? It sounds fairly complicated without any real knowledge about the project. It feels like you are trying to do a typical solution someone very new to Zend would do to then realise it was unnecessary. Then again I do not know alot about your project.

    Secondly, I would probably put such functionality in the service layer. Service layer to me has almost always been about manipulating objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing application using backbone.js & jquery. I have following code in model: runReport:
I am developing an application using Zend Framework 1.11.10. I have used this article
I am developing an application with the Zend Frameworks. I currently have the Controller
I am developing a web application using zend framework. For select statements I have
I'm developing a zend framework application that includes a simple email function. The development
Am developing a Zend application where i need to keep a single instance of
I am developing the application of login using facebook in Zend Framework. I done
I'm developing a modular application with Zend Framework and I find that I use
I am developing an application at the moment with zend and I have seperated
I am developing an application to manage a law office using zend framework 1.10,PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.