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 libraries/src/Application/AdministratorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function dispatch($component = null)
$this->set('themeParams', $template->params);

// Add Asset registry files
$document->getWebAssetManager()
$document->getWebAssetManager()->getRegistry()
->addRegistryFile('media/' . $component . '/joomla.asset.json')
->addRegistryFile('administrator/templates/' . $template->template . '/joomla.asset.json');

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/SiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function dispatch($component = null)
$this->set('themeParams', $template->params);

// Add Asset registry files
$document->getWebAssetManager()
$document->getWebAssetManager()->getRegistry()
->addRegistryFile('media/' . $component . '/joomla.asset.json')
->addRegistryFile('templates/' . $template->template . '/joomla.asset.json');

Expand Down
21 changes: 12 additions & 9 deletions libraries/src/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Joomla\Application\AbstractWebApplication;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory as CmsFactory;
use Joomla\CMS\WebAsset\WebAssetRegistry;
use Joomla\CMS\WebAsset\WebAssetManager;
use Symfony\Component\WebLink\HttpHeaderSerializer;

/**
Expand Down Expand Up @@ -249,7 +249,7 @@ class Document
/**
* Web Asset instance
*
* @var WebAssetRegistry
* @var WebAssetManager
* @since 4.0.0
*/
protected $webAssetManager = null;
Expand Down Expand Up @@ -321,13 +321,16 @@ public function __construct($options = array())
$this->setPreloadManager(new PreloadManager);
}

if (array_key_exists('webAsset', $options))
if (array_key_exists('webAssetManager', $options))
{
$this->setWebAssetManager($options['webAsset']);
$this->setWebAssetManager($options['webAssetManager']);
}
else
{
$this->setWebAssetManager(\Joomla\CMS\Factory::getContainer()->get('webasset'));
$webAssetManager = new WebAssetManager(\Joomla\CMS\Factory::getContainer()->get('webassetregistry'));
$webAssetManager->setDispatcher(CmsFactory::getApplication()->getDispatcher());

$this->setWebAssetManager($webAssetManager);
}
}

Expand Down Expand Up @@ -831,13 +834,13 @@ public function getPreloadManager(): PreloadManagerInterface
/**
* Set WebAsset manager
*
* @param WebAssetRegistry $webAsset The WebAsset instance
* @param WebAssetManager $webAsset The WebAsset instance
*
* @return Document
*
* @since 4.0.0
*/
public function setWebAssetManager(WebAssetRegistry $webAsset): self
public function setWebAssetManager(WebAssetManager $webAsset): self
{
$this->webAssetManager = $webAsset;

Expand All @@ -847,11 +850,11 @@ public function setWebAssetManager(WebAssetRegistry $webAsset): self
/**
* Return WebAsset manager
*
* @return WebAssetRegistry
* @return WebAssetManager
*
* @since 4.0.0
*/
public function getWebAssetManager(): WebAssetRegistry
public function getWebAssetManager(): WebAssetManager
{
return $this->webAssetManager;
}
Expand Down
22 changes: 0 additions & 22 deletions libraries/src/Event/WebAsset/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\WebAsset\WebAssetRegistry;

/**
* Event class for WebAsset events
Expand Down Expand Up @@ -40,25 +39,4 @@ public function __construct($name, array $arguments = array())

parent::__construct($name, $arguments);
}

/**
* Setter for the subject argument
*
* @param WebAssetRegistry $value The value to set
*
* @return WebAssetRegistry
*
* @throws BadMethodCallException if the argument is not of the expected type
*
* @since 4.0.0
*/
protected function setSubject($value)
{
if (!$value || !($value instanceof WebAssetRegistry))
{
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
}

return $value;
}
}
22 changes: 22 additions & 0 deletions libraries/src/Event/WebAsset/WebAssetBeforeAttachEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use BadMethodCallException;
use Joomla\CMS\Document\Document;
use Joomla\CMS\WebAsset\WebAssetManager;

/**
* Event class for WebAsset events
Expand Down Expand Up @@ -41,6 +42,27 @@ public function __construct($name, array $arguments = array())
parent::__construct($name, $arguments);
}

/**
* Setter for the subject argument
*
* @param WebAssetManager $value The value to set
*
* @return WebAssetManager
*
* @throws BadMethodCallException if the argument is not of the expected type
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject($value)
{
if (!$value || !($value instanceof WebAssetManager))
{
throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
}

return $value;
}

/**
* Return target Document
*
Expand Down
87 changes: 0 additions & 87 deletions libraries/src/Event/WebAsset/WebAssetStateChangedEvent.php

This file was deleted.

2 changes: 1 addition & 1 deletion libraries/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ protected static function createContainer(): Container
->registerServiceProvider(new \Joomla\CMS\Service\Provider\HTMLRegistry)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Session)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Toolbar)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\WebAsset);
->registerServiceProvider(new \Joomla\CMS\Service\Provider\WebAssetRegistry);

return $container;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\WebAsset\WebAssetRegistry;
use Joomla\CMS\WebAsset\WebAssetRegistry as Registry;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

Expand All @@ -19,7 +19,7 @@
*
* @since 4.0.0
*/
class WebAsset implements ServiceProviderInterface
class WebAssetRegistry implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
Expand All @@ -32,15 +32,12 @@ class WebAsset implements ServiceProviderInterface
*/
public function register(Container $container)
{
$container->alias('webasset', WebAssetRegistry::class)
$container->alias('webassetregistry', Registry::class)
->share(
WebAssetRegistry::class,
Registry::class,
function (Container $container)
{
$registry = new WebAssetRegistry;

// Set up Dispatcher
$registry->setDispatcher($container->get('Joomla\Event\DispatcherInterface'));
$registry = new Registry;

// Add Core registry files
$registry->addRegistryFile('media/vendor/joomla.asset.json')
Expand Down
35 changes: 35 additions & 0 deletions libraries/src/WebAsset/Exception/UnknownAssetException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\WebAsset\Exception;

defined('JPATH_PLATFORM') or die;

/**
* Exception class defining an Unknown Asset
*
* @since __DEPLOY_VERSION__
*/
class UnknownAssetException extends \RuntimeException implements WebAssetExceptionInterface
{
/**
* UnknownAssetException constructor.
*
* @param string $assetName The asset name.
* @param int $code The Exception code.
* @param \Throwable $previous The previous throwable used for the exception chaining.
*
* @since __DEPLOY_VERSION__
*/
public function __construct(string $assetName, int $code = 0, \Throwable $previous = null)
{
$message = 'Unknown asset "' . $assetName . '"';

parent::__construct($message, $code, $previous);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\WebAsset\Exception;

defined('JPATH_PLATFORM') or die;

/**
* Exception class defining an Unsatisfied Dependency
*
* @since __DEPLOY_VERSION__
*/
class UnsatisfiedDependencyException extends \RuntimeException implements WebAssetExceptionInterface
{

}
20 changes: 20 additions & 0 deletions libraries/src/WebAsset/Exception/WebAssetExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\WebAsset\Exception;

defined('JPATH_PLATFORM') or die;

/**
* Exception interface defining a WebAsset error
*
* @since __DEPLOY_VERSION__
*/
interface WebAssetExceptionInterface
{
}
Loading