I have a service like this :
services:
prodacom_authentication.encode:
class: Prodacom\AuthenticationBundle\Service\Encode
arguments: ["@security.context"]
the service function i want to call in a controller:
public function encodePassword() {
$factory = $this->get('security.encoder_factory');
$user = new Prodacom\MainBundle\Entity\PdbUser();
$encoder = $factory->getEncoder($user);
$password = $encoder->encodePassword('ryanpass', $user->getSalt());
var_dump($password);
$user->setPassword($password);
}
i want to call the function encodePassword in the authenticationController.php.
$this->get('prodacom_authentication.encode')->encodePassword();
but i keep getting this error :
Attempted to call method "get" on class "Prodacom\AuthenticationBundle\Service\Encode" in C:\htdocs\domeinbeheer\src\Prodacom\AuthenticationBundle\Service\Encode.php line 12.
any ideas ???
->get('')in Your service You have to passcontainerservice to It.