public function setUp()
 {
     $this->checkSkipTest();
     $this->bundle = new Bundle\RackspaceCloudfiles();
     $this->bundle->setDocRoot(__DIR__ . '/_files');
     stream_wrapper_register('rscf', 'RackspaceCloudFilesStreamWrapper') or die("Failed to register rscf:// protocol");
 }
Example #2
0
 /**
  *
  * Constructor for HiEngine
  *
  * Sets up the stream protocol handler
  */
 public function __construct()
 {
     $streams = stream_get_wrappers();
     if (!in_array('hi', $streams)) {
         stream_wrapper_register("hi", "HiEngineParser") or die(_t("Failed to register HiEngine stream protocol"));
     }
 }
Example #3
0
 function setUpFS()
 {
     ArrayFileStream::set_filesystem(array('dynamic' => array('course' => array($this->avatar_id . '_normal.png' => '', $this->avatar_id . '_medium.png' => '', $this->avatar_id . '_small.png' => ''))));
     if (!stream_wrapper_register("var", "ArrayFileStream")) {
         new Exception("Failed to register protocol");
     }
 }
Example #4
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // Set up an intercepting proxy for getimagesize() calls
     stream_wrapper_unregister('http');
     stream_wrapper_register('http', __CLASS__ . '_proxy');
 }
Example #5
0
 public static function wrap()
 {
     foreach (static::$protocols as $protocol) {
         stream_wrapper_unregister($protocol);
         stream_wrapper_register($protocol, get_called_class());
     }
 }
Example #6
0
 function __construct($orientation = 'P', $unit = 'mm', $size = 'A4')
 {
     parent::__construct($orientation, $unit, $size);
     $this->lineHeightPadding = 30 / $this->k;
     $this->SetAutoPageBreak(false);
     stream_wrapper_register("var", 'PhpSigep\\Pdf\\VariableStream') or die("Failed to register protocol");
 }
Example #7
0
 /**
  * @expectedException \MockFs\Exception\StreamException
  */
 public function testRegisterAnAlreadyRegisteredSchemeThrowsException()
 {
     $protocol = 'mock';
     stream_wrapper_register($protocol, __CLASS__);
     $stream = Stream::getInstance();
     $stream->register($protocol);
 }
 public function set_up()
 {
     stream_wrapper_unregister('https');
     stream_wrapper_register('https', 'MockHttpStreamWrapper', STREAM_IS_URL);
     MockHttpStreamWrapper::clear();
     parent::set_up();
 }
 public function testEvent()
 {
     $provider = $this->getProvider();
     $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true));
     $media = new Media();
     $media->setBinaryContent('x9wjql');
     $media->setId(1023456);
     stream_wrapper_unregister('http');
     stream_wrapper_register('http', 'Sonata\\MediaBundle\\Tests\\Provider\\FakeHttpWrapper');
     // pre persist the media
     $provider->prePersist($media);
     $this->assertEquals('Thomas Rabaix - les tests fonctionnels - Symfony Live 2009', $media->getName(), '::getName() return the file name');
     $this->assertEquals('x9wjql', $media->getProviderReference(), '::getProviderReference() is set');
     // post persit the media
     $provider->postPersist($media);
     $provider->postRemove($media);
     $media->setProviderStatus('fake');
     $provider->preUpdate($media);
     $this->assertEquals(MediaInterface::STATUS_OK, $media->getProviderStatus());
     $provider->postUpdate($media);
     $media->setProviderStatus('fake');
     $media->setBinaryContent(null);
     $provider->prePersist($media);
     $this->assertEquals('fake', $media->getProviderStatus());
     $provider->preUpdate($media);
     $this->assertEquals('fake', $media->getProviderStatus());
     $provider->postPersist($media);
     $this->assertEquals('fake', $media->getProviderStatus());
     $provider->preRemove($media);
     stream_wrapper_restore('http');
 }
Example #10
0
 /**
  * TODO don't hardcode pool, use params
  * TODO check rados extensions are available
  * @param $params
  */
 public function __construct($params)
 {
     $this->pool = 'owncloud';
     if (!in_array("rados", stream_get_wrappers())) {
         stream_wrapper_register("rados", '\\OCA\\Rados\\RadosStream');
     }
 }
Example #11
0
	function MEM_IMAGE($orientation='P',$unit='mm',$format='A4')
	{
		$this->FPDF($orientation, $unit, $format);
		//Register var stream protocol (requires PHP>=4.3.2)
		if(function_exists('stream_wrapper_register'))
			stream_wrapper_register('var','VariableStream');
	}
Example #12
0
 public static function register($scheme, $container)
 {
     if (!stream_wrapper_register($scheme, static::class)) {
         throw new \RuntimeException('Cannot register stream wrapper');
     }
     self::$containers[$scheme] = $container;
 }
Example #13
0
 /**
  * Constructs CustomURIResolver from scheme prefix string (e.g. "arg" or "http").
  * @param string $scheme Scheme prefix string
  */
 function __construct($scheme)
 {
     $this->scheme = $scheme;
     if (!in_array($scheme, stream_get_wrappers())) {
         stream_wrapper_register($scheme, "StringStream") or die("Failed to register '" . $scheme . "'");
     }
 }
Example #14
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Service_Amazon_S3::setKeys(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEYID'));
     if (!stream_wrapper_register('s3', 'Zend_Service_Amazon_S3')) {
         $this->fail('Unable to register s3:// streams wrapper');
     }
 }
Example #15
0
 /**
  * @return string
  */
 protected function create()
 {
     $id = uniqid('stream');
     eval(sprintf('namespace %s { class %s extends \\%s {}; }', __NAMESPACE__, self::PROXY_CLASSNAME . '_' . $id, __NAMESPACE__ . '\\' . self::PROXY_CLASSNAME));
     stream_wrapper_register($id, $this->getProxyClassName($id));
     return $id;
 }
 /**
  * Register the GridFS stream wrapper.
  */
 public static function register()
 {
     if (in_array('gridfs', stream_get_wrappers())) {
         stream_wrapper_unregister('gridfs');
     }
     stream_wrapper_register('gridfs', get_called_class(), \STREAM_IS_URL);
 }
Example #17
0
 /**
  * Registers the stream wrapper to handle the specified scheme
  *
  * @param  string $schema Default is gaufrette
  */
 public static function register($scheme = 'gaufrette')
 {
     @stream_wrapper_unregister($scheme);
     if (!stream_wrapper_register($scheme, __CLASS__)) {
         throw new \RuntimeException(sprintf('Could not register stream wrapper class %s for scheme %s.', __CLASS__, $scheme));
     }
 }
Example #18
0
 public static function register()
 {
     if (in_array('phpspec', stream_get_wrappers())) {
         stream_wrapper_unregister('phpspec');
     }
     stream_wrapper_register('phpspec', 'PhpSpec\\Loader\\StreamWrapper');
 }
 protected function init(Container $container, ResourceLocator $locator)
 {
     $schemes = $container['config']->get('streams.schemes');
     if (!$schemes) {
         return;
     }
     // Set locator to both streams.
     Stream::setLocator($locator);
     ReadOnlyStream::setLocator($locator);
     $registered = stream_get_wrappers();
     foreach ($schemes as $scheme => $config) {
         if (isset($config['paths'])) {
             $locator->addPath($scheme, '', $config['paths']);
         }
         if (isset($config['prefixes'])) {
             foreach ($config['prefixes'] as $prefix => $paths) {
                 $locator->addPath($scheme, $prefix, $paths);
             }
         }
         if (in_array($scheme, $registered)) {
             stream_wrapper_unregister($scheme);
         }
         $type = !empty($config['type']) ? $config['type'] : 'ReadOnlyStream';
         if ($type[0] != '\\') {
             $type = '\\Grav\\Component\\Filesystem\\StreamWrapper\\' . $type;
         }
         if (!stream_wrapper_register($scheme, $type)) {
             throw new \InvalidArgumentException("Stream '{$type}' could not be initialized.");
         }
     }
 }
Example #20
0
 /**
  * Install this stream wrapper.
  */
 public static function install()
 {
     $wrappers = stream_get_wrappers();
     if (!in_array('madmodel', $wrappers)) {
         stream_wrapper_register('madmodel', 'Mad_Model_Stream');
     }
 }
Example #21
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex:///template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     // 3 slashes needed to sidestep some server url include protections
     // example: https://www.strato.de/faq/article/622/Warum-erhalte-ich-über-PHP-die-Fehlermeldung-%22Warning:-main()-…:-include(….).html
     $path = 'rex:///' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
		static function registerStream()
		{
			if (!in_array("efile", stream_get_wrappers()))
			{
				stream_wrapper_register("efile", "ExtendedFileStream");
			}
		}
