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: 
 18: /**
 19:  * Condition checking that the value of a property is false.
 20:  */
 21: class PropertyFalseCondition implements PropertyConditionInterface
 22: {
 23:     /**
 24:      * The property name.
 25:      *
 26:      * @var string
 27:      */
 28:     protected $propertyName;
 29: 
 30:     /**
 31:      * Use strict compare mode.
 32:      *
 33:      * @var bool
 34:      */
 35:     protected $strict;
 36: 
 37:     /**
 38:      * Create a new instance.
 39:      *
 40:      * @param string $propertyName The name of the property.
 41:      *
 42:      * @param bool   $strict       Flag if the comparison shall be strict (type safe).
 43:      */
 44:     public function __construct($propertyName, $strict = false)
 45:     {
 46:         $this->propertyName = (string)$propertyName;
 47:         $this->strict       = (bool)$strict;
 48:     }
 49: 
 50:     /**
 51:      * Set the property name.
 52:      *
 53:      * @param string $propertyName The property name.
 54:      *
 55:      * @return PropertyTrueCondition
 56:      */
 57:     public function setPropertyName($propertyName)
 58:     {
 59:         $this->propertyName = (string)$propertyName;
 60: 
 61:         return $this;
 62:     }
 63: 
 64:     /**
 65:      * Retrieve the property name.
 66:      *
 67:      * @return string
 68:      */
 69:     public function getPropertyName()
 70:     {
 71:         return $this->propertyName;
 72:     }
 73: 
 74:     /**
 75:      * Set the flag if the comparison shall be strict (type safe).
 76:      *
 77:      * @param boolean $strict The flag.
 78:      *
 79:      * @return PropertyTrueCondition
 80:      */
 81:     public function setStrict($strict)
 82:     {
 83:         $this->strict = (bool)$strict;
 84: 
 85:         return $this;
 86:     }
 87: 
 88:     /**
 89:      * Retrieve the flag if the comparison shall be strict (type safe).
 90:      *
 91:      * @return boolean
 92:      */
 93:     public function getStrict()
 94:     {
 95:         return $this->strict;
 96:     }
 97: 
 98:     /**
 99:      * {@inheritdoc}
100:      */
101:     public function match(ModelInterface $model = null, PropertyValueBag $input = null)
102:     {
103:         if ($input && $input->hasPropertyValue($this->propertyName))
104:         {
105:             $value = $input->getPropertyValue($this->propertyName);
106:         }
107:         elseif ($model)
108:         {
109:             $value = $model->getProperty($this->propertyName);
110:         }
111:         elseif ($this->strict)
112:         {
113:             return false;
114:         }
115:         else
116:         {
117:             return true;
118:         }
119: 
120:         return $this->strict ? ($value === false) : !$value;
121:     }
122: 
123:     /**
124:      * {@inheritdoc}
125:      */
126:     public function __clone()
127:     {
128:     }
129: }
130: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0