Skip to content

Commit 2bd3afa

Browse files
authored
Remove the dispatch event functions in model and view (#45431)
1 parent 03b804c commit 2bd3afa

File tree

3 files changed

+0
-133
lines changed

3 files changed

+0
-133
lines changed

libraries/src/MVC/Model/BaseDatabaseModel.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
use Joomla\Database\Exception\DatabaseNotFoundException;
3232
use Joomla\Event\DispatcherAwareInterface;
3333
use Joomla\Event\DispatcherAwareTrait;
34-
use Joomla\Event\DispatcherInterface;
35-
use Joomla\Event\EventInterface;
3634

3735
// phpcs:disable PSR1.Files.SideEffects
3836
\defined('_JEXEC') or die;
@@ -333,55 +331,6 @@ protected function bootComponent($component): ComponentInterface
333331
return Factory::getApplication()->bootComponent($component);
334332
}
335333

336-
/**
337-
* Get the event dispatcher.
338-
*
339-
* The override was made to keep a backward compatibility for legacy component.
340-
* TODO: Remove the override in 6.0
341-
*
342-
* @return DispatcherInterface
343-
*
344-
* @since 4.4.0
345-
* @throws \UnexpectedValueException May be thrown if the dispatcher has not been set.
346-
*/
347-
public function getDispatcher()
348-
{
349-
if (!$this->dispatcher) {
350-
@trigger_error(
351-
\sprintf('Dispatcher for %s should be set through MVC factory. It will throw an exception in 6.0', __CLASS__),
352-
E_USER_DEPRECATED
353-
);
354-
355-
return Factory::getContainer()->get(DispatcherInterface::class);
356-
}
357-
358-
return $this->dispatcher;
359-
}
360-
361-
/**
362-
* Dispatches the given event on the internal dispatcher, does a fallback to the global one.
363-
*
364-
* @param EventInterface $event The event
365-
*
366-
* @return void
367-
*
368-
* @since 4.1.0
369-
*
370-
* @deprecated 4.4 will be removed in 6.0. Use $this->getDispatcher() directly.
371-
*/
372-
protected function dispatchEvent(EventInterface $event)
373-
{
374-
$this->getDispatcher()->dispatch($event->getName(), $event);
375-
376-
@trigger_error(
377-
\sprintf(
378-
'Method %s is deprecated and will be removed in 6.0. Use getDispatcher()->dispatch() directly.',
379-
__METHOD__
380-
),
381-
E_USER_DEPRECATED
382-
);
383-
}
384-
385334
/**
386335
* Get the database driver.
387336
*

libraries/src/MVC/View/AbstractView.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@
1111

1212
use Joomla\CMS\Document\Document;
1313
use Joomla\CMS\Document\DocumentAwareInterface;
14-
use Joomla\CMS\Factory;
1514
use Joomla\CMS\Language\LanguageAwareInterface;
1615
use Joomla\CMS\Language\LanguageAwareTrait;
1716
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
1817
use Joomla\CMS\Object\LegacyErrorHandlingTrait;
1918
use Joomla\CMS\Object\LegacyPropertyManagementTrait;
2019
use Joomla\Event\DispatcherAwareInterface;
2120
use Joomla\Event\DispatcherAwareTrait;
22-
use Joomla\Event\DispatcherInterface;
23-
use Joomla\Event\EventInterface;
2421

2522
// phpcs:disable PSR1.Files.SideEffects
2623
\defined('_JEXEC') or die;
@@ -292,53 +289,4 @@ public function setDocument(Document $document): void
292289
{
293290
$this->document = $document;
294291
}
295-
296-
/**
297-
* Get the event dispatcher.
298-
*
299-
* The override was made to keep a backward compatibility for legacy component.
300-
* TODO: Remove the override in 6.0
301-
*
302-
* @return DispatcherInterface
303-
*
304-
* @since 4.4.0
305-
* @throws \UnexpectedValueException May be thrown if the dispatcher has not been set.
306-
*/
307-
public function getDispatcher()
308-
{
309-
if (!$this->dispatcher) {
310-
@trigger_error(
311-
\sprintf('Dispatcher for %s should be set through MVC factory. It will throw an exception in 6.0', __CLASS__),
312-
E_USER_DEPRECATED
313-
);
314-
315-
return Factory::getContainer()->get(DispatcherInterface::class);
316-
}
317-
318-
return $this->dispatcher;
319-
}
320-
321-
/**
322-
* Dispatches the given event on the internal dispatcher, does a fallback to the global one.
323-
*
324-
* @param EventInterface $event The event
325-
*
326-
* @return void
327-
*
328-
* @since 4.1.0
329-
*
330-
* @deprecated 4.4 will be removed in 6.0. Use $this->getDispatcher() directly.
331-
*/
332-
protected function dispatchEvent(EventInterface $event)
333-
{
334-
$this->getDispatcher()->dispatch($event->getName(), $event);
335-
336-
@trigger_error(
337-
\sprintf(
338-
'Method %s is deprecated and will be removed in 6.0. Use getDispatcher()->dispatch() directly.',
339-
__METHOD__
340-
),
341-
E_USER_DEPRECATED
342-
);
343-
}
344292
}

tests/Unit/Libraries/Cms/MVC/View/AbstractViewTest.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212

1313
use Joomla\CMS\MVC\Model\BaseModel;
1414
use Joomla\CMS\MVC\View\AbstractView;
15-
use Joomla\Event\DispatcherInterface;
16-
use Joomla\Event\Event;
17-
use Joomla\Event\EventInterface;
1815
use Joomla\Tests\Unit\UnitTestCase;
1916

2017
/**
@@ -220,31 +217,4 @@ public function display($tpl = null)
220217

221218
$this->assertEquals('test', $view->get('unit'));
222219
}
223-
224-
/**
225-
* @testdox can dispatch an event
226-
*
227-
* @return void
228-
*
229-
* @since 4.2.0
230-
*/
231-
public function testDispatchEvent()
232-
{
233-
$event = new Event('test');
234-
$dispatcher = $this->createMock(DispatcherInterface::class);
235-
$dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo('test'), $this->equalTo($event));
236-
237-
$view = new class () extends AbstractView {
238-
public function dispatchEvent(EventInterface $event)
239-
{
240-
parent::dispatchEvent($event);
241-
}
242-
243-
public function display($tpl = null)
244-
{
245-
}
246-
};
247-
$view->setDispatcher($dispatcher);
248-
$view->dispatchEvent($event);
249-
}
250220
}

0 commit comments

Comments
 (0)