本文整理汇总了PHP中SplObjectStorage::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP SplObjectStorage::contains方法的具体用法?PHP SplObjectStorage::contains怎么用?PHP SplObjectStorage::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplObjectStorage
的用法示例。
在下文中一共展示了SplObjectStorage::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeHandler
/**
* Remove the given log message handler if it is registered.
*
* @param LogHandler $handler
*/
public function removeHandler(LogHandler $handler)
{
if ($this->handlers->contains($handler)) {
$this->handlers->detach($handler);
$this->enabled = $this->handlers->count() ? true : false;
}
}
示例2: isVisiting
public function isVisiting($object)
{
if (!is_object($object)) {
return false;
}
return $this->visitingSet->contains($object);
}
示例3: isVisiting
public function isVisiting($object)
{
if (!is_object($object)) {
throw new LogicException('Expected object but got ' . gettype($object) . '. Do you have the wrong @Type mapping or could this be a Doctrine many-to-many relation?');
}
return $this->visitingSet->contains($object);
}
示例4: findConnection
/**
* @param AbstractSQLConnection $connection
*
* @return bool
*/
public function findConnection(AbstractSQLConnection $connection)
{
if ($this->storage->contains($connection)) {
return true;
}
return false;
}
示例5: removeComparison
/**
* Removes the given comparison
*
* @param PropertyComparisonInterface $comparison
* @throws Exception\InvalidComparisonException if the given comparison is not in the list
* @return $this
*/
public function removeComparison($comparison)
{
if (!$this->comparisons->contains($comparison)) {
throw new InvalidComparisonException('Can not remove given comparison because it is not in the list', 1409600320);
}
$this->comparisons->detach($comparison);
}
示例6: getBlockId
protected function getBlockId(Block $block)
{
if (!$this->blocks->contains($block)) {
$this->blocks[$block] = count($this->blocks) + 1;
}
return $this->blocks[$block];
}
示例7: removeValidator
/**
* Removes the specified validator.
*
* @param \TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator The validator to remove
* @throws \TYPO3\FLOW3\Validation\Exception\NoSuchValidatorException
* @api
*/
public function removeValidator(\TYPO3\FLOW3\Validation\Validator\ValidatorInterface $validator)
{
if (!$this->validators->contains($validator)) {
throw new \TYPO3\FLOW3\Validation\Exception\NoSuchValidatorException('Cannot remove validator because its not in the conjunction.', 1207020177);
}
$this->validators->detach($validator);
}
示例8: attachHandler
/**
* @return \Nano\Event\Manager
* @param \Nano\Event\Handler $handler
*/
public function attachHandler(\Nano\Event\Handler $handler)
{
if ($this->handlers->contains($handler)) {
return $this;
}
$this->handlers->attach($handler);
return $this;
}
示例9: addListener
/**
* @inheritDoc
*/
public function addListener(ListenerInterface ...$listeners)
{
foreach ($listeners as $listener) {
if (!$this->listeners->contains($listener)) {
$this->listeners->attach($listener);
}
}
}
示例10: detach
/**
* Detach a autoloadiable
*
* @param \Attw\Autoloader\AutoloadableInterface
*/
public function detach(AutoloadableInterface $autoloadable)
{
if (!$this->autoloadables->contains($autoloadable)) {
throw new \Exception('The autoload hasn\'t been duplicated');
}
$this->autoloadables->detach($autoloadable);
spl_autoload_unregister($autoloadable->getCallable());
}
示例11: add
/**
* @param FormInterface $child
* @return FormInterface
*/
public function add(FormInterface $child)
{
if (FALSE === $this->children->contains($child)) {
$this->children->attach($child);
$child->setParent($this);
}
return $this;
}
示例12: getLocale
/**
* {@inheritdoc}
*/
public function getLocale() {
$request = $this->requestStack->getCurrentRequest();
if (!$this->locales->contains($request)) {
$this->locales[$request] = $this->chainResolver->resolve();
}
return $this->locales[$request];
}
示例13: 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.");
}
}
示例14: removeBackend
/**
* Runs the close() method of a backend and removes the backend
* from the logger.
*
* @param Backend\BackendInterface $backend The backend to remove
* @return void
* @throws NoSuchBackendException if the given backend is unknown to this logger
* @api
*/
public function removeBackend(Backend\BackendInterface $backend)
{
if (!$this->backends->contains($backend)) {
throw new NoSuchBackendException('Backend is unknown to this logger.', 1229430381);
}
$backend->close();
$this->backends->detach($backend);
}
示例15: 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;
}