Last active
December 18, 2015 14:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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