File indexing completed on 2025-03-02 05:29:31
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Ldap 0017 * @subpackage Filter 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Ldap_Filter_Abstract 0025 */ 0026 // require_once 'Zend/Ldap/Filter/Abstract.php'; 0027 /** 0028 * @see Zend_Ldap_Filter_String 0029 */ 0030 // require_once 'Zend/Ldap/Filter/String.php'; 0031 0032 /** 0033 * Zend_Ldap_Filter_Logical provides a base implementation for a grouping filter. 0034 * 0035 * @category Zend 0036 * @package Zend_Ldap 0037 * @subpackage Filter 0038 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0039 * @license http://framework.zend.com/license/new-bsd New BSD License 0040 */ 0041 abstract class Zend_Ldap_Filter_Logical extends Zend_Ldap_Filter_Abstract 0042 { 0043 const TYPE_AND = '&'; 0044 const TYPE_OR = '|'; 0045 0046 /** 0047 * All the sub-filters for this grouping filter. 0048 * 0049 * @var array 0050 */ 0051 private $_subfilters; 0052 0053 /** 0054 * The grouping symbol. 0055 * 0056 * @var string 0057 */ 0058 private $_symbol; 0059 0060 /** 0061 * Creates a new grouping filter. 0062 * 0063 * @param array $subfilters 0064 * @param string $symbol 0065 */ 0066 protected function __construct(array $subfilters, $symbol) 0067 { 0068 foreach ($subfilters as $key => $s) { 0069 if (is_string($s)) $subfilters[$key] = new Zend_Ldap_Filter_String($s); 0070 else if (!($s instanceof Zend_Ldap_Filter_Abstract)) { 0071 /** 0072 * @see Zend_Ldap_Filter_Exception 0073 */ 0074 // require_once 'Zend/Ldap/Filter/Exception.php'; 0075 throw new Zend_Ldap_Filter_Exception('Only strings or Zend_Ldap_Filter_Abstract allowed.'); 0076 } 0077 } 0078 $this->_subfilters = $subfilters; 0079 $this->_symbol = $symbol; 0080 } 0081 0082 /** 0083 * Adds a filter to this grouping filter. 0084 * 0085 * @param Zend_Ldap_Filter_Abstract $filter 0086 * @return Zend_Ldap_Filter_Logical 0087 */ 0088 public function addFilter(Zend_Ldap_Filter_Abstract $filter) 0089 { 0090 $new = clone $this; 0091 $new->_subfilters[] = $filter; 0092 return $new; 0093 } 0094 0095 /** 0096 * Returns a string representation of the filter. 0097 * 0098 * @return string 0099 */ 0100 public function toString() 0101 { 0102 $return = '(' . $this->_symbol; 0103 foreach ($this->_subfilters as $sub) $return .= $sub->toString(); 0104 $return .= ')'; 0105 return $return; 0106 } 0107 }