I’m working with Symfony 1.4 and need help with variable injection into classes located in the frontend/lib directory. I can’t access $this->getUser
from within these classes since they exist outside the standard Symfony context, so session storage isn’t available.
Here’s my current implementation in apps/frontend/lib:
public function submitFormData( $project_id, $partner_id, $data = array(), &$result )
{
$data[ 'client_ip' ] = $_SERVER[ 'REMOTE_ADDR' ];
if ( isset( $custom_ip )) //need to pass this variable somehow
{
$data[ 'client_ip' ] = $custom_ip;
}
$data[ '__created_at' ] = date( 'Y-m-d H:i:s' );
$result = $this->httpClient->post( $this->service_url . 'submit/' . $project_id . '/' . $partner_id . '/', $data )->getResponseText();
return ( preg_match( '/(success)/', $result ) ) ? true : false;
}
This method gets called from an action in a frontend module. I’ve tried various approaches to pass the variable but I’m missing something fundamental about how data flows between these components. What’s the proper way to inject variables into these lib classes from the action layer?