当前位置: 首页>>代码示例>>PHP>>正文


PHP SplObjectStorage::attach方法代码示例

本文整理汇总了PHP中SplObjectStorage::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP SplObjectStorage::attach方法的具体用法?PHP SplObjectStorage::attach怎么用?PHP SplObjectStorage::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplObjectStorage的用法示例。


在下文中一共展示了SplObjectStorage::attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addValidator

 /**
  * Adds a new validator to the conjunction.
  *
  * @param \TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator The validator that should be added
  * @return void
  * @api
  */
 public function addValidator(\TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator)
 {
     if ($validator instanceof ObjectValidatorInterface) {
         $validator->setValidatedInstancesContainer = $this->validatedInstancesContainer;
     }
     $this->validators->attach($validator);
 }
开发者ID:nxpthx,项目名称:FLOW3,代码行数:14,代码来源:AbstractCompositeValidator.php

示例2: attach

 /**
  * 添加观察者
  * @param \SplObserver $observer
  */
 function attach(\SplObserver $observer)
 {
     if ($this->_observers == null) {
         $this->_observers = new \SplObjectStorage();
     }
     $this->_observers->attach($observer);
 }
开发者ID:matyhtf,项目名称:swoole_framework,代码行数:11,代码来源:Observer.php

示例3: __construct

 public function __construct(array $users = array())
 {
     $this->users = new SplObjectStorage();
     foreach ($users as $user) {
         $this->users->attach(new User(new UserId($user['id']), new Name($user['name']), new EmailAddress($user['email'])));
     }
 }
开发者ID:kolah,项目名称:recruitment,代码行数:7,代码来源:UserRepository.php

示例4: __construct

 public function __construct(\SplObjectStorage $fieldGroups, \SplObjectStorage $fields, array $fieldGroupsArray = array(), array $fieldsArray = array())
 {
     $this->fields = $fields;
     $this->fieldGroups = $fieldGroups;
     if (!empty($fieldsArray)) {
         foreach ($fieldsArray as $field) {
             if (!$field instanceof AbstractFieldProxy) {
                 $message = "One or more of the fields you have passed to ";
                 $message .= get_class($this);
                 $message .= " does not extend the FieldProxy class.";
                 throw new \RuntimeException($message);
             }
             $this->fields->attach($field);
         }
     }
     if (!empty($fieldGroupsArray)) {
         foreach ($fieldGroupsArray as $fieldGroup) {
             if (!$fieldGroup instanceof AbstractFieldGroup) {
                 $message = "One or more of the fields you have passed to ";
                 $message .= get_class($this);
                 $message .= " does not extend the FieldGroup class.";
                 throw new \RuntimeException($message);
             }
             $this->fieldGroups->attach($fieldGroup);
         }
     }
 }
开发者ID:flexpress,项目名称:component-acf,代码行数:27,代码来源:Helper.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 public function execute(ImmediateInterface $immediate)
 {
     if (!$this->immediates->contains($immediate)) {
         $this->queue->push($immediate);
         $this->immediates->attach($immediate);
     }
 }
开发者ID:kanzuka,项目名称:icicle,代码行数:10,代码来源:ImmediateManager.php

示例6: add

 /**
  * @param ConnectionInterface $connection
  */
 public function add(ConnectionInterface $connection)
 {
     Debug::line(__CLASS__ . ': Add [');
     $this->storage->attach($connection);
     Debug::line('-- WebSocket connection added');
     Debug::line(']');
 }
开发者ID:iiifx,项目名称:websocket-connect,代码行数:10,代码来源:WebSocketConnections.php

示例7: get

 public function get()
 {
     $storage = new \SplObjectStorage();
     $storage->attach($this->exampleA);
     $storage->attach($this->exampleB);
     return $storage;
 }
开发者ID:cheevauva,项目名称:container,代码行数:7,代码来源:ExampleF.php

