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

  • DataDefinitionContainer
  • DC_General
  • DcGeneral
  • DefaultEnvironment

Interfaces

  • ContainerAwareInterface
  • DataContainerInterface
  • DataDefinitionContainerInterface
  • EnvironmentAwareInterface
  • EnvironmentInterface
  • InputProviderInterface
  • ModelAwareInterface
  • ViewAwareInterface
  • 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;
 14: 
 15: use ContaoCommunityAlliance\Translator\TranslatorInterface;
 16: use DcGeneral\Controller\ControllerInterface;
 17: use DcGeneral\Exception\DcGeneralInvalidArgumentException;
 18: use DcGeneral\Exception\DcGeneralRuntimeException;
 19: use DcGeneral\Contao\View\Contao2BackendView\BaseView;
 20: 
 21: /**
 22:  * Default implementation of an environment.
 23:  *
 24:  * @package DcGeneral
 25:  */
 26: class DefaultEnvironment implements EnvironmentInterface
 27: {
 28:     /**
 29:      * The controller.
 30:      *
 31:      * @var ControllerInterface
 32:      */
 33:     protected $objController;
 34: 
 35:     /**
 36:      * The view in use.
 37:      *
 38:      * @var \DcGeneral\View\ViewInterface
 39:      */
 40:     protected $objView;
 41: 
 42:     /**
 43:      * The data container definition.
 44:      *
 45:      * @var \DcGeneral\DataDefinition\ContainerInterface
 46:      */
 47:     protected $objDataDefinition;
 48: 
 49:     /**
 50:      * The data container definition of the parent table.
 51:      *
 52:      * @var \DcGeneral\DataDefinition\ContainerInterface
 53:      */
 54:     protected $objParentDataDefinition;
 55: 
 56:     /**
 57:      * The data container definition of the root table.
 58:      *
 59:      * @var \DcGeneral\DataDefinition\ContainerInterface
 60:      */
 61:     protected $objRootDataDefinition;
 62: 
 63:     /**
 64:      * The attached input provider.
 65:      *
 66:      * @var InputProviderInterface
 67:      */
 68:     protected $objInputProvider;
 69: 
 70:     /**
 71:      * The registered data providers.
 72:      *
 73:      * @var \DcGeneral\Data\DataProviderInterface[]
 74:      */
 75:     protected $arrDataProvider;
 76: 
 77:     /**
 78:      * The clipboard in use.
 79:      *
 80:      * @var \DcGeneral\Clipboard\ClipboardInterface
 81:      */
 82:     protected $objClipboard;
 83: 
 84:     /**
 85:      * The translator in use.
 86:      *
 87:      * @var \ContaoCommunityAlliance\Translator\TranslatorInterface
 88:      */
 89:     protected $translator;
 90: 
 91:     /**
 92:      * The event propagator in use.
 93:      *
 94:      * @var \DcGeneral\Event\EventPropagatorInterface
 95:      */
 96:     protected $eventPropagator;
 97: 
 98:     /**
 99:      * {@inheritdoc}
100:      */
101:     public function setController($objController)
102:     {
103:         $this->objController = $objController;
104: 
105:         return $this;
106:     }
107: 
108:     /**
109:      * {@inheritdoc}
110:      */
111:     public function getController()
112:     {
113:         return $this->objController;
114:     }
115: 
116:     /**
117:      * {@inheritdoc}
118:      */
119:     public function setView($objView)
120:     {
121:         $this->objView = $objView;
122: 
123:         return $this;
124:     }
125: 
126:     /**
127:      * {@inheritdoc}
128:      */
129:     public function getView()
130:     {
131:         return $this->objView;
132:     }
133: 
134:     /**
135:      * {@inheritdoc}
136:      */
137:     public function setDataDefinition($objDataDefinition)
138:     {
139:         $this->objDataDefinition = $objDataDefinition;
140: 
141:         return $this;
142:     }
143: 
144:     /**
145:      * {@inheritdoc}
146:      */
147:     public function getDataDefinition()
148:     {
149:         return $this->objDataDefinition;
150:     }
151: 
152:     /**
153:      * {@inheritdoc}
154:      */
155:     public function setParentDataDefinition($objParentDataDefinition)
156:     {
157:         $this->objParentDataDefinition = $objParentDataDefinition;
158: 
159:         return $this;
160:     }
161: 
162:     /**
163:      * {@inheritdoc}
164:      */
165:     public function getParentDataDefinition()
166:     {
167:         return $this->objParentDataDefinition;
168:     }
169: 
170:     /**
171:      * {@inheritdoc}
172:      */
173:     public function setRootDataDefinition($objRootDataDefinition)
174:     {
175:         $this->objRootDataDefinition = $objRootDataDefinition;
176: 
177:         return $this;
178:     }
179: 
180:     /**
181:      * {@inheritdoc}
182:      */
183:     public function getRootDataDefinition()
184:     {
185:         return $this->objRootDataDefinition;
186:     }
187: 
188:     /**
189:      * {@inheritdoc}
190:      */
191:     public function setInputProvider($objInputProvider)
192:     {
193:         $this->objInputProvider = $objInputProvider;
194: 
195:         return $this;
196:     }
197: 
198:     /**
199:      * {@inheritdoc}
200:      */
201:     public function getInputProvider()
202:     {
203:         return $this->objInputProvider;
204:     }
205: 
206:     /**
207:      * {@inheritdoc}
208:      */
209:     public function hasDataProvider($strSource = null)
210:     {
211:         if ($strSource === null)
212:         {
213:             $strSource = $this->getDataDefinition()->getBasicDefinition()->getDataProvider();
214:         }
215: 
216:         return (isset($this->arrDataProvider[$strSource]));
217:     }
218: 
219:     /**
220:      * {@inheritdoc}
221:      *
222:      * @throws DcGeneralRuntimeException when an undefined provider is requested.
223:      */
224:     public function getDataProvider($strSource = null)
225:     {
226:         if ($strSource === null)
227:         {
228:             $strSource = $this->getDataDefinition()->getBasicDefinition()->getDataProvider();
229:         }
230: 
231:         if (isset($this->arrDataProvider[$strSource]))
232:         {
233:             return $this->arrDataProvider[$strSource];
234:         }
235: 
236:         throw new DcGeneralRuntimeException(sprintf('Data provider %s not defined', $strSource));
237:     }
238: 
239:     /**
240:      * {@inheritdoc}
241:      */
242:     public function addDataProvider($strSource, $dataProvider)
243:     {
244:         // Force removal of an potentially registered data provider to ease sub-classing.
245:         $this->removeDataProvider($strSource);
246: 
247:         $this->arrDataProvider[$strSource] = $dataProvider;
248: 
249:         return $this;
250:     }
251: 
252:     /**
253:      * {@inheritdoc}
254:      */
255:     public function removeDataProvider($strSource)
256:     {
257:         if (isset($this->arrDataProvider[$strSource]))
258:         {
259:             unset($this->arrDataProvider[$strSource]);
260:         }
261: 
262:         return $this;
263:     }
264: 
265:     /**
266:      * Retrieve the data provider for the named source.
267:      *
268:      * If a source name is given, the named data provider will get returned, if not given, the default data provider
269:      * will get returned, the default is to be determined via: getEnvironment()->getDataDefinition()->getDataProvider()
270:      *
271:      * @param string|null $strSource The name of the source.
272:      *
273:      * @return \DcGeneral\Data\DataProviderInterface
274:      *
275:      * @deprecated Use getDataProvider() instead!
276:      */
277:     public function getDataDriver($strSource = null)
278:     {
279:         trigger_error(
280:             __CLASS__ . '::getDataDriver() is deprecated - please use ' . __CLASS__ . '::getDataProvider().',
281:             E_USER_DEPRECATED
282:         );
283:         return $this->getDataProvider($strSource);
284:     }
285: 
286:     /**
287:      * Register a data provider to the environment.
288:      *
289:      * @param string                          $strSource The name of the source.
290:      *
291:      * @param \DcGeneral\Data\DataProviderInterface $dataProvider The data provider instance to register under the given name.
292:      *
293:      * @return EnvironmentInterface
294:      *
295:      * @deprecated Use addDataProvider() instead!
296:      */
297:     public function addDataDriver($strSource, $dataProvider)
298:     {
299:         trigger_error(
300:             __CLASS__ . '::addDataDriver() is deprecated - please use ' . __CLASS__ . '::addDataProvider().',
301:             E_USER_DEPRECATED
302:         );
303:         // Force removal of an potentially registered data provider to ease sub-classing.
304:         $this->addDataProvider($strSource, $dataProvider);
305: 
306:         return $this;
307:     }
308: 
309:     /**
310:      * Remove a data provider from the environment.
311:      *
312:      * @param string $strSource The name of the source.
313:      *
314:      * @return EnvironmentInterface
315:      *
316:      * @deprecated use removeDataProvider() instead!
317:      */
318:     public function removeDataDriver($strSource)
319:     {
320:         trigger_error(
321:             __CLASS__ . '::removeDataDriver() is deprecated - please use ' . __CLASS__ . '::removeDataProvider().',
322:             E_USER_DEPRECATED
323:         );
324:         $this->removeDataProvider($strSource);
325: 
326:         return $this;
327:     }
328: 
329:     /**
330:      * Store the panel container in the view.
331:      *
332:      * @param \DcGeneral\Panel\PanelContainerInterface $objPanelContainer The panel container.
333:      *
334:      * @throws DcGeneralInvalidArgumentException When an invalid view instance is stored in the environment.
335:      *
336:      * @return EnvironmentInterface
337:      *
338:      * @deprecated use the proper interface in the view!
339:      */
340:     public function setPanelContainer($objPanelContainer)
341:     {
342:         trigger_error(
343:             __CLASS__ . '::setPanelContainer() is deprecated - please use the proper interface in the view.',
344:             E_USER_DEPRECATED
345:         );
346: 
347:         if (!(($view = $this->getView()) instanceof BaseView))
348:         {
349:             throw new DcGeneralInvalidArgumentException(
350:                 __CLASS__ . '::setPanelContainer() got an invalid view instance passed.'
351:             );
352:         }
353: 
354:         /** @var BaseView $view */
355:         $view->setPanel($objPanelContainer);
356:         return $this;
357:     }
358: 
359:     /**
360:      * Retrieve the panel container.
361:      *
362:      * @return \DcGeneral\Panel\PanelContainerInterface
363:      *
364:      * @throws DcGeneralInvalidArgumentException When an invalid view instance is stored in the environment.
365:      *
366:      * @deprecated use the proper interface in the view!
367:      */
368:     public function getPanelContainer()
369:     {
370:         trigger_error(
371:             __CLASS__ . '::setPanelContainer() is deprecated - please use the proper interface in the view.',
372:             E_USER_DEPRECATED
373:         );
374: 
375:         if (!(($view = $this->getView()) instanceof BaseView))
376:         {
377:             throw new DcGeneralInvalidArgumentException(
378:                 __CLASS__ . '::setPanelContainer() got an invalid view instance passed.'
379:             );
380:         }
381: 
382:         /** @var BaseView $view */
383:         return $view->getPanel();
384:     }
385: 
386:     /**
387:      * {@inheritdoc}
388:      */
389:     public function getClipboard()
390:     {
391:         return $this->objClipboard;
392:     }
393: 
394:     /**
395:      * {@inheritdoc}
396:      */
397:     public function setClipboard($objClipboard)
398:     {
399:         if (is_null($objClipboard))
400:         {
401:             unset($this->objClipboard);
402:         }
403:         else
404:         {
405:             $this->objClipboard = $objClipboard;
406:         }
407: 
408:         return $this;
409:     }
410: 
411:     /**
412:      * {@inheritdoc}
413:      */
414:     public function setTranslator(TranslatorInterface $translator)
415:     {
416:         $this->translator = $translator;
417: 
418:         return $this;
419:     }
420: 
421:     /**
422:      * {@inheritdoc}
423:      */
424:     public function getTranslator()
425:     {
426:         return $this->translator;
427:     }
428: 
429:     /**
430:      * {@inheritdoc}
431:      */
432:     public function setEventPropagator($propagator)
433:     {
434:         $this->eventPropagator = $propagator;
435:     }
436: 
437:     /**
438:      * {@inheritdoc}
439:      */
440:     public function getEventPropagator()
441:     {
442:         return $this->eventPropagator;
443:     }
444: }
445: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0