protected function validateCompFilters(VObject\Component $parent, array $filters)
    {
        foreach ($filters as $filter) {
            $isDefined = isset($parent->{$filter['name']});

            if ($filter['is-not-defined']) {
                if ($isDefined) {
                    return false;
                } else {
                    continue;
                }
            }
            if (!$isDefined) {
                return false;
            }

            if ($filter['time-range']) {
                foreach ($parent->{$filter['name']} as $subComponent) {
                    if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
                        continue 2;
                    }
                }

                return false;
            }

            if (!$filter['comp-filters'] && !$filter['prop-filters']) {
                continue;
            }

            // If there are sub-filters, we need to find at least one component
            // for which the subfilters hold true.
            foreach ($parent->{$filter['name']} as $subComponent) {
                if (
                    $this->validateCompFilters($subComponent, $filter['comp-filters']) &&
                    $this->validatePropFilters($subComponent, $filter['prop-filters'])) {
                    // We had a match, so this comp-filter succeeds
                    continue 2;
                }
            }

            // If we got here it means there were sub-comp-filters or
            // sub-prop-filters and there was no match. This means this filter
            // needs to return false.
            return false;
        }

        // If we got here it means we got through all comp-filters alive so the
        // filters were all true.
        return true;
    }
protected function validateCompFilters(VObject\Component $parent, array $filters)
    {
        foreach ($filters as $filter) {
            $isDefined = isset($parent->{$filter['name']});

            if ($filter['is-not-defined']) {
                if ($isDefined) {
                    return false;
                } else {
                    continue;
                }
            }
            if (!$isDefined) {
                return false;
            }

            if ($filter['time-range']) {
                foreach ($parent->{$filter['name']} as $subComponent) {
                    if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
                        continue 2;
                    }
                }

                return false;
            }

            if (!$filter['comp-filters'] && !$filter['prop-filters']) {
                continue;
            }

            // If there are sub-filters, we need to find at least one component
            // for which the subfilters hold true.
            foreach ($parent->{$filter['name']} as $subComponent) {
                if (
                    $this->validateCompFilters($subComponent, $filter['comp-filters']) &&
                    $this->validatePropFilters($subComponent, $filter['prop-filters'])) {
                    // We had a match, so this comp-filter succeeds
                    continue 2;
                }
            }

            // If we got here it means there were sub-comp-filters or
            // sub-prop-filters and there was no match. This means this filter
            // needs to return false.
            return false;
        }

        // If we got here it means we got through all comp-filters alive so the
        // filters were all true.
        return true;
    }
protected function validateCompFilters ( VObject \ Component $ parent , array $ filters ) { foreach ( $ filters as $ filter ) { $ isDefined = isset ( $ parent -> { $ filter [ 'name' ] } ) ; if ( $ filter [ 'is-not-defined' ] ) { if ( $ isDefined ) { return false ; } else { continue ; } } if ( ! $ isDefined ) { return false ; } if ( $ filter [ 'time-range' ] ) { foreach ( $ parent -> { $ filter [ 'name' ] } as $ subComponent ) { if ( $ this -> validateTimeRange ( $ subComponent , $ filter [ 'time-range' ] [ 'start' ] , $ filter [ 'time-range' ] [ 'end' ] ) ) { continue 2 ; } } return false ; } if ( ! $ filter [ 'comp-filters' ] && ! $ filter [ 'prop-filters' ] ) { continue ; } // If there are sub-filters, we need to find at least one component // for which the subfilters hold true. foreach ( $ parent -> { $ filter [ 'name' ] } as $ subComponent ) { if ( $ this -> validateCompFilters ( $ subComponent , $ filter [ 'comp-filters' ] ) && $ this -> validatePropFilters ( $ subComponent , $ filter [ 'prop-filters' ] ) ) { // We had a match, so this comp-filter succeeds continue 2 ; } } // If we got here it means there were sub-comp-filters or // sub-prop-filters and there was no match. This means this filter // needs to return false. return false ; } // If we got here it means we got through all comp-filters alive so the // filters were all true. return true ; }
This method checks the validity of comp-filters.

A list of comp-filters needs to be specified. Also the parent of the
component we're checking should be specified, not the component to check
itself.

@param VObject\Component $parent
@param array             $filters

@return bool
This method checks the validity of comp - filters .