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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:02:29+00:00 2026-06-07T18:02:29+00:00

I read that a good practice have entities light, only getters and setters. But

  • 0

I read that a good practice have entities light, only getters and setters. But I have custom methods with some logic, for example.

public function calculatePrice(){

  /*
 Here I have to do many math operations 
 including access to other repositories to get 
 specific data (taxes, comissions, ect) from others entities
*/


}

Where to put this kind “more complex methods” for do:

//in controller
$product->calculatePrice()  

//in twig templates
{{ product.calculatePrice }}
  • 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-07T18:02:30+00:00Added an answer on June 7, 2026 at 6:02 pm

    I like to put business logic related to entities within a Service class. IMO, an entity repository should only be responsible for querying the DB for multiple items of an entity group, or very specific ‘findBy’ methods (ex: fetch all Messages belonging to User where isRead = 0).

    Often times, you’ll find yourself using multiple service classes to handle specific blocks of business logic – it’s easier (and cleaner) to keep all of this in the service layer instead of shoe-horning it into repositories.

    Using services for business logic will result in more modular code. If your Product entity and repo don’t contain any business logic (which is usually very specific per app), you can more easily reuse those classes in other projects without having to do as much cleanup.

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

Sidebar

Related Questions

I have read that as a good security practice it is good to enable
I have read that it is a good practice to not use too many
I have a read only list that is shared across all instances of the
I have some services with methods that return DTO's back to my controllers. Like
I have read it here : CodeProject and some other places that there should
I've read that good programming practice claims that one should use a function if
I have read other questions on this topic but none that actually answers my
I've read that it's supposedly a good idea to split an aggregator project (the
I've read that It's a good experience to use a fresh image every day
Original Question: i read that for RESTful websites. it is not good to use

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.