Esempio n. 1
0
 public function getFactory()
 {
     if ($this->factory == NULL) {
         $this->factory = Factory::factory();
         $this->factory->registerType('resource', 'ResourceController');
         $this->factory->registerType('service', 'ServiceController');
         $this->factory->registerType('users', 'UserController');
         $this->factory->registerType('apps', 'ClientAppController');
     }
     return $this->factory;
 }
Esempio n. 2
0
<?php

require_once './libs/Autoload.class.php';
/*spl_autoload_extensions(".php,.class.php");
	set_include_path(get_include_path() . PATH_SEPARATOR . '/libs/');*/
spl_autoload_register('autoload');
error_reporting(E_ALL & ~E_NOTICE);
$numA = $_POST['numA'];
$sign = $_POST['sign'];
$numB = $_POST['numB'];
$obj = new Factory($sign);
$result = $obj->factory()->getResult($numA, $numB);
echo $result;
Esempio n. 3
0
{
    private static $instance;
    private function __construct($a, $b, $c)
    {
        echo 'Product52 ', $a, $b, $c, " <br/>\n";
    }
    public static function __instance($a, $b, $c)
    {
        if (!isset(self::$instance)) {
            self::$instance = new self($a, $b, $c);
        }
        return self::$instance;
    }
}
class Product5Factory
{
    public static function factory($a = null, $b = null, $c = null)
    {
        if ($a && $b && $c) {
            return Product52::__instance($a, $b, $c);
        }
        return new Product51();
    }
}
$product1 = Factory::factory('Product1');
$product2 = Factory::factory('Product2', array('a', 'b', 'c'));
$product3 = Factory::factory('Product3', null, '__instance');
$product4 = Factory::factory('Product4', array('a', 'b', 'c'), '__instance');
$product51 = Factory::factory('Product5');
$product52 = Factory::factory('Product5', array('a', 'b', 'c'));