本文整理汇总了PHP中Factory::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::factory方法的具体用法?PHP Factory::factory怎么用?PHP Factory::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFactory
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;
}
示例2: Factory
<?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;
示例3: __construct
{
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'));