Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
require_once 'PEAR/Frontend.php';
12
require_once 'PEAR/Frontend/CLI.php';
13
 
14
/**
15
 * The PEAR Frontend object.
16
 *
17
 * @package    symfony
18
 * @subpackage plugin
19
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
20
 * @version    SVN: $Id: sfPearFrontendPlugin.class.php 9131 2008-05-21 04:12:00Z Carl.Vondrick $
21
 */
22
class sfPearFrontendPlugin extends PEAR_Frontend_CLI
23
{
24
  protected
25
    $dispatcher = null;
26
 
27
  /**
28
   * Sets the sfEventDispatcher object for this frontend.
29
   *
30
   * @param sfEventDispatcher $dispatcher The sfEventDispatcher instance
31
   */
32
  public function setEventDispatcher(sfEventDispatcher $dispatcher)
33
  {
34
    $this->dispatcher = $dispatcher;
35
  }
36
 
37
  public function _displayLine($text)
38
  {
39
    $this->_display($text);
40
  }
41
 
42
  public function _display($text)
43
  {
44
    $this->dispatcher->notify(new sfEvent($this, 'application.log', $this->splitLongLine($text)));
45
  }
46
 
47
  protected function splitLongLine($text)
48
  {
49
    $lines = '';
50
    foreach (explode("\n", $text) as $longline)
51
    {
52
      foreach (explode("\n", wordwrap($longline, 62)) as $line)
53
      {
54
        if ($line = trim($line))
55
        {
56
          $lines[] = $line;
57
        }
58
      }
59
    }
60
 
61
    return $lines;
62
  }
63
}