本文整理汇总了PHP中Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNewServer
public function createNewServer()
{
$F = new Factory("xCal");
$F->sA("xCalServerActive", "1");
$F->sA("xCalUserID", Session::currentUser()->getID());
$F->store();
}
示例2: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config_authentification_form');
$factory = new Factory();
$form = $factory->createForm($config);
return $form;
}
示例3: test_create_new
public function test_create_new()
{
/** === Test Data === */
$TRANS = 'transaction name';
$CONN = 'connection name';
/** === Setup Mocks === */
// $result = $this->_manObj->create(\Praxigento\Core\Transaction\Database\Def\Item::class);
$mResult = $this->_mock(\Praxigento\Core\Transaction\Database\Def\Item::class);
$this->mManObj->shouldReceive('create')->once()->andReturn($mResult);
// $result->setTransactionName($transactionName);
$mResult->shouldReceive('setTransactionName')->once()->with($TRANS);
// $result->setConnectionName($connectionName);
$mResult->shouldReceive('setConnectionName')->once()->with($CONN);
// $cfgData = $this->_configDeployment->get($cfgName);
$mCfgData = [];
$this->mConfigDeployment->shouldReceive('get')->once()->andReturn($mCfgData);
// $conn = $this->_factoryConn->create($cfgData);
$mConn = $this->_mock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
$this->mFactoryConn->shouldReceive('create')->once()->andReturn($mConn);
// $result->setConnection($conn);
$mResult->shouldReceive('setConnection')->once();
/** === Call and asserts === */
$res = $this->obj->create($TRANS, $CONN);
$this->assertTrue($res instanceof \Praxigento\Core\Transaction\Database\IItem);
}
示例4: handle_create
public function handle_create(Command\Create $cmd, Factory $factory)
{
$this->assert->not(Invariant\UserHasPendingCart::class);
$cart = $factory->make_new();
$cart->create($cmd->id, $cmd->customer_id);
$this->repo->store($cart);
}
示例5: createNew
public function createNew()
{
$F = new Factory("TinkerforgeBricklet");
$F->sA("TinkerforgeBrickletTinkerforgeID", $this->getID());
$F->store();
echo $this->bricklets();
}
示例6: validator
/**
* Custom validator to check email array
*
* @param Factory $factory
* @return $object
*/
public function validator($factory)
{
$campaign_id = $this->route('campaigns');
$validation = $factory->make($this->all(), $this->rules());
$validation->each('add_user_email_notification', ['exists:user_has_roles,user_id,campaign_id,' . $campaign_id]);
return $validation;
}
示例7: test_getReflection_should_return_instance_of_current_routed_class
function test_getReflection_should_return_instance_of_current_routed_class()
{
$route = new Factory('any', '/', 'DateTime', function () {
return new \DateTime();
});
$refl = $route->getReflection('format');
$this->assertInstanceOf('ReflectionMethod', $refl);
}
示例8: testShouldFactoryTypeParserWhenSomeArgumentKeyIsANumber
public function testShouldFactoryTypeParserWhenSomeArgumentKeyIsANumber()
{
$factory = new Factory();
$arguments = array('a' => true, 'b' => 42, 'c');
$expectedInstanceType = 'PHPFluent\\Callback\\ArgumentParser\\Type';
$actualInstance = $factory->parser($arguments);
$this->assertInstanceOf($expectedInstanceType, $actualInstance);
}
示例9: 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);
}
示例10: buildContent
/**
* [buildContent description]
* @param Factory $fieldFactory The field factory with all fields for the
* content
* @param array $data The content data, this should be specified
* as ['group' => [$field_1, $field_2, ...], ...]
* where $field_1 & $field_2 are a stdClass
* objects containing at least 'field' and
* 'value' properties
* @param string|ContentInterface $content Content class or class name
* @return ContentInterface Returns the build content
*/
public function buildContent(Factory $fieldFactory, $data, $content = '\\Message\\Cog\\Field\\Content')
{
if (!$content instanceof ContentInterface) {
if (!is_string($content)) {
throw new \InvalidArgumentException('content must be either ContentInterface or string, ' . gettype($content) == 'object' ? get_class($content) : gettype($content) . ' given');
}
$content = new $content();
}
foreach ($fieldFactory as $name => $field) {
if ($field instanceof Group && $field->isRepeatable()) {
// add sequence variable
$field->add($fieldFactory->getField('hidden', self::SEQUENCE_FIELD));
$field = new RepeatableContainer($field);
}
$content->set($name, $field);
}
// Loop through the content, grouped by group
foreach ($data as $groupName => $rows) {
foreach ($rows as $row) {
// If this field is in a group
if ($groupName) {
$group = $content->get($groupName);
if (!$group) {
continue;
}
// Get the right group instance if it's a repeatable group
if ($group instanceof RepeatableContainer) {
// Ensure the right number of groups are defined
while (!$group->get($row->sequence)) {
$group->add();
}
$group = $group->get($row->sequence);
// set sequence field value
$group->get('_sequence')->setValue($row->sequence);
}
// Set the field
try {
$field = $group->{$row->field};
} catch (\OutOfBoundsException $e) {
continue;
}
} else {
$field = $content->get($row->field);
}
// Skip the field if we can't find it
if (!isset($field)) {
continue;
}
// Set the values
if ($field instanceof MultipleValueField) {
$field->setValue($row->data_name, $row->value);
} elseif ($field instanceof BaseField) {
$field->setValue($row->value);
}
}
}
return $content;
}
示例11: __construct
public function __construct(Factory $factory)
{
$this->factory = $factory;
$this->db = $factory->getDb();
$this->logger = $factory->getLogger();
$this->mainTable = $this->getMainTable();
$this->relationsTable = $this->getRelationsTable();
$this->createTables();
}
示例12: main
public function main()
{
$myShapes = array();
$myFactory = new Factory();
$myShapes = $myFactory->getShapes();
foreach ($myShapes as $myShape) {
$myShape->draw();
}
}
示例13: testBehaviorOwner
public function testBehaviorOwner()
{
$factory = new Factory('http://localhost/');
$factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
$factory->attachBehavior('my', new \Sokil\Rest\Client\MyBehavior());
// exec behavior
$requert = $factory->createRequest('GetRequestMock');
$this->assertEquals('http://localhost/some/resource', $requert->getRequestUrl());
}
示例14: crawlComments
/**
* Crawl comments page
*
* @param array $comment previously received comments page link
* @param bool $proceed proceed or not with received comments
* @return array
*/
public function crawlComments($comments, $proceed = true)
{
$importer = new Factory($this->plugin->config);
$result = $importer->getImporter()->getComments($comments['page']);
if ($result && $proceed) {
$this->proceedPostComments($comments['postId'], $result);
}
return $result;
}
示例15: validator
/**
* Custom validator to check email array
*
* @param Factory $factory
* @return $object
*/
public function validator($factory)
{
$landing_page_id = $this->route('landing_pages');
$campaign_id = Landing_Page::where('id', $landing_page_id)->first()->campaign->id;
// Validate email users are part of campaign
$validation = $factory->make($this->all(), $this->rules());
$validation->each('add_user_email_notification', ['exists:user_has_roles,user_id,campaign_id,' . $campaign_id]);
return $validation;
}