Initial Drupal 11 with DDEV setup
This commit is contained in:
		
							
								
								
									
										30
									
								
								web/core/tests/Drupal/Tests/StreamCapturer.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								web/core/tests/Drupal/Tests/StreamCapturer.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Drupal\Tests;
 | 
			
		||||
 | 
			
		||||
// cspell:ignore datalen PSFS_FEED_ME writeable
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Captures output to a stream and stores it for retrieval.
 | 
			
		||||
 */
 | 
			
		||||
class StreamCapturer extends \php_user_filter {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The cache data.
 | 
			
		||||
   *
 | 
			
		||||
   * @var string
 | 
			
		||||
   */
 | 
			
		||||
  public static $cache = '';
 | 
			
		||||
 | 
			
		||||
  public function filter($in, $out, &$consumed, $closing): int {
 | 
			
		||||
    while ($bucket = stream_bucket_make_writeable($in)) {
 | 
			
		||||
      self::$cache .= $bucket->data;
 | 
			
		||||
      $consumed += $bucket->datalen;
 | 
			
		||||
      stream_bucket_append($out, $bucket);
 | 
			
		||||
    }
 | 
			
		||||
    return PSFS_FEED_ME;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user