Moved many field related get methods to its own classes
This commit is contained in:
@@ -13,7 +13,8 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\CMS\Version;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
|
||||
|
||||
@@ -25,6 +26,14 @@ use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
|
||||
*/
|
||||
class Event implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Current Joomla Version We are IN
|
||||
*
|
||||
* @var int
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected $currentVersion;
|
||||
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
@@ -37,6 +46,27 @@ class Event implements ServiceProviderInterface
|
||||
{
|
||||
$container->alias(J3Event::class, 'J3.Event')
|
||||
->share('J3.Event', [$this, 'getJ3Event'], true);
|
||||
|
||||
$container->alias(EventInterface::class, 'Event')
|
||||
->share('Event', [$this, 'getEvent'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Event
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getEvent(Container $container): EventInterface
|
||||
{
|
||||
if (empty($this->currentVersion))
|
||||
{
|
||||
$this->currentVersion = Version::MAJOR_VERSION;
|
||||
}
|
||||
|
||||
return $container->get('J' . $this->currentVersion . '.Event');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,12 +74,13 @@ class Event implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return EventInterface
|
||||
* @return J3Event
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJ3Event(Container $container): EventInterface
|
||||
public function getJ3Event(Container $container): J3Event
|
||||
{
|
||||
return new J3Event();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user