0

Hi to every one I'm new with symfony2, and i got two questions,

the first is: I need have 2 Parameters in one array, for example

   $actions = array('1' => 'In', '2' => 'Out')

in all symfony2 in my bundle, where is the appropriate place/file to set this parameter, I've seen in symfony 1.4 put this parameter in some classes but in symfony2 I dont know wherw to put it because I just have the Entity DIR for classes.

The second is:

I need create my own functions to do something about a entity class for example Employees, I need to create a function to get the a especific employe and after do some proccess with its information a return a value, well the question is
Where I should put my own functions in my bundle ?

Any Suggestion I appreciate it!!!

1 Answer 1

1

Answer to 2nd question: Symfony2 uses ClassLoader so if you will follow coding standards, you can put it anywhere, you want to (I recommend you to read best practises). Just register namespace:

namespace Acme\TestBundle\Temp;

class MyClass
{
  public function getCertainEmployee($param)
  {}
}

One of possible way is to use EntityRepository.

namespace Acme\TestBundle\Entity;

use Doctrine\ORM\EntityRepository;

class EmployeeRepository extends EntityRepository
{
  public function getCertainEmployee($param)
  {}
}

The you can just call:

$certainEmployee = $this->getDoctrine()
                        ->getEntityRepository('AcmeTestBundle:Employee')
                        ->getCertainEmployee($foo)
;
Sign up to request clarification or add additional context in comments.

1 Comment

ok thanks you, what is the function for the repository class of an object?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.