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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Media\Administrator\Plugin;

use Joomla\CMS\Event\Model\PrepareFormEvent;
use Joomla\CMS\Form\Form;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\CMSPlugin;
Expand All @@ -34,6 +35,35 @@ class MediaActionPlugin extends CMSPlugin
*/
protected $autoloadLanguage = true;

/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function getSubscribedEvents(): array
{
return [
'onContentPrepareForm' => 'onContentPrepareFormListener',
];
}

/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
*
* @param PrepareFormEvent $event Event instance.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onContentPrepareFormListener(PrepareFormEvent $event): void
{
$this->onContentPrepareForm($event->getForm(), $event->getData());
}

/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
Expand Down
3 changes: 2 additions & 1 deletion plugins/media-action/crop/src/Extension/Crop.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Application\CMSWebApplicationInterface;
use Joomla\Component\Media\Administrator\Plugin\MediaActionPlugin;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -22,7 +23,7 @@
*
* @since 4.0.0
*/
final class Crop extends MediaActionPlugin
final class Crop extends MediaActionPlugin implements SubscriberInterface
{
/**
* Load the javascript files of the plugin.
Expand Down
28 changes: 22 additions & 6 deletions plugins/media-action/resize/src/Extension/Resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

namespace Joomla\Plugin\MediaAction\Resize\Extension;

use Joomla\CMS\Event\Model\BeforeSaveEvent;
use Joomla\CMS\Image\Image;
use Joomla\Component\Media\Administrator\Plugin\MediaActionPlugin;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -22,22 +24,36 @@
*
* @since 4.0.0
*/
final class Resize extends MediaActionPlugin
final class Resize extends MediaActionPlugin implements SubscriberInterface
{
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function getSubscribedEvents(): array
{
return array_merge(parent::getSubscribedEvents(), [
'onContentBeforeSave' => 'onContentBeforeSave',
]);
}

/**
* The save event.
*
* @param string $context The context
* @param object $item The item
* @param boolean $isNew Is new item
* @param array $data The validated data
* @param BeforeSaveEvent $event The event instance
*
* @return void
*
* @since 4.0.0
*/
public function onContentBeforeSave($context, $item, $isNew, $data = [])
public function onContentBeforeSave(BeforeSaveEvent $event): void
{
$context = $event->getContext();
$item = $event->getItem();

if ($context != 'com_media.file') {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/media-action/rotate/src/Extension/Rotate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Joomla\Plugin\MediaAction\Rotate\Extension;

use Joomla\Component\Media\Administrator\Plugin\MediaActionPlugin;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -21,6 +22,6 @@
*
* @since 4.0.0
*/
final class Rotate extends MediaActionPlugin
final class Rotate extends MediaActionPlugin implements SubscriberInterface
{
}