Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You would probably define a Module like following:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php namespace Marketo; use Zend\ModuleManager\Feature\ConfigProviderInterface; class Module implements ConfigProviderInterface { public function getConfig() { return array( 'service_manager' =&gt; array( 'factories' =&gt; array( 'Marketo\Client\Client' =&gt; 'Marketo\ServiceFactory\ClientServiceFactory', ), ), 'marketo' =&gt; array( 'key' =&gt; 'DEFAULT', 'pass' =&gt; 'DEFAULT', ), ); } } </code></pre> <p>Note: I preferred to use <code>getConfig</code> over <code>getServiceConfig</code> since it is more flexible (overrideable) and the method call is cached when you setup your application to do so.</p> <p>Then the <code>Marketo\ServiceFactory\ClientServiceFactory</code>:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php namespace Marketo\ServiceFactory; use Marketo\Client\Client; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class ClientServiceFactory implements FactoryInterface { public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator-&gt;get('Config'); return new Client($config['marketo']['key'], $value['marketo']['pass']); } } </code></pre> <p>After that, you will be able to pull the Marketo client from the service locator by calling following (for example in controllers):</p> <pre class="lang-php prettyprint-override"><code>$marketoClient = $this-&gt;getServiceLocator()-&gt;get('Marketo\Client\Client'); </code></pre> <p>At this point, your <code>Marketo\Client\Client</code> is anyway built with <code>key</code> and <code>pass</code> both set to <code>DEFAULT</code>.</p> <p>Let's go on and override this by creating a <code>config/autoload/marketo.local.php</code> file (in your application root, not in the module!):</p> <pre class="lang-php prettyprint-override"><code>&lt;?php return array( 'marketo' =&gt; array( 'key' =&gt; 'MarketoAdmin', 'pass' =&gt; 'Pa$$w0rd', ), ); </code></pre> <p>This is VERY important since you should never redistribute your <code>key</code> and <code>pass</code>, so put this file into <code>.gitignore</code> or <code>svn:ignore</code>!</p> <p>So basically what we did here is:</p> <ol> <li>Setup service manager configuration to use a service factory to instantiate our Marketo client</li> <li>Setup the service factory to use merged configuration (service name: <code>'config'</code>) to instantiate the Marketo client</li> <li>Add local configuration for the actual application instance</li> <li>Retrieve the Marketo service via service locator.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload