Overview

Namespaces

  • DcGeneral
    • Clipboard
    • Contao
      • Callback
      • Compatibility
      • DataDefinition
        • Definition
      • Dca
        • Builder
          • Legacy
        • Definition
        • Palette
        • Populator
      • Event
      • View
        • Contao2BackendView
          • Event
    • Controller
    • Data
    • DataDefinition
      • Builder
      • Definition
        • Properties
        • View
          • Panel
      • ModelRelationship
      • Palette
        • Builder
          • Event
        • Condition
          • Palette
          • Property
    • EnvironmentPopulator
    • Event
    • Exception
    • Factory
      • Event
    • Panel
    • View
      • Event

Classes

  • AbstractCallbackListener
  • AbstractReturningCallbackListener
  • AbstractStaticCallbackListener
  • Callbacks
  • ContainerGetBreadcrumbCallbackListener
  • ContainerGlobalButtonCallbackListener
  • ContainerHeaderCallbackListener
  • ContainerOnCopyCallbackListener
  • ContainerOnCutCallbackListener
  • ContainerOnDeleteCallbackListener
  • ContainerOnLoadCallbackListener
  • ContainerOnSubmitCallbackListener
  • ContainerPasteButtonCallbackListener
  • ContainerPasteRootButtonCallbackListener
  • ModelChildRecordCallbackListener
  • ModelGroupCallbackListener
  • ModelLabelCallbackListener
  • ModelOperationButtonCallbackListener
  • ModelOptionsCallbackListener
  • PropertyInputFieldCallbackListener
  • PropertyInputFieldGetWizardCallbackListener
  • PropertyOnLoadCallbackListener
  • PropertyOnSaveCallbackListener
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 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\Contao\View\Contao2BackendView\Event\ModelToLabelEvent;
17: use DcGeneral\DC_General;
18: 
19: /**
20:  * Class ModelLabelCallbackListener.
21:  *
22:  * Handle the label_callbacks.
23:  *
24:  * @package DcGeneral\Contao\Callback
25:  */
26: class ModelLabelCallbackListener extends AbstractReturningCallbackListener
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 ModelToLabelEvent $event The event being emitted.
52:      *
53:      * @return array
54:      */
55:     public function getArgs($event)
56:     {
57:         return array(
58:             $event->getModel()->getPropertiesAsArray(),
59:             $event->getLabel(),
60:             new DcCompat($event->getEnvironment(), $event->getModel()),
61:             $event->getArgs()
62:         );
63:     }
64: 
65:     /**
66:      * Set the value in the event.
67:      *
68:      * @param ModelToLabelEvent $event The event being emitted.
69:      *
70:      * @param string            $value The label text to use.
71:      *
72:      * @return void
73:      */
74:     public function update($event, $value)
75:     {
76:         if (is_null($value))
77:         {
78:             return;
79:         }
80: 
81:         $event->setLabel($value);
82:     }
83: }
84: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0