本文整理汇总了PHP中Factory::build方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::build方法的具体用法?PHP Factory::build怎么用?PHP Factory::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* @throws \Exception
*/
private function postProcess()
{
foreach ($this->config->PostProcessors as $processor) {
if (Classes::validateProcessor($processor)) {
$process = Factory::build($processor);
$process->process($this);
} else {
throw new \Exception('Mongular: Attempt to access invalid processor ' . $this->request);
}
}
}
示例2: testJsonFormatter
public function testJsonFormatter()
{
$factory = new Factory();
$format = $factory->build('json');
$data = $format->convertToArray($this->rawData);
$this->assertTrue(is_array($data));
$this->assertCount(5, $data);
}
示例3: getGuess
public function getGuess($letter)
{
$hangman = Factory::build('Hangman');
$this->template->hangman = $hangman;
if ($hangman->guess(strtoupper($letter))) {
$this->template->render('winner');
}
$this->template->render('guess');
}
示例4: buildParameters
/**
* @param $parameters
* @param $class
* @return array
* @throws \Exception
*/
private static function buildParameters($parameters, $class)
{
$di_params = array();
foreach ($parameters as $key => $parameter) {
$di_class = $parameter->getClass();
if (is_object($di_class)) {
$di_params[$parameter->name] = Factory::build('\\' . $di_class->name);
} else {
$error = 'Mongular DI error for Controller class ' . $class . ' on parameter ' . $parameter->name;
throw new \Exception($error);
}
}
return $di_params;
}
示例5: getDefinition
public function getDefinition()
{
if (empty($this->definitions)) {
$wordnik = Factory::build('Wordnik');
$definitions = $wordnik->getDefinitions(strtolower($this->word));
if (!is_null($definitions)) {
foreach ($definitions as $definition) {
if (isset($definition->text)) {
$this->definition = str_ireplace($this->word, '[WORD]', $definition->text);
break;
}
}
}
}
return $this->definition;
}
示例6: set
public static function set()
{
$num_args = func_num_args();
if ($num_args === 1) {
self::$config['url'] = self::URL;
self::$config['key'] = func_get_arg(0);
self::$config['url'] = Factory::build('account')->authenticate()->url;
} elseif ($num_args === 2) {
self::$config['url'] = $url = func_get_arg(0);
if ($is_subdomain = strpos($url, '.') === false) {
self::$config['url'] = self::URL;
}
self::$config['key'] = func_get_arg(1);
if ($is_subdomain) {
$url = Factory::build('account')->authenticate()->url;
}
self::$config['url'] = $url;
}
}
示例7: testNonExistentFactory
/**
* @expectedException \Carpenter\FactoryNotFoundException
* @expectedExceptionMessage "ImaginaryFactory" is not a registered factory
*/
public function testNonExistentFactory()
{
Factory::build('ImaginaryFactory');
}
示例8: build
public static function build($type)
{
$class = 'Format' . $type;
if (!class_exists($class)) {
throw new Exception('Missing format class.');
}
return new $class();
}
}
/**
* Class FormatString
*/
class FormatString implements Format
{
}
/**
* Class FormatNumber
*/
class FormatNumber implements Format
{
}
try {
$string = Factory::build('String');
} catch (Exception $e) {
echo $e->getMessage();
}
try {
$number = Factory::build('Number');
} catch (Exception $e) {
echo $e->getMessage();
}
示例9: __construct
/**
* Constructor.
*
* @param array $config
*/
private final function __construct(array $config)
{
$this->db = Factory::build(new Configuration($config));
$this->db->connect();
}
示例10:
<?php
namespace Mongular\Core;
require '../../vendor/autoload.php';
$mongular = Factory::build('\\Mongular\\Core\\Mongular');
/*
* Uncomment to add memcache support.
*/
//$mongular->addCache();
echo $mongular->build();
示例11: build
public function build(string $filter, callable $callback)
{
$conditions = $this->parser->parse($filter);
list($predicates, $types, $rooms) = $this->compiler->compile($conditions);
return $this->factory->build($filter, $predicates, $types, $rooms, $callback);
}
示例12: Factory
<?php
require_once __DIR__ . '/../vendor/autoload.php';
class Factory extends Rtablada\IbmDataStruct\StructFactory
{
protected static $rules = ['name_short' => 22, 'name_long' => ['length' => 10]];
protected static $structBuilderType = 'Rtablada\\IbmDataStruct\\IbmStructBuilder';
}
$factory = new Factory();
$values = ['name_long' => 'Ryan Tablada', 'name_short' => 'Ryan Tablada'];
echo $factory->build($values);
示例13: testBuildingFormatParser
public function testBuildingFormatParser()
{
$factory = new Factory();
$formatParser = $factory->build('json');
$this->assertTrue(is_object($formatParser));
}
示例14: testIfWeCanBuildNonExistentController
/**
* @expectedException Api\Exception\Controller
*/
public function testIfWeCanBuildNonExistentController()
{
$factory = new Factory();
$controller = $factory->build('InvalidController');
}
示例15: remove
/**
* @param $name
*/
public static function remove($name)
{
Factory::build(__CLASS__);
unset($_SESSION[$name]);
}