src/wcmf/lib/model/ObjectQuery.php
public function valueChanged(ValueChangeEvent $event) {
    $object = $event->getObject();
    $name = $event->getValueName();
    $initialOid = $object->getProperty(self::PROPERTY_INITIAL_OID);
    if (isset($this->observedObjects[$initialOid])) {
      $newValue = $event->getNewValue();
      // make a criteria from newValue and make sure that all properties are set
      if (!($newValue instanceof Criteria)) {
        // LIKE fallback, if the value is not a Criteria instance
        $mapper = self::getMapper($object->getType());
        $pkNames = $mapper->getPkNames();
        if (!in_array($name, $pkNames)) {
          // use like condition on any attribute, if it's a string
          // other value changes will be ignored!
          if (is_string($newValue)) {
            $newValue = new Criteria($object->getType(), $name, 'LIKE', '%'.$newValue.'%');
          }
        }
        else {
          // don't search for pk names with LIKE
          $newValue = new Criteria($object->getType(), $name, '=', $newValue);
        }
      }
      else {
        // make sure that type and name are set even if the Criteria is constructed
        // via Criteria::forValue()
        $newValue->setType($object->getType());
        $newValue->setAttribute($name);
      }

      $oid = $object->getOID()->__toString();
      // store change in internal array to have it when constructing the query
      if (!isset($this->conditions[$oid])) {
        $this->conditions[$oid] = [];
      }
      $this->conditions[$oid][$name] = $newValue;
    }
  }
public function valueChanged(ValueChangeEvent $event) {
    $object = $event->getObject();
    $name = $event->getValueName();
    $initialOid = $object->getProperty(self::PROPERTY_INITIAL_OID);
    if (isset($this->observedObjects[$initialOid])) {
      $newValue = $event->getNewValue();
      // make a criteria from newValue and make sure that all properties are set
      if (!($newValue instanceof Criteria)) {
        // LIKE fallback, if the value is not a Criteria instance
        $mapper = self::getMapper($object->getType());
        $pkNames = $mapper->getPkNames();
        if (!in_array($name, $pkNames)) {
          // use like condition on any attribute, if it's a string
          // other value changes will be ignored!
          if (is_string($newValue)) {
            $newValue = new Criteria($object->getType(), $name, 'LIKE', '%'.$newValue.'%');
          }
        }
        else {
          // don't search for pk names with LIKE
          $newValue = new Criteria($object->getType(), $name, '=', $newValue);
        }
      }
      else {
        // make sure that type and name are set even if the Criteria is constructed
        // via Criteria::forValue()
        $newValue->setType($object->getType());
        $newValue->setAttribute($name);
      }

      $oid = $object->getOID()->__toString();
      // store change in internal array to have it when constructing the query
      if (!isset($this->conditions[$oid])) {
        $this->conditions[$oid] = [];
      }
      $this->conditions[$oid][$name] = $newValue;
    }
  }
public function valueChanged ( ValueChangeEvent $ event ) { $ object = $ event -> getObject ( ) ; $ name = $ event -> getValueName ( ) ; $ initialOid = $ object -> getProperty ( self :: PROPERTY_INITIAL_OID ) ; if ( isset ( $ this -> observedObjects [ $ initialOid ] ) ) { $ newValue = $ event -> getNewValue ( ) ; // make a criteria from newValue and make sure that all properties are set if ( ! ( $ newValue instanceof Criteria ) ) { // LIKE fallback, if the value is not a Criteria instance $ mapper = self :: getMapper ( $ object -> getType ( ) ) ; $ pkNames = $ mapper -> getPkNames ( ) ; if ( ! in_array ( $ name , $ pkNames ) ) { // use like condition on any attribute, if it's a string // other value changes will be ignored! if ( is_string ( $ newValue ) ) { $ newValue = new Criteria ( $ object -> getType ( ) , $ name , 'LIKE' , '%' . $ newValue . '%' ) ; } } else { // don't search for pk names with LIKE $ newValue = new Criteria ( $ object -> getType ( ) , $ name , '=' , $ newValue ) ; } } else { // make sure that type and name are set even if the Criteria is constructed // via Criteria::forValue() $ newValue -> setType ( $ object -> getType ( ) ) ; $ newValue -> setAttribute ( $ name ) ; } $ oid = $ object -> getOID ( ) -> __toString ( ) ; // store change in internal array to have it when constructing the query if ( ! isset ( $ this -> conditions [ $ oid ] ) ) { $ this -> conditions [ $ oid ] = [ ] ; } $ this -> conditions [ $ oid ] [ $ name ] = $ newValue ; } }
Listen to ValueChangeEvents
@param $event ValueChangeEvent instance
Listen to ValueChangeEvents