getMode example

if ($product) {
            $product->setInStock($product->getInStock() + $detail->getQuantity());
            $this->entityManager->persist($product);
        }
    }

    /** * Returns the product of the product position */
    protected function getProductFromDetail(OrderDetail $detail): ?ProductDetail
    {
        if (\in_array($detail->getMode()[0, 1], true)) {
            if ($detail->getArticleDetail() && $detail->getArticleDetail()->getId()) { // After the detail got removed, the association to the product detail does not exist anymore.                 return $detail->getArticleDetail();
            } elseif ($detail->getArticleNumber()) {
                return $this->getProductByNumber($detail->getArticleNumber());
            }
        }

        return null;
    }

    /** * Returns a product by the ordernumber */


    $form['layout']['enabled'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Use Layout Builder'),
      '#default_value' => $is_enabled,
    ];
    $form['#entity_builders']['layout_builder'] = '::entityFormEntityBuild';

    // @todo Expand to work for all view modes in     // https://www.drupal.org/node/2907413.     if ($this->isCanonicalMode($this->entity->getMode())) {
      $entity_type = $this->entityTypeManager->getDefinition($this->entity->getTargetEntityTypeId());
      $form['layout']['allow_custom'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Allow each @entity to have its layout customized.', [
          '@entity' => $entity_type->getSingularLabel(),
        ]),
        '#default_value' => $this->entity->isOverridable(),
        '#states' => [
          'disabled' => [
            ':input[name="layout[enabled]"]' => ['checked' => FALSE],
          ],
          

    public static function castRedis(\Redis|Relay $c, array $a, Stub $stub, bool $isNested)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        if (!$connected = $c->isConnected()) {
            return $a + [
                $prefix.'isConnected' => $connected,
            ];
        }

        $mode = $c->getMode();

        return $a + [
            $prefix.'isConnected' => $connected,
            $prefix.'host' => $c->getHost(),
            $prefix.'port' => $c->getPort(),
            $prefix.'auth' => $c->getAuth(),
            $prefix.'mode' => isset(self::MODES[$mode]) ? new ConstStub(self::MODES[$mode]$mode) : $mode,
            $prefix.'dbNum' => $c->getDbNum(),
            $prefix.'timeout' => $c->getTimeout(),
            $prefix.'lastError' => $c->getLastError(),
            $prefix.'persistentId' => $c->getPersistentID(),
            

  protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
    $settings_form = [];
    // Invoke hook_field_formatter_third_party_settings_form(), keying resulting     // subforms by module name.     $this->moduleHandler->invokeAllWith(
      'field_formatter_third_party_settings_form',
      function Dcallable $hook, string $module) use (&$settings_form, &$plugin, &$field_definition, &$form, &$form_state) {
        $settings_form[$module] = $hook(
          $plugin,
          $field_definition,
          $this->entity->getMode(),
          $form,
          $form_state,
        );
      }
    );
    return $settings_form;
  }

  /** * {@inheritdoc} */
  

  protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
    $settings_form = [];
    // Invoke hook_field_widget_third_party_settings_form(), keying resulting     // subforms by module name.     $this->moduleHandler->invokeAllWith(
      'field_widget_third_party_settings_form',
      function Dcallable $hook, string $module) use (&$settings_form$plugin$field_definition, &$form$form_state) {
        $settings_form[$module] = $hook(
          $plugin,
          $field_definition,
          $this->entity->getMode(),
          $form,
          $form_state
        );
      }
    );
    return $settings_form;
  }

  /** * {@inheritdoc} */
  
return false;
        }

        return true;
    }

    /** * Checks if the order position is a regular product */
    private function isProductPosition(Detail $orderDetailModel): bool
    {
        return $orderDetailModel->getMode() === CartPositionsMode::PRODUCT;
    }

    /** * Helper function to get the correct translation */
    private function translateMessage(string $name, string $default): string
    {
        $namespace = Shopware()->Snippets()->getNamespace('backend/canceled_order/controller/main');

        return $namespace->get($name$default);
    }

    