Example #23
0
 /**
  * Constructor
  *
  * @param string $streamWrapperClassName
  */
 public function __construct($streamWrapperClassName)
 {
     $registered = in_array(self::WRAPPER, stream_get_wrappers());
     if (!$registered) {
         stream_wrapper_register(self::WRAPPER, $streamWrapperClassName);
     }
 }
Example #24
0
 /**
  * ctor for the view-object takes config-parameters (from a Controller) initialized in module-setup
  * @param array $options
  */
 public function __construct($options = [])
 {
     // enable use of stream wrapper if short-tags are used/supported
     $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
     // check setting to force usage of stream wrapper, enabling short-tags usage even if disabled
     if (array_key_exists('useStreamWrapper', $options)) {
         $this->_useStreamWrapper = (bool) $options['useStreamWrapper'];
         unset($options['useStreamWrapper']);
     }
     // set if custom stream-wrapper should be used
     if ($this->_useViewStream && $this->_useStreamWrapper) {
         if (!$this->hasStreamWrapper()) {
             stream_wrapper_register('slick.view', 'SlickFW\\Mvc\\View\\Stream');
         }
     }
     // add filters to use somewhere upon setting public members that are passed through to the output
     if (isset($options['filters'])) {
         $this->_filter = $options['filters'];
     } else {
         $this->_filter = [];
     }
     // walk through options-array to assign further settings
     $props = get_object_vars($this);
     foreach ($options as $key => $value) {
         if (array_key_exists('_' . $key, $props)) {
             $this->{'_' . $key} = $value;
         }
     }
 }
Example #25
0
 /**
  * Create a stream from multiple data sources.
  *
  * @since 2.1.0
  *
  * @param array $data  An array of strings and/or streams to combine into
  *                     a single stream.
  *
  * @return resource  A PHP stream.
  */
 public static function getStream($data)
 {
     if (!self::$_id) {
         stream_wrapper_register(self::WRAPPER_NAME, __CLASS__);
     }
     return fopen(self::WRAPPER_NAME . '://' . ++self::$_id, 'wb', false, stream_context_create(array(self::WRAPPER_NAME => array('data' => $data))));
 }
Example #26
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex://template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     $path = 'rex://' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
Example #27
0
 /**
  * Creates an ImportXMLReader drawing from the source provided
  * @param ImportSource $source
  * @param Config $config
  */
 function __construct(ImportSource $source, Config $config = null)
 {
     $this->reader = new XMLReader();
     if (!$config) {
         wfDeprecated(__METHOD__ . ' without a Config instance', '1.25');
         $config = ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $this->config = $config;
     if (!in_array('uploadsource', stream_get_wrappers())) {
         stream_wrapper_register('uploadsource', 'UploadSourceAdapter');
     }
     $id = UploadSourceAdapter::registerSource($source);
     if (defined('LIBXML_PARSEHUGE')) {
         $this->reader->open("uploadsource://{$id}", null, LIBXML_PARSEHUGE);
     } else {
         $this->reader->open("uploadsource://{$id}");
     }
     // Default callbacks
     $this->setPageCallback(array($this, 'beforeImportPage'));
     $this->setRevisionCallback(array($this, "importRevision"));
     $this->setUploadCallback(array($this, 'importUpload'));
     $this->setLogItemCallback(array($this, 'importLogItem'));
     $this->setPageOutCallback(array($this, 'finishImportPage'));
     $this->importTitleFactory = new NaiveImportTitleFactory();
 }
 public static function activateHook()
 {
     foreach (static::$protocols as $protocol) {
         stream_wrapper_unregister($protocol);
         stream_wrapper_register($protocol, static::class);
     }
 }
Example #29
0
 /**
  * Registers current class as the PHP file stream wrapper.
  *
  * @return void
  */
 public function intercept()
 {
     if (!$this->isIntercepting) {
         stream_wrapper_unregister(self::PROTOCOL);
         $this->isIntercepting = stream_wrapper_register(self::PROTOCOL, __CLASS__);
     }
 }
 /**
  * registriert ein neues Protokoll
  *
  * @static
  *
  * @param string $proto
  * @param string $dir
  */
 public static function register($proto, $dir)
 {
     $protocol = $proto == null ? static::$proto : $proto;
     static::$protocolMaps[$protocol] = [];
     static::$basedir = $dir;
     stream_wrapper_register($protocol, get_called_class());
 }