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

  • AbstractWeightAwarePaletteCondition
  • DefaultPaletteCondition
  • PaletteConditionChain
  • PropertyFalseCondition
  • PropertyTrueCondition
  • PropertyValueCondition

Interfaces

  • PaletteConditionInterface
  • WeightAwarePaletteConditionInterface
  • 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\Palette;
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 palette conditions.
22:  */
23: class PaletteConditionChain extends AbstractConditionChain implements PaletteConditionInterface
24: {
25:     /**
26:      * {@inheritdoc}
27:      *
28:      * @throws DcGeneralRuntimeException When an condition that does not implement PaletteConditionInterface
29:      *                                   is encountered.
30:      */
31:     public function getMatchCount(ModelInterface $model = null, PropertyValueBag $input = null)
32:     {
33:         $totalCount = false;
34: 
35:         foreach ($this->conditions as $condition)
36:         {
37:             if (!($condition instanceof PaletteConditionInterface))
38:             {
39:                 throw new DcGeneralRuntimeException('Invalid condition in chain: '. get_class($condition));
40:             }
41: 
42:             $conditionCount = $condition->getMatchCount($model, $input);
43: 
44:             if ($conditionCount !== false)
45:             {
46:                 $totalCount += $conditionCount;
47:             }
48:             elseif ($this->conjunction == static::AND_CONJUNCTION)
49:             {
50:                 return false;
51:             }
52:         }
53: 
54:         return $totalCount;
55:     }
56: }
57: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0