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

  • BooleanCondition
  • NotCondition
  • PropertyConditionChain
  • PropertyFalseCondition
  • PropertyTrueCondition
  • PropertyValueCondition

Interfaces

  • PropertyConditionInterface
  • 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\Palette\Condition\Property;
14: 
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\Data\PropertyValueBag;
17: use DcGeneral\DataDefinition\AbstractConditionChain;
18: use DcGeneral\Exception\DcGeneralRuntimeException;
19: 
20: /**
21:  * A chain of property conditions.
22:  */
23: class PropertyConditionChain extends AbstractConditionChain implements PropertyConditionInterface
24: {
25:     /**
26:      * {@inheritdoc}
27:      *
28:      * @throws DcGeneralRuntimeException When an condition that does not implement PropertyConditionInterface
29:      *                                   is encountered.
30:      */
31:     public function match(ModelInterface $model = null, PropertyValueBag $input = null)
32:     {
33:         if ($this->conjunction == static::AND_CONJUNCTION)
34:         {
35:             foreach ($this->conditions as $condition)
36:             {
37:                 if (!($condition instanceof PropertyConditionInterface))
38:                 {
39:                     throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
40:                 }
41: 
42:                 if (!$condition->match($model, $input))
43:                 {
44:                     return false;
45:                 }
46:             }
47: 
48:             return true;
49:         }
50: 
51:         foreach ($this->conditions as $condition)
52:         {
53:             if (!($condition instanceof PropertyConditionInterface))
54:             {
55:                 throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
56:             }
57: 
58:             if ($condition->match($model, $input))
59:             {
60:                 return true;
61:             }
62:         }
63: 
64:         return false;
65:     }
66: }
67: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0