Skip to content

Instantly share code, notes, and snippets.

@peterfox
Last active December 18, 2015 14:09
Show Gist options
  • Save peterfox/5795295 to your computer and use it in GitHub Desktop.
Save peterfox/5795295 to your computer and use it in GitHub Desktop.
A template for wrapping third party libraries that require multiple instances to be generated an therefore require a factory pattern
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//Load this class with $this->load->library('CI_Something', $data, 'something');
require_once dir(__FILE__).'/Something/Something.php';
class CI_Something
{
public function __construct($config)
{
$expected = array('arguement1', 'arguement2', 'arguement3')
get_instance()->load->helper('array');
$config = elements($expected, $config);
//do what you need with your config parameters
}
public function initiate_something()
{
return new Something();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment