本文整理汇总了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);
}
示例2: attach
/**
* 添加观察者
* @param \SplObserver $observer
*/
function attach(\SplObserver $observer)
{
if ($this->_observers == null) {
$this->_observers = new \SplObjectStorage();
}
$this->_observers->attach($observer);
}
示例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'])));
}
}
示例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);
}
}
}
示例5: execute
/**
* {@inheritdoc}
*/
public function execute(ImmediateInterface $immediate)
{
if (!$this->immediates->contains($immediate)) {
$this->queue->push($immediate);
$this->immediates->attach($immediate);
}
}
示例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(']');
}
示例7: get
public function get()
{
$storage = new \SplObjectStorage();
$storage->attach($this->exampleA);
$storage->attach($this->exampleB);
return $storage;
}
示例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);
}
示例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);
}
示例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.");
}
}
示例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(__);
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}