Development

/branches/1.2/lib/plugin/sfPearFrontendPlugin.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugin/sfPearFrontendPlugin.class.php

Revision 9131, 1.4 kB (checked in by Carl.Vondrick, 6 years ago)

1.1: fixed @param phpdoc to fit specs in plugin (refs #2991)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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$
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 }
64
Note: See TracBrowser for help on using the browser.