src/wcmf/lib/model/Node.php
public static function filter(array $nodeList, ObjectId $oid=null, $type=null, $values=null,
          $properties=null, $useRegExp=true) {

    $returnArray = [];
    for ($i=0, $count=sizeof($nodeList); $i<$count; $i++) {
      $curNode = $nodeList[$i];
      if ($curNode instanceof PersistentObject) {
        $match = true;
        // check oid
        if ($oid != null && $curNode->getOID() != $oid) {
          $match = false;
        }
        // check type
        if ($type != null) {
          $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
          $fqType = $persistenceFacade->getFullyQualifiedType($type);
          if ($fqType != null && $curNode->getType() != $fqType) {
            $match = false;
          }
        }
        // check values
        if ($values != null && is_array($values)) {
          foreach($values as $key => $value) {
            $nodeValue = $curNode->getValue($key);
            if ($useRegExp && !preg_match("/".$value."/m", $nodeValue) ||
                    !$useRegExp && $value != $nodeValue) {
              $match = false;
              break;
            }
          }
        }
        // check properties
        if ($properties != null && is_array($properties)) {
          foreach($properties as $key => $value) {
            $nodeProperty = $curNode->getProperty($key);
            if ($useRegExp && !preg_match("/".$value."/m", $nodeProperty) ||
                    !$useRegExp && $value != $nodeProperty) {
              $match = false;
              break;
            }
          }
        }
        if ($match) {
          $returnArray[] = $curNode;
        }
      }
      else {
        self::$logger->warn(StringUtil::getDump($curNode)." found, where a PersistentObject was expected.\n".ErrorHandler::getStackTrace(),
          __CLASS__);
      }
    }
    return $returnArray;
  }
public static function filter(array $nodeList, ObjectId $oid=null, $type=null, $values=null,
          $properties=null, $useRegExp=true) {

    $returnArray = [];
    for ($i=0, $count=sizeof($nodeList); $i<$count; $i++) {
      $curNode = $nodeList[$i];
      if ($curNode instanceof PersistentObject) {
        $match = true;
        // check oid
        if ($oid != null && $curNode->getOID() != $oid) {
          $match = false;
        }
        // check type
        if ($type != null) {
          $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
          $fqType = $persistenceFacade->getFullyQualifiedType($type);
          if ($fqType != null && $curNode->getType() != $fqType) {
            $match = false;
          }
        }
        // check values
        if ($values != null && is_array($values)) {
          foreach($values as $key => $value) {
            $nodeValue = $curNode->getValue($key);
            if ($useRegExp && !preg_match("/".$value."/m", $nodeValue) ||
                    !$useRegExp && $value != $nodeValue) {
              $match = false;
              break;
            }
          }
        }
        // check properties
        if ($properties != null && is_array($properties)) {
          foreach($properties as $key => $value) {
            $nodeProperty = $curNode->getProperty($key);
            if ($useRegExp && !preg_match("/".$value."/m", $nodeProperty) ||
                    !$useRegExp && $value != $nodeProperty) {
              $match = false;
              break;
            }
          }
        }
        if ($match) {
          $returnArray[] = $curNode;
        }
      }
      else {
        self::$logger->warn(StringUtil::getDump($curNode)." found, where a PersistentObject was expected.\n".ErrorHandler::getStackTrace(),
          __CLASS__);
      }
    }
    return $returnArray;
  }
public static function filter ( array $ nodeList , ObjectId $ oid = null , $ type = null , $ values = null , $ properties = null , $ useRegExp = true ) { $ returnArray = [ ] ; for ( $ i = 0 , $ count = sizeof ( $ nodeList ) ; $ i < $ count ; $ i ++ ) { $ curNode = $ nodeList [ $ i ] ; if ( $ curNode instanceof PersistentObject ) { $ match = true ; // check oid if ( $ oid != null && $ curNode -> getOID ( ) != $ oid ) { $ match = false ; } // check type if ( $ type != null ) { $ persistenceFacade = ObjectFactory :: getInstance ( 'persistenceFacade' ) ; $ fqType = $ persistenceFacade -> getFullyQualifiedType ( $ type ) ; if ( $ fqType != null && $ curNode -> getType ( ) != $ fqType ) { $ match = false ; } } // check values if ( $ values != null && is_array ( $ values ) ) { foreach ( $ values as $ key => $ value ) { $ nodeValue = $ curNode -> getValue ( $ key ) ; if ( $ useRegExp && ! preg_match ( "/" . $ value . "/m" , $ nodeValue ) || ! $ useRegExp && $ value != $ nodeValue ) { $ match = false ; break ; } } } // check properties if ( $ properties != null && is_array ( $ properties ) ) { foreach ( $ properties as $ key => $ value ) { $ nodeProperty = $ curNode -> getProperty ( $ key ) ; if ( $ useRegExp && ! preg_match ( "/" . $ value . "/m" , $ nodeProperty ) || ! $ useRegExp && $ value != $ nodeProperty ) { $ match = false ; break ; } } } if ( $ match ) { $ returnArray [ ] = $ curNode ; } } else { self :: $ logger -> warn ( StringUtil :: getDump ( $ curNode ) . " found, where a PersistentObject was expected.\n" . ErrorHandler :: getStackTrace ( ) , __CLASS__ ) ; } } return $ returnArray ; }
Get Nodes that match given conditions from a list.
@param $nodeList An array of nodes to filter or a single Node.
@param $oid The object id that the Nodes should match (optional, default: _null_)
@param $type The type that the Nodes should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_)
@param $values An associative array holding key value pairs that the Node values should match
(values are interpreted as regular expression, optional, default: _null_)
@param $properties An associative array holding key value pairs that the Node properties should match
(values are interpreted as regular expression, optional, default: _null_)
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return An Array holding references to the Nodes that matched.
Get Nodes that match given conditions from a list .