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

  • DefaultBasicDefinition
  • DefaultDataProviderDefinition
  • DefaultModelRelationshipDefinition
  • DefaultPalettesDefinition
  • DefaultPropertiesDefinition

Interfaces

  • BasicDefinitionInterface
  • DataProviderDefinitionInterface
  • DefinitionInterface
  • ModelRelationshipDefinitionInterface
  • PalettesDefinitionInterface
  • PropertiesDefinitionInterface
  • ViewDefinitionInterface
  • 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\DataDefinition\Definition;
 14: 
 15: use DcGeneral\DataDefinition\ModelRelationship\ParentChildConditionInterface;
 16: use DcGeneral\DataDefinition\ModelRelationship\RootConditionInterface;
 17: 
 18: /**
 19:  * Default implementation of a model relationship definition.
 20:  *
 21:  * @package DcGeneral\DataDefinition\Definition
 22:  */
 23: class DefaultModelRelationshipDefinition implements ModelRelationshipDefinitionInterface
 24: {
 25:     /**
 26:      * The root condition relationship.
 27:      *
 28:      * @var RootConditionInterface
 29:      */
 30:     protected $rootCondition;
 31: 
 32:     /**
 33:      * A collection of parent child conditions.
 34:      *
 35:      * @var ParentChildConditionInterface[]
 36:      */
 37:     protected $childConditions = array();
 38: 
 39:     /**
 40:      * {@inheritdoc}
 41:      */
 42:     public function setRootCondition($condition)
 43:     {
 44:         $this->rootCondition = $condition;
 45: 
 46:         return $this;
 47:     }
 48: 
 49:     /**
 50:      * {@inheritdoc}
 51:      */
 52:     public function getRootCondition()
 53:     {
 54:         return $this->rootCondition;
 55:     }
 56: 
 57:     /**
 58:      * {@inheritdoc}
 59:      */
 60:     public function addChildCondition($condition)
 61:     {
 62:         $hash = spl_object_hash($condition);
 63: 
 64:         $this->childConditions[$hash] = $condition;
 65: 
 66:         return $this;
 67:     }
 68: 
 69:     /**
 70:      * {@inheritdoc}
 71:      */
 72:     public function getChildCondition($srcProvider, $dstProvider)
 73:     {
 74:         foreach ($this->getChildConditions($srcProvider) as $condition)
 75:         {
 76:             if ($condition->getDestinationName() == $dstProvider)
 77:             {
 78:                 return $condition;
 79:             }
 80:         }
 81: 
 82:         return null;
 83:     }
 84: 
 85:     /**
 86:      * {@inheritdoc}
 87:      */
 88:     public function getChildConditions($srcProvider = '')
 89:     {
 90: 
 91:         if (!$this->childConditions)
 92:         {
 93:             return array();
 94:         }
 95: 
 96:         $arrReturn = array();
 97:         foreach ($this->childConditions as $condition)
 98:         {
 99:             if ($condition->getSourceName() != $srcProvider)
100:             {
101:                 continue;
102:             }
103: 
104:             $arrReturn[] = $condition;
105:         }
106: 
107:         return $arrReturn;
108:     }
109: }
110: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0