本文整理汇总了PHP中SplObjectStorage::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP SplObjectStorage::offsetSet方法的具体用法?PHP SplObjectStorage::offsetSet怎么用?PHP SplObjectStorage::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplObjectStorage
的用法示例。
在下文中一共展示了SplObjectStorage::offsetSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach
/**
* @param HandlerInterface $handler
* @param array $categories
*/
public function attach(HandlerInterface $handler, array $categories = array())
{
if ($this->handlers->contains($handler)) {
$handlerCategories = $this->handlers->offsetGet($handler);
$this->handlers->offsetSet($handler, array_merge((array) $handlerCategories, $categories));
} else {
$this->handlers->attach($handler, $categories);
}
}
示例2: getObservers
/**
* Returns list of observers for subject
*
* @param SubjectInterface $s
*
* @return \SplObjectStorage|ObserverInterface[]
*/
protected function getObservers(SubjectInterface $s)
{
if ($this->perSubjectObservers === null) {
$this->perSubjectObservers = new \SplObjectStorage();
}
if (!isset($this->perSubjectObservers[$s])) {
$observers = new \SplObjectStorage();
$this->perSubjectObservers->offsetSet($s, $observers);
} else {
$observers = $this->perSubjectObservers->offsetGet($s);
}
return $observers;
}
示例3: offsetSet
public function offsetSet($index, $testResult)
{
$indexObj = $index;
$this->validateIndex($index);
$this->validateValue($testResult);
// Decrement counters when replacing existing item
if (parent::offsetExists($index)) {
$oldResult = parent::offsetGet($index);
if ($oldResult instanceof Success) {
$this->countSuccess--;
} elseif ($oldResult instanceof Failure) {
$this->countFailure--;
} elseif ($oldResult instanceof Warning) {
$this->countWarning--;
} else {
$this->countUnknown--;
}
}
parent::offsetSet($index, $testResult);
// Increment counters
if ($testResult instanceof Success) {
$this->countSuccess++;
} elseif ($testResult instanceof Failure) {
$this->countFailure++;
} elseif ($testResult instanceof Warning) {
$this->countWarning++;
} else {
$this->countUnknown++;
}
}
示例4: offsetSet
/**
* @param object $object
* @param null $data
*/
public function offsetSet($object, $data = null)
{
if (!$object instanceof Date) {
throw new \InvalidArgumentException("DateObjectStorage can store only date objects");
}
parent::offsetSet($object, $data);
// TODO: Change the autogenerated stub
}
示例5: setData
/**
* setData()
*
* sets the data set of a given route
*
* @param \Naquadria\Components\Routing\Route $route
* @param mixed $data
* @throws \Naquadria\Components\Routing\Exceptions\RouteNotFoundException
*/
public function setData(Route $route, $data)
{
if (!parent::contains($route)) {
throw new RouteNotFoundException('Unknown route instance');
}
$current = parent::offsetGet($route);
$current['data'] = $data;
parent::offsetSet($route, $current);
}
示例6: addSitemap
/**
* @param \Sitemapper\SitemapInterface $sitemap
*/
public function addSitemap(SitemapInterface $sitemap)
{
$this->boot();
$this->sitemaps->attach($sitemap);
$index = $this->sitemaps->count();
$sitemap->setLocation($this->getLocation($index));
$this->sitemaps->offsetSet($sitemap, $index);
$this->indexSitemap->addSitemap($sitemap);
}
示例7: eventsToPublishOn
private function eventsToPublishOn(EventMessageInterface $event, EventBusInterface $eventBus)
{
if (!$this->eventsToPublish->contains($eventBus)) {
$this->eventsToPublish->attach($eventBus, array($event));
return;
}
$events = $this->eventsToPublish->offsetGet($eventBus);
$events[] = $event;
$this->eventsToPublish->offsetSet($eventBus, $events);
}
示例8: unsubscribe
private function unsubscribe(WebSocketConnection $connection)
{
/** @var WebSocketObservableTable $table */
$table = $this->connectionTableMap->offsetGet($connection);
$table->removeConnection($connection);
$this->connectionTableMap->offsetUnset($connection);
$connections = $this->getConnectionsSubscribedToTable($table)->filter(function (WebSocketConnection $c) use($connection) {
return $c !== $connection;
});
if (count($connections)) {
$this->tableConnectionMap->offsetSet($table, $connections);
} else {
$this->tableConnectionMap->offsetUnset($table);
}
}
示例9: offsetSet
/**
* Sets the value for the passed offset.
*
* @param int $offset The offset to set value for
* @param mixed $value The value to write
*
* @author Benjamin Carl <opensource@clickalicious.de>
*
* @return mixed The result of the operation
*/
public function offsetSet($offset, $value)
{
foreach ($this->observer as $observer) {
if (strtolower($observer->getName()) === strtolower($offset)) {
$this->observer->offsetSet($value);
}
}
}
示例10: addServiceInlinedDefinitionsSetup
/**
* Generates the inline definition setup.
*
* @param string $id
* @param Definition $definition
*
* @return string
*
* @throws ServiceCircularReferenceException when the container contains a circular reference
*/
private function addServiceInlinedDefinitionsSetup($id, $definition)
{
$this->referenceVariables[$id] = new Variable('instance');
$code = '';
$processed = new \SplObjectStorage();
foreach ($this->getInlinedDefinitions($definition) as $iDefinition) {
if ($processed->contains($iDefinition)) {
continue;
}
$processed->offsetSet($iDefinition);
if (!$this->hasReference($id, $iDefinition->getMethodCalls(), true) && !$this->hasReference($id, $iDefinition->getProperties(), true)) {
continue;
}
// if the instance is simple, the return statement has already been generated
// so, the only possible way to get there is because of a circular reference
if ($this->isSimpleInstance($id, $definition)) {
throw new ServiceCircularReferenceException($id, array($id));
}
$name = (string) $this->definitionVariables->offsetGet($iDefinition);
$code .= $this->addServiceMethodCalls(null, $iDefinition, $name);
$code .= $this->addServiceProperties(null, $iDefinition, $name);
$code .= $this->addServiceConfigurator(null, $iDefinition, $name);
}
if ('' !== $code) {
$code .= "\n";
}
return $code;
}
示例11: offsetSet
public function offsetSet($object, $info)
{
$this->initialize();
parent::offsetSet($object, $info);
}
示例12: offsetSet
/**
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
*/
public function offsetSet($object, $data = null)
{
@trigger_error('The ' . __METHOD__ . ' method is deprecated as of 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
parent::offsetSet($object, $data);
}
示例13: addServiceInlinedDefinitionsSetup
/**
* Generates the inline definition setup.
*
* @param string $id
* @param Definition $definition
* @return string
*/
private function addServiceInlinedDefinitionsSetup($id, $definition)
{
$this->referenceVariables[$id] = new Variable('instance');
$code = '';
$processed = new \SplObjectStorage();
foreach ($this->getInlinedDefinitions($definition) as $iDefinition) {
if ($processed->contains($iDefinition)) {
continue;
}
$processed->offsetSet($iDefinition);
if (!$this->hasReference($id, $iDefinition->getMethodCalls())) {
continue;
}
if ($iDefinition->getMethodCalls()) {
$code .= $this->addServiceMethodCalls(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition));
}
if ($iDefinition->getConfigurator()) {
$code .= $this->addServiceConfigurator(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition));
}
}
if ('' !== $code) {
$code .= "\n";
}
return $code;
}
示例14: offsetSet
/**
* @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0.
*/
public function offsetSet($object, $data = null)
{
$this->triggerDeprecation(__METHOD__);
parent::offsetSet($object, $data);
}
示例15: offsetSet
/**
* @param object $index
* @param mixed|null $checkResult
* @link http://php.net/manual/en/splobjectstorage.offsetset.php
*/
public function offsetSet($index, $checkResult)
{
$this->validateIndex($index);
$this->validateValue($checkResult);
// Decrement counters when replacing existing item
if (parent::offsetExists($index)) {
$this->updateCounters(parent::offsetGet($index), -1);
}
// Store the new instance
parent::offsetSet($index, $checkResult);
// Increment counters
$this->updateCounters($checkResult, 1);
}