1: <?php
2: /**
3: * PHP version 5
4: * @package generalDriver
5: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
6: * @author Stefan Heimes <stefan_heimes@hotmail.com>
7: * @author Tristan Lins <tristan.lins@bit3.de>
8: * @copyright The MetaModels team.
9: * @license LGPL.
10: * @filesource
11: */
12:
13: namespace DcGeneral\Contao\Callback;
14:
15: use DcGeneral\Contao\Compatibility\DcCompat;
16: use DcGeneral\DC_General;
17: use DcGeneral\Event\PostDuplicateModelEvent;
18:
19: /**
20: * Class ContainerOnCopyCallbackListener.
21: *
22: * Handle callbacks to be invoked when a copy operation is made.
23: *
24: * @package DcGeneral\Contao\Callback
25: */
26: class ContainerOnCopyCallbackListener extends AbstractCallbackListener
27: {
28: /**
29: * The DC_General instance.
30: *
31: * @var DC_General
32: */
33: protected $dcGeneral;
34:
35: /**
36: * Create a new instance of the listener.
37: *
38: * @param array|callable $callback The callback to call when invoked.
39: *
40: * @param DC_General $dcGeneral The DC_General instance to use in the callback.
41: */
42: public function __construct($callback, DC_General $dcGeneral)
43: {
44: parent::__construct($callback);
45: $this->dcGeneral = $dcGeneral;
46: }
47:
48: /**
49: * Retrieve the arguments for the callback.
50: *
51: * @param PostDuplicateModelEvent $event The event being emitted.
52: *
53: * @return array
54: */
55: public function getArgs($event)
56: {
57: return array($event->getModel()->getId(), new DcCompat($event->getEnvironment(), $event->getModel()));
58: }
59: }
60: