At the beginning I am sorry for the title – I don’t know how to call this problem.
Let’s say I have (simplified) classes:
class Articles_Repository {
public function save(Article_Entity $article) {...}
public function find($id) {...}
// Other methods
}
class Article_Entity {
public $thumbnail_url;
public $title;
public $text;
...
}
Where should I put “changing thumbnail” – method to upload&crop&save thumbnail for specific article? Into Repository, Entity or somewhere else?
I believe that the best place to put the method is in a Service. I don’t think it’s the Article entity’s responsiblity to manipulate images. Repository’s, even less. The Article simply states that it has a thumbnail, it doesn’t care how the thumbnail was generated .
The controller should pass the uploaded image to a service wich will involve other objects to crop and then save the image (an images repository might work here). Then the thumbnail url will be assigned to the article.