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 7964301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:51:09+00:00 2026-06-04T05:51:09+00:00

I have an application that uses Doctrine ORM for entities. I try to push

  • 0

I have an application that uses Doctrine ORM for entities. I try to push as much business logic into the entities as possible, following OO design. But I have run into a small problem. Some of the business logic requires variables that are defined in my external application configuration (because they sometimes need to be tweaked). How do I get these into my entities without violating OO principles? I don’t want to access my global configuration directly from my entities, and I don’t want to store these variables inside my entities and database either.

Here’s a mode concrete example. I use PHP with Doctrine ORM but the same kind of OO principles apply to Hibernate (JAVA), nHibernate (C#), etcetera.

My application has Products and Users. There are many different kinds of Users (real human users, automated robots, etcetera). They all need to work on the Product object. All the users share the same UserInterface which has a single method:

class UserInterface {
    function canProcess(Product $product);
}

I have a ProcessService that mediates between the Products and the Users. It just iterates over all the Users attached to a Product until it finds one that is willing to process it at that time.

class ProcessService {

    // Process a product
    function process(Product $product) {
        foreach ($this->getUsers() as $user) {
            if ($user->canProcess($product)) {
                ...
            }
     }
}

The problem is that some of the users (in my case one of the robots) needs to have an external configuration variable in order to determine if it can process a product.

I don’t want to store that value in my entity and database (it’s not the right place) and I don’t want to access my global configuration object from inside the robot entity (violates OO). But, I also can’t pass it throught the canProcess() interface method because this variable is only applicable for that one type of robot, not for all the other kinds of users in my system. So, it has no place in the UserInterface either.

So, how do I get this configuration variable into my entity?

  • 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-04T05:51:12+00:00Added an answer on June 4, 2026 at 5:51 am

    I solved it by using a postLoad event handler. The application configuration is passed to the event handler, and on the postLoad event I inject the configuration settings in the appropriate User entities that need it.

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

Sidebar

Related Questions

I have a Symfony application that uses Doctrine as its ORM. Based on Symfony's
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have an application that uses the Facebook SDK for Android to login into
I have an application that uses RPC for interprocess communications. Turns out that synchronous
I have an application that uses rest to communicate to a server, i would
I have an application that uses CoreData. I previously had a class named Marker
I have an application that uses the Paperclip plugin for image upload. Now that
We have an application that uses Hibernate's 2nd level caching to avoid database hits.
i have an application that uses SMTP to send emails from an yahoo account.
I have an application that uses the Google Maps API to geocode distances between

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.