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\GetPropertyOptionsEvent;
17: use DcGeneral\DC_General;
18: 
19: /**
20:  * Class ModelOptionsCallbackListener.
21:  *
22:  * Handle the options_callback for a model in edit view.
23:  *
24:  * @package DcGeneral\Contao\Callback
25:  */
26: class ModelOptionsCallbackListener 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 GetPropertyOptionsEvent $event The event being emitted.
52:      *
53:      * @return array
54:      */
55:     public function getArgs($event)
56:     {
57:         return array(
58:             new DcCompat($event->getEnvironment(), $event->getModel())
59:         );
60:     }
61: 
62:     /**
63:      * Update the options list in the event.
64:      *
65:      * @param GetPropertyOptionsEvent $event The event being emitted.
66:      *
67:      * @param array                   $value The options array.
68:      *
69:      * @return void
70:      */
71:     public function update($event, $value)
72:     {
73:         if (is_null($value))
74:         {
75:             return;
76:         }
77: 
78:         $event->setOptions($value);
79:         $event->stopPropagation();
80:     }
81: }
82: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0