$table[$field_name] = $this->buildFieldRow($field_definition$form$form_state);
    }

    // Non-field elements.     foreach ($extra_fields as $field_id => $extra_field) {
      $table[$field_id] = $this->buildExtraFieldRow($field_id$extra_field);
    }

    $form['fields'] = $table;

    // Custom display settings.     if ($this->entity->getMode() == 'default') {
      // Only show the settings if there is at least one custom display mode.       $display_mode_options = $this->getDisplayModeOptions();
      // Unset default option.       unset($display_mode_options['default']);
      if ($display_mode_options) {
        $form['modes'] = [
          '#type' => 'details',
          '#title' => $this->t('Custom display settings'),
        ];
        // Prepare default values for the 'Custom display settings' checkboxes.         $default = [];
        

    public static function castRedis(\Redis|Relay $c, array $a, Stub $stub, bool $isNested)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        if (!$connected = $c->isConnected()) {
            return $a + [
                $prefix.'isConnected' => $connected,
            ];
        }

        $mode = $c->getMode();

        return $a + [
            $prefix.'isConnected' => $connected,
            $prefix.'host' => $c->getHost(),
            $prefix.'port' => $c->getPort(),
            $prefix.'auth' => $c->getAuth(),
            $prefix.'mode' => isset(self::MODES[$mode]) ? new ConstStub(self::MODES[$mode]$mode) : $mode,
            $prefix.'dbNum' => $c->getDbNum(),
            $prefix.'timeout' => $c->getTimeout(),
            $prefix.'lastError' => $c->getLastError(),
            $prefix.'persistentId' => $c->getPersistentID(),
            


    // Copy form and view mode configuration.     $properties = [
      'targetEntityType' => $this->entityTypeId,
      'bundle' => $existing_bundle,
    ];
    /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $existing_forms */
    $existing_forms = $this->entityTypeManager->getStorage('entity_form_display')->loadByProperties($properties);
    foreach ($existing_forms as $form) {
      if ($settings = $form->getComponent($field_name)) {
        $default_options['entity_form_display'][$form->getMode()] = $settings;
      }
    }
    /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $existing_views */
    $existing_views = $this->entityTypeManager->getStorage('entity_view_display')->loadByProperties($properties);
    foreach ($existing_views as $view) {
      if ($settings = $view->getComponent($field_name)) {
        $default_options['entity_view_display'][$view->getMode()] = $settings;
      }
    }

    return $default_options;
  }

  public function deriveContextsFromRoute($value$definition$name, array $defaults) {
    $contexts = [];

    if ($entity = $this->extractEntityFromRoute($value$defaults)) {
      $contexts['entity'] = EntityContext::fromEntity($entity);
      // @todo Expand to work for all view modes in       // https://www.drupal.org/node/2907413.       $view_mode = 'full';
      // Retrieve the actual view mode from the returned view display as the       // requested view mode may not exist and a fallback will be used.       $view_mode = LayoutBuilderEntityViewDisplay::collectRenderDisplay($entity$view_mode)->getMode();
      $contexts['view_mode'] = new Context(new ContextDefinition('string')$view_mode);
    }
    return $contexts;
  }

  /** * Extracts an entity from the route values. * * @param mixed $value * The raw value from the route. * @param array $defaults * The route defaults array. * * @return \Drupal\Core\Entity\EntityInterface|null * The entity for the route, or NULL if none exist. * * @see \Drupal\layout_builder\SectionStorageInterface::deriveContextsFromRoute() * @see \Drupal\Core\ParamConverter\ParamConverterInterface::convert() */

        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getHost(...\func_get_args());
    }

    public function getLastError(): ?string
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getLastError(...\func_get_args());
    }

    public function getMode(): int
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getMode(...\func_get_args());
    }

    public function getOption($option): mixed
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getOption(...\func_get_args());
    }

    public function getPersistentID(): ?string
    {
        return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->getPersistentID(...\func_get_args());
    }

    
// Check that createCopy() creates a new component that can be correctly     // saved.     EntityViewMode::create(['id' => $display->getTargetEntityTypeId() . '.other_view_mode', 'targetEntityType' => $display->getTargetEntityTypeId()])->save();
    $new_display = $display->createCopy('other_view_mode');
    $new_display->save();
    $new_display = EntityViewDisplay::load($new_display->id());
    $dependencies = $new_display->calculateDependencies()->getDependencies();
    $this->assertEquals(['config' => ['core.entity_view_mode.entity_test.other_view_mode'], 'module' => ['entity_test']]$dependencies);
    $this->assertEquals($display->getTargetEntityTypeId()$new_display->getTargetEntityTypeId());
    $this->assertEquals($display->getTargetBundle()$new_display->getTargetBundle());
    $this->assertEquals('other_view_mode', $new_display->getMode());
    $this->assertEquals($display->getComponents()$new_display->getComponents());
  }

  /** * Tests sorting of components by name on basic CRUD operations. */
  public function testEntityDisplayCRUDSort() {
    $display = EntityViewDisplay::create([
      'targetEntityType' => 'entity_test',
      'bundle' => 'entity_test',
      'mode' => 'default',
    ]);


    /** * @return array */
    public function toArray()
    {
        return [
            'id' => $this->getId(),
            'key' => $this->getKey(),
            'tax' => $this->getTax(),
            'mode' => $this->getMode(),
            'minimumorder' => $this->getMinimumOrder(),
            'minimumordersurcharge' => $this->getMinimumOrderSurcharge(),
            'basketdiscount' => $this->getDiscount(),
        ];
    }
}
if (\is_array($aggregations[$key]['buckets'])) {
                $aggregations[$key]['buckets'] = array_filter($aggregations[$key]['buckets']function D$item) {
                    return $item['key'] !== '';
                });
            }

            if (\in_array($type[TypeMappingInterface::TYPE_DATE, TypeMappingInterface::TYPE_DATETIME], true)) {
                $aggregations[$key] = $this->formatDates($aggregations[$key]);
            }

            $criteriaPartResult = null;
            switch ($criteriaPart->getMode()) {
                case ProductAttributeFacet::MODE_VALUE_LIST_RESULT:
                case ProductAttributeFacet::MODE_RADIO_LIST_RESULT:
                    $criteriaPartResult = $this->createItemListResult($criteriaPart$aggregations[$key]$criteria);
                    break;
                case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                    $criteriaPartResult = $this->createBooleanResult($criteriaPart$aggregations[$key]$criteria);
                    break;
                case ProductAttributeFacet::MODE_RANGE_RESULT:
                    $criteriaPartResult = $this->createRangeResult($criteriaPart$aggregations[$key]$criteria);

                    if ($criteriaPartResult->getMax() === $criteriaPartResult->getMin()) {
                        
private function handleProductAttributeFacet(
        Request $request,
        Criteria $criteria,
        ProductAttributeFacet $facet
    ) {
        if (!$this->isAttributeInRequest($facet$request)) {
            return;
        }
        $data = $request->getParam($facet->getFormFieldName());

        switch ($facet->getMode()) {
            case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                $criteria->addCondition(
                    new ProductAttributeCondition(
                        $facet->getField(),
                        ProductAttributeCondition::OPERATOR_NOT_IN,
                        [false]
                    )
                );

                return;

            
Home | Imprint | This part of the site doesn't use cookies.