當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Factory類代碼示例

本文整理匯總了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();
 }
開發者ID:nemiah,項目名稱:fheME,代碼行數:7,代碼來源:mxCalGUI.class.php

示例2: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config_authentification_form');
     $factory = new Factory();
     $form = $factory->createForm($config);
     return $form;
 }
開發者ID:sanPgut,項目名稱:Exos-ZFPhp,代碼行數:7,代碼來源:AuthentificationFormFactory.php

示例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);
 }
開發者ID:praxigento,項目名稱:mobi_mod_mage2_core,代碼行數:25,代碼來源:Factory_Test.php

示例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);
 }
開發者ID:barryosull,項目名稱:bounded-context-sample,代碼行數:7,代碼來源:Handler.php

示例5: createNew

 public function createNew()
 {
     $F = new Factory("TinkerforgeBricklet");
     $F->sA("TinkerforgeBrickletTinkerforgeID", $this->getID());
     $F->store();
     echo $this->bricklets();
 }
開發者ID:nemiah,項目名稱:fheME,代碼行數:7,代碼來源:TinkerforgeGUI.class.php

示例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;
 }
開發者ID:henrytung,項目名稱:Bodie-CRM,代碼行數:13,代碼來源:StoreLandingPageRequest.php

示例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);
 }
開發者ID:nickl-,項目名稱:Rest,代碼行數:8,代碼來源:FactoryTest.php

示例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);
 }
開發者ID:phpfluent,項目名稱:callback,代碼行數:8,代碼來源:FactoryTest.php

示例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);
 }
開發者ID:phaniso,項目名稱:phpmonitor,代碼行數:8,代碼來源:JsonTest.php

示例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;
 }
開發者ID:mothership-ec,項目名稱:cog,代碼行數:70,代碼來源:ContentBuilder.php

示例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();
 }
開發者ID:michelezamuner,項目名稱:groph-php-simple,代碼行數:9,代碼來源:Collection.php

示例12: main

 public function main()
 {
     $myShapes = array();
     $myFactory = new Factory();
     $myShapes = $myFactory->getShapes();
     foreach ($myShapes as $myShape) {
         $myShape->draw();
     }
 }
開發者ID:nouka,項目名稱:DesignPatternsExplained,代碼行數:9,代碼來源:10-3.php

示例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());
 }
開發者ID:sokil,項目名稱:php-rest,代碼行數:9,代碼來源:FactoryBehaviorTest.php

示例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;
 }
開發者ID:evgenykireev,項目名稱:wp-facebook-import,代碼行數:16,代碼來源:Service.php

示例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;
 }
開發者ID:henrytung,項目名稱:Bodie-CRM,代碼行數:15,代碼來源:StoreRequest.php


注:本文中的Factory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。