The tag has no wiki summary.

learn more… | top users | synonyms

10
votes
2answers
197 views

Trait accessing variables of classes using it

I just tried PHP Traits for the first time, to keep my code DRY : ...
6
votes
1answer
97 views

Uploading file for related entity

I see that my code smells. The first file is a controller, and createAction. But I don't know where to delegate this. BookController.php - Whole controller class So this is most 'smelly' code to ...
4
votes
1answer
169 views

Fetching objects and adding a calculated field in Doctrine 2

I'm making a section that shows a list of blogs and how many comments it has without loading any comment data. My Blog entity is as follows: ...
3
votes
1answer
1k views

Linking to an image asset from a JavaScript file in Symfony 2

I am calling a JS file from a bundle directory like so: <script src="{{ asset('bundles/macppages/js/main.js') }}"></script> which loads the JS file ...
3
votes
1answer
28 views

Tag manipulation using DOMDocument

On our main symfony2 application at work I have had to manipulate some outputted grid fields by wrapping them in a hyperlink tag. This happens in quite a few different controllers, so I made a method ...
3
votes
1answer
3k views
3
votes
1answer
1k views

Friends edit form

I have a list of friends and new friends are added via a form. When you click on a friend you see all the information about him. There is also an Edit button. When clicking it, I want a form to be ...
3
votes
0answers
202 views

Building a console application using a DI service container

I am working on a project that will allow developers to create a console application using a dependency injection service container. Both the console and container are Symfony components with some ...
2
votes
1answer
444 views

Uploading a file using Symfony 2.5 strictly

Recently I have been looking into Symfony framework and I am working on a task where I need to upload a file using a form. Once the form has been submitted I need to insert the user input along with ...
2
votes
1answer
118 views

Handling library entity

Below you'll find a Symfony2 service I wrote to assist in handling the Library entity. Each user in my app has a personal library where one can upload items to and a purchased library, that contains ...
2
votes
0answers
15 views

View helper for creating HTML elements with DOM

I have attempted to create a view helper class which makes programmatically creating HTML strings less verbose and hopefully simpler. This is inspired by the tag helpers in Rails. It's compatible ...
2
votes
0answers
34 views

Which pattern could help to refactor this controller code?

I know I should use services and patterns to refactor this controller action, but I can't imagine one that could fit/be appropriate for this problem. It seems a strategy or template, but a strategy ...
1
vote
1answer
58 views

Checking if a relationship exists

I'm using a many-to-many relationship between users and roles with propel: ...
1
vote
0answers
158 views

Form-processing controller action

I have a fairly ugly controller method I would like to refactor / extract. I can only test this in an integration-type test which kind of signals a code smell. The method processes the form and needs ...
0
votes
1answer
152 views

Database “design” using Symfony2 and Doctrine2

I'm working on an application, which tracks expenses. I have users, and each user can create his categories for the expenses (like Food, Bills, Transport, Drinks, Clothes) and then create expenses - ...