getRevision example

$version_negotiator = new VersionNegotiator();
    $version_negotiator->addVersionNegotiator(new VersionById($entity_type_manager), 'id');
    $version_negotiator->addVersionNegotiator(new VersionByRel($entity_type_manager), 'rel');
    $this->versionNegotiator = $version_negotiator;

  }

  /** * @covers \Drupal\jsonapi\Revisions\VersionById::getRevision */
  public function testOldRevision() {
    $revision = $this->versionNegotiator->getRevision($this->node, 'id:' . $this->nodePreviousRevisionId);
    $this->assertEquals($this->node->id()$revision->id());
    $this->assertEquals($this->nodePreviousRevisionId, $revision->getRevisionId());
  }

  /** * @covers \Drupal\jsonapi\Revisions\VersionById::getRevision */
  public function testInvalidRevisionId() {
    $this->expectException(CacheableNotFoundHttpException::class);
    $this->expectExceptionMessage(sprintf('The requested version, identified by `id:%s`, could not be found.', $this->node2->getRevisionId()));
    $this->versionNegotiator->getRevision($this->node, 'id:' . $this->node2->getRevisionId());
  }
$this->setCacheResource($cache);
        }
    }

    /** * @return Configuration */
    public function setCache(CacheProvider $cache)
    {
        // Set namespace for doctrine cache provider to avoid collisions         $namespace = $this->cacheNamespace !== null ? $this->cacheNamespace : md5(
            $this->getProxyDir() . $this->release->getRevision()
        );
        $cache->setNamespace('dc2_' . $namespace . '_');

        $this->setMetadataCacheImpl($cache);
        $this->setQueryCacheImpl($cache);
        $this->setResultCacheImpl($cache);

        return $this;
    }

    /** * @return CacheProvider|null */

    /** * Returns the current version */
    public function indexAction(): void
    {
        /** @var ShopwareReleaseStruct $shopwareRelease */
        $shopwareRelease = $this->container->get('shopware.release');

        $result['data'] = [
            'version' => $shopwareRelease->getVersion(),
            'revision' => $shopwareRelease->getRevision(),
        ];

        $this->View()->assign($result);
        $this->View()->assign('success', true);
    }
}
$data = $builder->execute()->fetchAll();

        $result = [];
        foreach ($data as $row) {
            $value = !empty($row['value']) ? @unserialize($row['value']['allowed_classes' => false]) : null;
            $result[$row['name']] = $value;
            // Take namespaces (form names) into account             $result[$row['form'] . '::' . $row['name']] = $value;
        }

        $result['version'] = $this->release->getVersion();
        $result['revision'] = $this->release->getRevision();
        $result['versiontext'] = $this->release->getVersionText();

        return $result;
    }
}

  public function getRevision(EntityInterface $entity$resource_version_identifier) {
    try {
      [$version_negotiator_name$version_argument] = explode(VersionNegotiator::SEPARATOR, $resource_version_identifier, 2);
      if (!isset($this->negotiators[$version_negotiator_name])) {
        static::throwBadRequestHttpException($resource_version_identifier);
      }
      return $this->negotiators[$version_negotiator_name]->getRevision($entity$version_argument);
    }
    catch (VersionNotFoundException $exception) {
      static::throwNotFoundHttpException($entity$resource_version_identifier);
    }
    catch (InvalidVersionIdentifierException $exception) {
      static::throwBadRequestHttpException($resource_version_identifier);
    }
  }

  /** * Throws a cacheable error exception. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity for which a revision was requested. * @param string $resource_version_identifier * The user input for the revision negotiation. * * @throws \Drupal\Core\Http\Exception\CacheableNotFoundHttpException */
$sbpLogin = (int) (!empty($tokenData) && $tokenData->getExpire() >= new DateTime('+30 seconds'));
        }
        $this->View()->assign('sbpLogin', $sbpLogin, true);
        $this->View()->assign('firstRunWizardEnabled', $firstRunWizardEnabled, true);

        $config = $this->get(Shopware_Components_Config::class);

        $shopwareRelease = $this->container->get('shopware.release');

        $this->View()->assign('SHOPWARE_VERSION', $shopwareRelease->getVersion());
        $this->View()->assign('SHOPWARE_VERSION_TEXT', $shopwareRelease->getVersionText());
        $this->View()->assign('SHOPWARE_REVISION', $shopwareRelease->getRevision());
        $this->View()->assign('updateWizardStarted', $config->get('updateWizardStarted'));
        $this->View()->assign('extJsDeveloperModeActive', $this->container->getParameter('shopware.extjs.developer_mode'));
    }

    /** * @return void */
    public function authAction()
    {
    }

    

    private function getConfig(Template $template, Shop $shop): array
    {
        $config = $this->inheritance->buildConfig($template$shop);
        $config['shopware-revision'] = md5($this->release->getRevision() . $this->uniqueIdGenerator->getUniqueId());

        /** @var ArrayCollection<int, mixed> $collection */
        $collection = new ArrayCollection();

        $this->eventManager->collect(
            'Theme_Compiler_Collect_Less_Config',
            $collection,
            ['shop' => $shop, 'template' => $template]
        );

        foreach ($collection as $temp) {
            

    public function buildTimestampName($timestamp, Shop\Shop $shop$suffix)
    {
        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        $filename = $timestamp . '_' . md5($timestamp . $shop->getTemplate()->getId() . $shop->getId() . $this->release->getRevision());

        return $filename . '.' . $suffix;
    }

    /** * @return string */
    private function getBaseThemeDirectory()
    {
        return rtrim($this->templateDir, DIRECTORY_SEPARATOR);
    }

    
throw new CacheableBadRequestHttpException($cacheability$message);
      }
      // Whether the collection to be loaded should include only working copies.       $defaults[static::WORKING_COPIES_REQUESTED] = $resource_version_identifier === $working_copy_identifier;
      return $defaults;
    }

    /** @var \Drupal\Core\Entity\EntityInterface $entity */
    $entity = $defaults['entity'];

    /** @var \Drupal\jsonapi\Revisions\VersionNegotiatorInterface $negotiator */
    $resolved_revision = $this->versionNegotiator->getRevision($entity$resource_version_identifier);
    // Ensure none of the original entity cacheability is lost, especially the     // query argument's cache context.     $resolved_revision->addCacheableDependency($entity);
    return ['entity' => $resolved_revision] + $defaults;
  }

  /** * Validates the user input. * * @param string $resource_version * The requested resource version identifier. * * @return bool * TRUE if the received resource version value is valid, FALSE otherwise. */
$result = $this->_redis->pconnect($server['host']$server['port']);
            } else {
                $result = $this->_redis->connect($server['host']$server['port']);
            }

            // SW-20299 - sw-fix: support redis auth configuration             if (isset($server['redisAuth'])) {
                $this->_redis->auth($server['redisAuth']);
            }

            if (array_key_exists('release', $options)) {
                $this->_options['key_prefix'] = $options['release']->getRevision();
            }

            if ($result) {
                $this->_redis->select($server['dbindex']);
            } else {
                $this->_redis = null;
            }
        }
    }

    /** * Gets the redis instance used by the cache. * * @return Redis|null */
Home | Imprint | This part of the site doesn't use cookies.