Warning, file /webapps/ocs-webserver/library/Zend/Log/Filter/Message.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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_Log
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 /** Zend_Log_Filter_Abstract */
0024 // require_once 'Zend/Log/Filter/Abstract.php';
0025 
0026 /**
0027  * @category   Zend
0028  * @package    Zend_Log
0029  * @subpackage Filter
0030  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0031  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0032  * @version    $Id$
0033  */
0034 class Zend_Log_Filter_Message extends Zend_Log_Filter_Abstract
0035 {
0036     /**
0037      * @var string
0038      */
0039     protected $_regexp;
0040 
0041     /**
0042      * Filter out any log messages not matching $regexp.
0043      *
0044      * @param  string  $regexp     Regular expression to test the log message
0045      * @return void
0046      * @throws Zend_Log_Exception
0047      */
0048     public function __construct($regexp)
0049     {
0050         if (@preg_match($regexp, '') === false) {
0051             // require_once 'Zend/Log/Exception.php';
0052             throw new Zend_Log_Exception("Invalid regular expression '$regexp'");
0053         }
0054         $this->_regexp = $regexp;
0055     }
0056 
0057     /**
0058      * Create a new instance of Zend_Log_Filter_Message
0059      *
0060      * @param  array|Zend_Config $config
0061      * @return Zend_Log_Filter_Message
0062      */
0063     static public function factory($config)
0064     {
0065         $config = self::_parseConfig($config);
0066         $config = array_merge(array(
0067             'regexp' => null
0068         ), $config);
0069 
0070         return new self(
0071             $config['regexp']
0072         );
0073     }
0074 
0075     /**
0076      * Returns TRUE to accept the message, FALSE to block it.
0077      *
0078      * @param  array    $event    event data
0079      * @return boolean            accepted?
0080      */
0081     public function accept($event)
0082     {
0083         return preg_match($this->_regexp, $event['message']) > 0;
0084     }
0085 }