示例8:

 function it_should_process_the_tiebreaker_round_and_return_the_loser()
 {
     // less
     $answer1 = json_decode('{"answer":0.019,"token":"token-goes-here"}');
     $answer2 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // more
     $answer3 = json_decode('{"answer":0.021,"token":"token-goes-here"}');
     $answer4 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // equal
     $answer5 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     $answer6 = json_decode('{"answer":0.020,"token":"token-goes-here"}');
     // create Dummy objects
     $clients = new \SplObjectStorage();
     $conn1 = new \StdClass();
     $conn2 = new \StdClass();
     // less - answer1 wins
     $clients->attach($conn1, $answer1);
     $clients->attach($conn2, $answer2);
     $this->processTiebreaker($clients)->shouldReturn($conn2);
     // more - answer2 wins
     $clients->attach($conn1, $answer3);
     $clients->attach($conn2, $answer4);
     $this->processTiebreaker($clients)->shouldReturn($conn1);
     // equal - answer1 wins ( I know its cheating a little )
     $clients->attach($conn1, $answer5);
     $clients->attach($conn2, $answer6);
     $this->processTiebreaker($clients)->shouldReturn($conn2);
 }
开发者ID:Techbot,项目名称:ratchet-based-game,代码行数:28,代码来源:RoundProcessorSpec.php

示例9: getMultiplePairsExtensions

 public static function getMultiplePairsExtensions()
 {
     $extensions = new \SplObjectStorage();
     $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/topic'), 'Conformance Testing');
     $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/color'), array('model' => 'RGB', 'value' => '#FFFFFF'));
     $extensions->attach(IRI::fromString('http://id.tincanapi.com/extension/starting-position'), 1);
     return new Extensions($extensions);
 }
开发者ID:php-xapi,项目名称:test-fixtures,代码行数:8,代码来源:ExtensionsFixtures.php

示例10: addDefaultScope

 /**
  * Adds scope to default scopes
  *
  * @param IScope $scope
  */
 public function addDefaultScope(IScope $scope)
 {
     if (!$this->defaultScopes->contains($scope)) {
         $this->defaultScopes->attach($scope);
     } else {
         throw new \InvalidArgumentException("Scope '{$scope->getId()}' is already registered as default scope.");
     }
 }
开发者ID:michalkvasnicak,项目名称:oauth2-server,代码行数:13,代码来源:ScopeResolver.php

示例11: spl_object_storage_can_be_used_like_a_set

 public function spl_object_storage_can_be_used_like_a_set()
 {
     $spl_storage = new SplObjectStorage();
     $an_object = new ClassWithProperties();
     $spl_storage->attach($an_object);
     $spl_storage->attach($an_object);
     assert_that(count($spl_storage))->is_identical_to(__);
 }
开发者ID:mtvillwock,项目名称:php-inferno,代码行数:8,代码来源:Fraud.php

示例12: where

 public function where(CompilableInterface $expr, $operator = 'AND')
 {
     if (!in_array($operator, ['AND', 'OR'])) {
         throw new InvalidArgumentException(sprintf("The operator must be one of: AND, OR, but got '%s'", $operator));
     }
     $this->where->attach($expr, $operator);
     return $this;
 }
开发者ID:kyoya-de,项目名称:simple-yql,代码行数:8,代码来源:Select.php

示例13: then

 public function then(callable $onFulfilled = null, callable $onRejected = null)
 {
     $child = new Promise($this->promise);
     $this->onFulfilled->attach($child, $onFulfilled);
     $this->onRejected->attach($child, $onRejected);
     $this->children[] = $child;
     return $child;
 }
开发者ID:bugadani,项目名称:monad,代码行数:8,代码来源:Pending.php

示例14: testGetExceptions

 public function testGetExceptions()
 {
     $exceptions = new \SplObjectStorage();
     $exceptions->attach(new \Exception());
     $exceptions->attach(new \Exception());
     $result = new Result('export', new \DateTime(), new \DateTime(), 10, $exceptions);
     $this->assertSame($exceptions, $result->getExceptions());
 }
开发者ID:repat,项目名称:data-import,代码行数:8,代码来源:ResultTest.php

示例15: getValues

 /**
  * {@inheritdoc}
  */
 public function getValues() : PromiseInterface
 {
     $counters = $this->infoProvider->getCounters();
     $storage = new \SplObjectStorage();
     $storage->attach(new Metric('current_read_streams', (double) $counters['streams']['read']['current']));
     $storage->attach(new Metric('current_write_streams', (double) $counters['streams']['write']['current']));
     return resolve($storage);
 }
开发者ID:WyriHaximus,项目名称:reactphp-event-loop-inspector-phunin-node-plugin,代码行数:11,代码来源:Streams.php


注:本文中的SplObjectStorage::attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。