本文整理汇总了PHP中SplObjectStorage::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP SplObjectStorage::offsetGet方法的具体用法?PHP SplObjectStorage::offsetGet怎么用?PHP SplObjectStorage::offsetGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplObjectStorage
的用法示例。
在下文中一共展示了SplObjectStorage::offsetGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onNext
/**
* @param EventInterface $value
* @throws \Exception
*/
public function onNext($value)
{
$uri = $value->getName();
// TODO add route cache
foreach ($this->routing as $subject) {
/* @var ReplaySubject $subject */
$routes = $this->routing->offsetGet($subject);
foreach ($routes as $data) {
if (!preg_match($data['regex'], $uri, $matches)) {
continue;
}
$vars = [];
$i = 0;
foreach ($data['routeMap'] as $varName) {
$vars[$varName] = $matches[++$i];
}
$labels = $value->getLabels();
$labels = array_merge($labels, $vars);
$value->setLabels($labels);
$subject->onNext($value);
return;
}
}
throw new \Exception("not found");
}
示例2: getHelperForEntityType
/**
* @param \AGmakonts\STL\String\Text $entityType
*
* @return AbstractRepository
* @throws \AGmakonts\DddBricks\Repository\Exception\HelperException
*/
protected function getHelperForEntityType(Text $entityType)
{
if (FALSE === $this->_helpers->offsetExists($entityType)) {
throw new HelperException(HelperException::HELPER_UNKNOWN);
}
return $this->_helpers->offsetGet($entityType);
}
示例3: fetch
/**
* @param Peer $peer
* @return PeerState
*/
public function fetch(Peer $peer)
{
if (!$this->storage->contains($peer)) {
$state = $this->createState($peer);
} else {
$state = $this->storage->offsetGet($peer);
}
return $state;
}
示例4: 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);
}
}
示例5: finish
/**
* {@inheritdoc}
*/
public function finish(RequestInterface $request, ResponseInterface $response)
{
if ($this->isTerminableKernel) {
list($sfRequest, $sfResponse) = $this->requestMapping->offsetGet($request);
$this->requestMapping->detach($request);
$kernel = $this->kernel;
/* @var $kernel TerminableInterface */
$kernel->terminate($sfRequest, $sfResponse);
}
}
示例6: onMessage
/**
* Triggered when a client sends data through the socket
* @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
* @param string $msg The message received
* @throws \Exception
*
* expects:
* { 'cmd': "identifier", 'payload': {<data>}}
* could use bson instead
*/
function onMessage(ConnectionInterface $from, $msg)
{
$from = $this->connections->offsetGet($from);
if (null === ($json = @json_decode($msg, true))) {
throw new JsonException();
}
if (!is_array($json)) {
throw new Exception("Invalid message");
}
$this->wrapped->onMessage($from, $json);
}
示例7: 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;
}
示例8: save
/**
* @return bool
*/
public function save()
{
$pkField = self::getAutoIncrementField();
if ($this->isNewRecord()) {
if (($id = $this->insertGetId((array) $this)) > 0) {
$this->{$pkField} = $id;
return true;
}
return false;
} else {
$original = unserialize(static::$modelStorage->offsetGet($this));
return 1 == $this->where($pkField . '=?', array($original[$pkField]))->update((array) $this);
}
}
示例9: getValidationGroups
/**
* Returns the validation groups of the given form.
*
* @param FormInterface $form The form.
*
* @return array The validation groups.
*/
private static function getValidationGroups(FormInterface $form)
{
$root = $form->getRoot();
// Determine the clicked button of the complete form tree
if (!static::$clickedButtons->contains($root)) {
// Only call findClickedButton() once to prevent an exponential
// runtime
// https://github.com/symfony/symfony/issues/8317
static::$clickedButtons->attach($root, self::findClickedButton($root));
}
$button = static::$clickedButtons->offsetGet($root);
if (null !== $button) {
$groups = $button->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
}
do {
$groups = $form->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
$form = $form->getParent();
} while (null !== $form);
return array(Constraint::DEFAULT_GROUP);
}
示例10: evaluate
/**
* Call the view helper associated with this object.
*
* First, it evaluates the arguments of the view helper.
*
* If the view helper implements \TYPO3\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface,
* it calls setChildNodes(array childNodes) on the view helper.
*
* Afterwards, checks that the view helper did not leave a variable lying around.
*
* @param RenderingContextInterface $renderingContext
* @return object evaluated node after the view helper has been called.
*/
public function evaluate(RenderingContextInterface $renderingContext)
{
if ($this->viewHelpersByContext->contains($renderingContext)) {
$viewHelper = $this->viewHelpersByContext->offsetGet($renderingContext);
$viewHelper->resetState();
} else {
$viewHelper = clone $this->uninitializedViewHelper;
$this->viewHelpersByContext->attach($renderingContext, $viewHelper);
}
$evaluatedArguments = array();
if (count($viewHelper->prepareArguments())) {
/** @var $argumentDefinition ArgumentDefinition */
foreach ($viewHelper->prepareArguments() as $argumentName => $argumentDefinition) {
if (isset($this->arguments[$argumentName])) {
/** @var $argumentValue NodeInterface */
$argumentValue = $this->arguments[$argumentName];
$evaluatedArguments[$argumentName] = $argumentValue->evaluate($renderingContext);
} else {
$evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue();
}
}
}
$viewHelper->setArguments($evaluatedArguments);
$viewHelper->setViewHelperNode($this);
$viewHelper->setRenderingContext($renderingContext);
if ($viewHelper instanceof ChildNodeAccessInterface) {
$viewHelper->setChildNodes($this->childNodes);
}
$output = $viewHelper->initializeArgumentsAndRender();
return $output;
}
示例11: saveSitemap
/**
* @param \Sitemapper\SitemapInterface $sitemap
*/
protected function saveSitemap(SitemapInterface $sitemap)
{
if ($this->sitemaps->contains($sitemap)) {
$index = $this->sitemaps->offsetGet($sitemap);
$this->saveFile($this->getPathname($index), $sitemap->getOutput());
$this->savedSitemaps->attach($sitemap);
}
}
示例12: getConnectionsSubscribedToTable
/**
* @param WebSocketObservableTable $table
*
* @return Vector|WebSocketConnection[]
*/
private function getConnectionsSubscribedToTable(WebSocketObservableTable $table)
{
try {
return $this->tableConnectionMap->offsetGet($table);
} catch (\Exception $e) {
return new Vector();
}
}
示例13: getData
/**
* getData()
*
* gets the data set of a given route
*
* @param \Naquadria\Components\Routing\Route $route
* @throws \Naquadria\Components\Routing\Exceptions\RouteNotFoundException
* @return mixed
*/
public function getData(Route $route)
{
if (!parent::contains($route)) {
throw new RouteNotFoundException('Unknown route instance');
}
$current = parent::offsetGet($route);
return $current['data'];
}
示例14: handleItems
public function handleItems($object, array $items, SerializationContext $context)
{
if ($this->deferredData->contains($object)) {
$items = array_merge($this->deferredData->offsetGet($object), $items);
$this->deferredData->detach($object);
}
$parentObjectInlining = $this->getParentObjectInlining($object, $context);
if (null === $parentObjectInlining) {
return $items;
}
if ($this->deferredData->contains($parentObjectInlining)) {
$items = array_merge($items, $this->deferredData->offsetGet($parentObjectInlining));
}
// We need to defer the links serialization to the $parentObject
$this->deferredData->attach($parentObjectInlining, $items);
return array();
}
示例15: flush
/**
* Send data to database
*
* @return \Sokil\Mongo\Persistence
*/
public function flush()
{
/** @var $document \Sokil\Mongo\Document */
foreach ($this->_pool as $document) {
switch ($this->_pool->offsetGet($document)) {
case self::STATE_SAVE:
$document->save();
break;
case self::STATE_REMOVE:
// delete document form db
$document->delete();
// remove link form pool
$this->detach($document);
break;
}
}
return $this;
}