Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"require": {
"php": "^8.3.0",
"fig/link-util": "^1.0",
"psr/link": "^2.0"
"psr/link": "^1.1|^2.0"
},
"require-dev": {
"joomla/application": "^4.0",
Expand Down
8 changes: 5 additions & 3 deletions src/PreloadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @since 2.0.0
*/
class PreloadManager
class PreloadManager implements PreloadManagerInterface
{
/**
* The link provider
Expand Down Expand Up @@ -57,13 +57,15 @@ public function getLinkProvider(): EvolvableLinkProviderInterface
*
* @param EvolvableLinkProviderInterface $linkProvider The link provider
*
* @return void
* @return $this
*
* @since 2.0.0
*/
public function setLinkProvider(EvolvableLinkProviderInterface $linkProvider): void
public function setLinkProvider(EvolvableLinkProviderInterface $linkProvider): self
{
$this->linkProvider = $linkProvider;

return $this;
}

/**
Expand Down
100 changes: 100 additions & 0 deletions src/PreloadManagerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

/**
* Part of the Joomla Framework Preload Package
*
* @copyright Copyright (C) 2005 - 2026 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Preload;

use Psr\Link\EvolvableLinkProviderInterface;

/**
* Joomla! Preload Manager Interface
*
* @since 4.1.0
*/
interface PreloadManagerInterface
{
/**
* Get the link provider
*
* @return EvolvableLinkProviderInterface
*
* @since 4.1.0
*/
public function getLinkProvider(): EvolvableLinkProviderInterface;

/**
* Set the link provider
*
* @param EvolvableLinkProviderInterface $linkProvider The link provider
*
* @return $this
*
* @since 4.1.0
*/
public function setLinkProvider(EvolvableLinkProviderInterface $linkProvider);

/**
* Preloads a resource.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('crossorigin' => 'use-credentials')")
*
* @return void
*
* @since 4.1.0
*/
public function preload(string $uri, array $attributes = []);

/**
* Resolves a resource origin as early as possible.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
*
* @return void
*
* @since 4.1.0
*/
public function dnsPrefetch(string $uri, array $attributes = []);

/**
* Initiates an early connection to a resource (DNS resolution, TCP handshake, TLS negotiation).
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
*
* @return void
*
* @since 4.1.0
*/
public function preconnect(string $uri, array $attributes = []);

/**
* Indicates to the client that it should prefetch this resource.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
*
* @return void
*
* @since 4.1.0
*/
public function prefetch(string $uri, array $attributes = []);

/**
* Indicates to the client that it should prerender this resource.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
*
* @return void
*
* @since 4.1.0
*/
public function prerender(string $uri, array $attributes = []);
}
4 changes: 4 additions & 0 deletions tests/EventListener/PreloadSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\Application\Event\ApplicationEvent;
use Joomla\Preload\EventListener\PreloadSubscriber;
use Joomla\Preload\PreloadManager;
use Laminas\Diactoros\Response;
use PHPUnit\Framework\TestCase;
use Psr\Link\EvolvableLinkProviderInterface;

Expand Down Expand Up @@ -57,6 +58,9 @@ public function testAddHeaderToApplication()
* @since 1.0
*/
class TestAbstractWebApplication extends AbstractWebApplication {
public function __construct() {
$this->setResponse(new Response());
}
protected function doExecute()
{
// TODO: Implement doExecute() method.
Expand Down
Loading