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

  • AbstractCondition
  • ParentChildCondition
  • RootCondition

Interfaces

  • ParentChildConditionInterface
  • RootConditionInterface
  • 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\ModelRelationship;
 14: 
 15: use DcGeneral\Exception\DcGeneralRuntimeException;
 16: 
 17: /**
 18:  * Default implementation of a root condition.
 19:  *
 20:  * @package DcGeneral\DataDefinition\ModelRelationship
 21:  */
 22: class RootCondition
 23:     extends AbstractCondition
 24:     implements RootConditionInterface
 25: {
 26:     /**
 27:      * The filter rules to use.
 28:      *
 29:      * @var array
 30:      */
 31:     protected $filter;
 32: 
 33:     /**
 34:      * The setter information to use when a model shall get marked as root item.
 35:      *
 36:      * @var array
 37:      */
 38:     protected $setOn;
 39: 
 40:     /**
 41:      * The name of the table this condition is being applied to.
 42:      *
 43:      * @var string
 44:      */
 45:     protected $sourceProvider;
 46: 
 47:     /**
 48:      * {@inheritdoc}
 49:      */
 50:     public function setFilterArray($value)
 51:     {
 52:         $this->filter = $value;
 53: 
 54:         return $this;
 55:     }
 56: 
 57:     /**
 58:      * {@inheritdoc}
 59:      */
 60:     public function getFilterArray()
 61:     {
 62:         return $this->filter;
 63:     }
 64: 
 65:     /**
 66:      * {@inheritdoc}
 67:      */
 68:     public function setSetters($value)
 69:     {
 70:         $this->setOn = $value;
 71: 
 72:         return $this;
 73:     }
 74: 
 75:     /**
 76:      * {@inheritdoc}
 77:      */
 78:     public function getSetters()
 79:     {
 80:         return $this->setOn;
 81:     }
 82: 
 83:     /**
 84:      * {@inheritdoc}
 85:      */
 86:     public function setSourceName($value)
 87:     {
 88:         $this->sourceProvider = $value;
 89: 
 90:         return $this;
 91:     }
 92: 
 93:     /**
 94:      * {@inheritdoc}
 95:      */
 96:     public function getSourceName()
 97:     {
 98:         return $this->sourceProvider;
 99:     }
100: 
101:     /**
102:      * {@inheritdoc}
103:      *
104:      * @throws DcGeneralRuntimeException When an incomplete rule is encountered in the setters.
105:      */
106:     public function applyTo($objModel)
107:     {
108:         if ($this->setOn)
109:         {
110:             foreach ($this->setOn as $rule)
111:             {
112:                 if (!($rule['property'] && isset($rule['value'])))
113:                 {
114:                     throw new DcGeneralRuntimeException(
115:                         'Error Processing root condition, you need to specify property and value: ' . var_export($rule, true),
116:                         1
117:                     );
118:                 }
119: 
120:                 $objModel->setProperty($rule['property'], $rule['value']);
121:             }
122:         }
123:         else
124:         {
125:             throw new DcGeneralRuntimeException(
126:                 'Error Processing root condition, you need to specify root condition setters.',
127:                 1
128:             );
129:         }
130: 
131:         return $this;
132:     }
133: 
134:     /**
135:      * {@inheritdoc}
136:      */
137:     public function matches($objModel)
138:     {
139:         if ($this->getFilterArray())
140:         {
141:             return $this->checkCondition($objModel, $this->getFilterArray());
142:         }
143: 
144:         return true;
145:     }
146: }
147: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0