offsetExists example

 elseif ($value instanceof IteratorAggregate) {
            // Note: getIterator() returns a Traversable, not an Iterator             // thus rewind() and valid() methods may not be present             return iterator_count($value->getIterator());
        } elseif ($value instanceof Iterator) {
            return iterator_count($value);
        } elseif ($value instanceof PDOStatement) {
            return $value->rowCount();
        } elseif ($value instanceof Traversable) {
            return iterator_count($value);
        } elseif ($value instanceof ArrayAccess) {
            if ($value->offsetExists(0)) {
                return 1;
            }
        } elseif (is_object($value)) {
            return count($value);
        }
        return 0;
    }

    /** * runtime error not matching capture tags * */
public function __construct(array $values$message) {
    $this->message = $message;
    parent::__construct($values);
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function offsetExists($offset) {
    @trigger_error($this->message, E_USER_DEPRECATED);
    return parent::offsetExists($offset);
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function offsetGet($offset) {
    @trigger_error($this->message, E_USER_DEPRECATED);
    return parent::offsetGet($offset);
  }

  
$username = $auth->getIdentity()->username;
        $password = $this->Request()->get('password');

        if (empty($username) || empty($password)) {
            $this->View()->assign(['success' => false]);

            return;
        }

        $result = $auth->isPasswordValid($username$password);

        if ($this->container->get('backendsession')->offsetExists('passwordVerified')) {
            $this->container->get('backendsession')->offsetUnset('passwordVerified');
        }

        // Set a flag in the backend session indicating that the password has been verified successfully         if ($result) {
            $this->container->get('backendsession')->offsetSet('passwordVerified', true);
        }

        $this->View()->assign('success', $result);
    }
}
public function postDispatch()
    {
        $this->session->set('sBasketCurrency', Shopware()->Shop()->getCurrency()->getId());
        $this->session->set('sBasketQuantity', $this->basket->sCountBasket());
        $amount = $this->basket->sGetAmount();
        $this->session->set('sBasketAmount', empty($amount) ? 0 : array_shift($amount));

        if (($messageType = $this->Request()->query->get('removeMessage')) && $messageType === 'voucher') {
            $this->session->offsetUnset('sBasketVoucherRemovedInCart');
        }

        if ($this->session->offsetExists('sBasketVoucherRemovedInCart')) {
            $this->View()->assign('sBasketVoucherRemovedInCart', true);
        }
    }

    /** * Forward to cart or confirm action depending on user state * * @return void */
    public function indexAction()
    {
        
$this->View()->assign('_POST', Shopware()->System()->_POST->toArray());

        if (!isset(Shopware()->System()->_POST['newsletter'])) {
            return;
        }

        if (Shopware()->System()->_POST['subscribeToNewsletter'] != 1) {
            // Unsubscribe user             $this->View()->assign('sStatus', Shopware()->Modules()->Admin()->sNewsletterSubscription(Shopware()->System()->_POST['newsletter'], true));

            $session = $this->container->get('session');
            if ($session->offsetExists('sNewsletter')) {
                $session->offsetSet('sNewsletter', false);
            }

            return;
        }

        $config = $this->container->get(Shopware_Components_Config::class);
        $noCaptchaAfterLogin = $config->get('noCaptchaAfterLogin');
        // redirect user if captcha is active and request is sent from the footer         if (strtolower($config->get('newsletterCaptcha')) !== 'nocaptcha'
            && $this->Request()->getPost('redirect') !== null
            
/** * Returns the instance of the passed plugin name. * * @param string $name * @param bool $throwException * * @return Enlight_Plugin_Bootstrap|null */
    public function get($name$throwException = true)
    {
        if (!$this->plugins->offsetExists($name)) {
            $this->load($name$throwException);
        }

        $plugin = $this->plugins->offsetGet($name);
        if ($plugin instanceof Enlight_Plugin_Bootstrap) {
            return $plugin;
        }

        if ($throwException) {
            throw new Enlight_Exception('Plugin "' . $name . '" in namespace "' . $this->getName() . '" not found');
        }

        

    #[ReturnTypeWillChange]     public function offsetGet($offset)
    {
        if ($this->offsetExists($offset)) {
            throw new InvalidArgumentException(sprintf('Undefined offset "%s".', $offset));
        }

        return $offset === 'expire' ? $this->expires : $this->{$offset};
    }

    /** * Offset to set. * * @param string $offset * @param bool|int|string $value * * @throws LogicException */
$this->container = $container;
    }

    /** * @param string $locale * * @throws RuntimeException */
    public function updateLocaleSettings($locale)
    {
        $serviceName = 'database.dump_iterator_' . strtolower($locale);
        if ($this->container->offsetExists($serviceName)) {
            $dump = $this->container->offsetGet($serviceName);
            foreach ($dump as $row) {
                $this->connection->query($row);
            }
        }
    }
}
try {
            $this->sendMail($variables);
        } catch (Exception $e) {
            $confirmMailDeliveryFailed = true;
            $email = $this->sUserData['additional']['user']['email'];
            $this->logOrderMailException($e$orderNumber$email);
        }

        // Check if voucher is affected         $this->sTellFriend();

        if ($this->getSession()->offsetExists('sOrderVariables')) {
            $variables = $this->getSession()->offsetGet('sOrderVariables');
            $variables['sOrderNumber'] = $orderNumber;
            $variables['confirmMailDeliveryFailed'] = $confirmMailDeliveryFailed;
            $this->getSession()->offsetSet('sOrderVariables', $variables);
        }

        $this->eventManager->notify('Shopware_Modules_Order_SaveOrder_OrderCreated', [
            'subject' => $this,
            'details' => $this->sBasketData[CartKey::POSITIONS],
            'orderId' => $orderID,
            'orderNumber' => $orderNumber,
        ]);

        return null;
    }

    /** * Returns plugin name * * @return string */
    public function getLabel()
    {
        return $this->info instanceof Enlight_Config && $this->Info()->offsetExists('label') ? $this->Info()->get('label') : $this->getName();
    }

    /** * Returns plugin name */
    final public function getName(): ?string
    {
        return $this->name;
    }

    /** * Returns plugin source */
/** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function offsetExists($offset) {
    // For consistency with what happens in get(), we force offsetExists() to     // be TRUE for delta 0.     if ($offset === 0) {
      return TRUE;
    }
    return parent::offsetExists($offset);
  }

  /** * {@inheritdoc} */
  public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) {
    if ($operation === 'edit') {
      // Only users with administer comments permission can edit the comment       // status field.       $result = AccessResult::allowedIfHasPermission($account ?: \Drupal::currentUser(), 'administer comments');
      return $return_as_object ? $result : $result->isAllowed();
    }


    /** * @throws \InvalidArgumentException */
    private function discoverNamespace(\DOMXPath $domxpath, string $prefix): ?string
    {
        if (\array_key_exists($prefix$this->namespaces)) {
            return $this->namespaces[$prefix];
        }

        if ($this->cachedNamespaces->offsetExists($prefix)) {
            return $this->cachedNamespaces[$prefix];
        }

        // ask for one namespace, otherwise we'd get a collection with an item for each node         $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix));

        return $this->cachedNamespaces[$prefix] = ($node = $namespaces->item(0)) ? $node->nodeValue : null;
    }

    private function findNamespacePrefixes(string $xpath): array
    {
        
continue;
            }
            $sortData['property'] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $sortData['property']));
            $customSorting[] = $sortData;
        }

        return array_merge($prioritySorting$customSorting$fallbackSorting);
    }

    private function getAccessToken(): ?AccessTokenStruct
    {
        if (!$this->get('backendsession')->offsetExists('store_token')) {
            return null;
        }

        if (!$this->isApiAvailable()) {
            return null;
        }

        $allowedClassList = [
            AccessTokenStruct::class,
        ];

        
return $queryBuilder;
    }

    /** * @return array<string, mixed>|null */
    private function getShippingAddressData(ModelManager $entityManager, Customer $customer): ?array
    {
        $shippingAddress = null;

        if ($this->session->offsetExists('checkoutShippingAddressId')) {
            $shippingId = (int) $this->session->offsetGet('checkoutShippingAddressId');
            $shippingAddress = $entityManager->find(Address::class$shippingId);
        }

        if ($shippingAddress === null) {
            $shippingAddress = $customer->getDefaultShippingAddress();
        }

        if (!$shippingAddress instanceof Address) {
            return null;
        }

        
        // is called for the nested constraint, the outer validator is         // acting on the wrong context when the nested validation terminates.         //         // A better solution - which should be approached in Symfony 3.0 - is to         // remove the initialize() method and pass the context as last argument         // to validate() instead.         $context = $this->context;

        foreach ($constraint->fields as $field => $fieldConstraint) {
            // bug fix issue #2779             $existsInArray = \is_array($value) && \array_key_exists($field$value);
            $existsInArrayAccess = $value instanceof \ArrayAccess && $value->offsetExists($field);

            if ($existsInArray || $existsInArrayAccess) {
                if (\count($fieldConstraint->constraints) > 0) {
                    $context->getValidator()
                        ->inContext($context)
                        ->atPath('['.$field.']')
                        ->validate($value[$field]$fieldConstraint->constraints);
                }
            } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
                $context->buildViolation($constraint->missingFieldsMessage)
                    ->atPath('['.$field.']')
                    
Home | Imprint | This part of the site doesn't use cookies.