MetaModels\Attribute\Base::handleMetaChange PHP Method

handleMetaChange() public method

public handleMetaChange ( $strMetaName, $varNewValue )
    public function handleMetaChange($strMetaName, $varNewValue)
    {
        // By default we accept any change of meta information.
        $this->set($strMetaName, $varNewValue);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Updates the meta information of the attribute.
  *
  * This tells the attribute to perform any actions that must be done to correctly initialize the new value
  * and to perform any action to undo the changes that had been done for the previous value.
  * i.e.: when an attribute type needs columns in an an auxiliary table, these will have to be updated herein.
  *
  * This method may throw an exception, when the new value is invalid or any problems appear, the MetaModelAttribute
  * will then keep the old meta value.
  *
  * @param string $strMetaName Name of the meta information that shall be updated.
  *
  * @param mixed  $varNewValue The new value for this meta information.
  *
  * @return \MetaModels\Attribute\IAttribute The instance of this attribute, to support chaining.
  */
 public function handleMetaChange($strMetaName, $varNewValue)
 {
     // By default we accept any change of meta information.
     if ($strMetaName == 'colname') {
         if ($this->get($strMetaName) != $varNewValue) {
             $this->renameColumn($varNewValue);
         }
         return $this;
     }
     return parent::handleMetaChange($strMetaName, $varNewValue);
 }