Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Created August 5, 2011 15:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save weaverryan/1127748 to your computer and use it in GitHub Desktop.
Example "Container" in symfony 1.4
<?php
class mySoapActions extends sfActions
{
public function executeSomething(sfWebRequest $request)
{
$soapApi = $this->getSoapAPI();
// do something with it
}
/**
* @return mtReportSoapApi
*/
private function getSoapAPI()
{
return $this->getContext()
->getConfiguration()
->getPluginConfiguration('mtReportPlugin')
->getSoapApi()
;
}
}
<?php
// plugins/mtReportPlugin/config/mtReportPluginConfiguration.class.php
class mtReportPluginConfiguration extends sfPluginConfiguration
{
protected $mtSoapApi;
public function getSoapApi()
{
if ($this->mtSoapApi === null)
{
// in theory, the creation of this would also be centralized, but whatever
$reportingObject = new reportGuidePageOrders();
$this->mtSoapApi = new mtReportSoapApi('some_config', 'other_config', $reportingObject);
}
return $this->mtSoapApi;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment