/** * 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); }
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'); }
public static function register() { if (in_array('phpspec', stream_get_wrappers())) { stream_wrapper_unregister('phpspec'); } stream_wrapper_register('phpspec', 'PhpSpec\\Loader\\StreamWrapper'); }
public function set_up() { stream_wrapper_unregister('https'); stream_wrapper_register('https', 'MockHttpStreamWrapper', STREAM_IS_URL); MockHttpStreamWrapper::clear(); parent::set_up(); }
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."); } } }
/** * 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__); } }
/** * unregisters vfsStreamWrapper */ public static function unregister() { if (in_array(vfsStream::SCHEME, stream_get_wrappers()) === true) { stream_wrapper_unregister(vfsStream::SCHEME); } self::$registered = false; }
protected function setUp() { if (in_array('sfImageSource', stream_get_wrappers())) { stream_wrapper_unregister('sfImageSource'); } stream_wrapper_register('sfImageSource', 'sfImageSourceMock') or die('Failed to register protocol..'); }
public static function activateHook() { foreach (static::$protocols as $protocol) { stream_wrapper_unregister($protocol); stream_wrapper_register($protocol, static::class); } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // Set up an intercepting proxy for getimagesize() calls stream_wrapper_unregister('http'); stream_wrapper_register('http', __CLASS__ . '_proxy'); }
public function setUp() { parent::setUp(); if (in_array($this->protocol, stream_get_wrappers())) { stream_wrapper_unregister($this->protocol); } }
public function testRegisterWithArgument() { $protocol = 'sftptest'; $this->assertTrue(Stream::register($protocol)); $this->assertContains($protocol, stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister($protocol)); }
public static function unregisterWrapper() { $existed = in_array('stack', stream_get_wrappers()); if ($existed) { stream_wrapper_unregister('stack'); } }
public static function wrap() { foreach (static::$protocols as $protocol) { stream_wrapper_unregister($protocol); stream_wrapper_register($protocol, get_called_class()); } }
/** * Register a stream wrapper according to its scheme and class. * Must called prior the opening of first stream under this scheme */ public static function registerStreamWrapper() { if (in_array(static::SCHEME, stream_get_wrappers())) { stream_wrapper_unregister(static::SCHEME); } stream_register_wrapper(static::SCHEME, get_called_class()); }
/** * 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)); } }
function disable_wrappers() { $wrappers = array("php", "http", "https", "ftp", "ftps", "compress.zlib", "compress.bzip2", "zip", "glob", "data"); foreach ($wrappers as $v) { stream_wrapper_unregister($v); } }
/** * Tear down the hooks, url filtering etc for S3 Uploads */ public function tear_down() { stream_wrapper_unregister('s3'); remove_filter('upload_dir', array($this, 'filter_upload_dir')); remove_filter('wp_image_editors', array($this, 'filter_editors'), 9); remove_filter('wp_handle_sideload_prefilter', array($this, 'filter_sideload_move_temp_file_to_s3')); }
public static function enable() { if (!isset(self::$intercept) || !isset(self::$replacement)) { throw new NoIncludeInterceptSetException('Set a file to intercept and its replacement before enabling wrapper'); } stream_wrapper_unregister('file'); stream_wrapper_register('file', __CLASS__); }
/** * @param array $options the options for the context to wrap the stream with * @param string $class * @return resource */ protected static function wrapWithOptions($options, $class) { $context = stream_context_create($options); stream_wrapper_register('dirwrapper', $class); $wrapped = opendir('dirwrapper://', $context); stream_wrapper_unregister('dirwrapper'); return $wrapped; }
public static function register() { if (in_array(static::$protocol, stream_get_wrappers())) { stream_wrapper_unregister(static::$protocol); } stream_wrapper_register(static::$protocol, get_called_class(), STREAM_IS_URL); static::$registered = true; }
protected function setUp() { if (in_array('sfImageSource', stream_get_wrappers())) { stream_wrapper_unregister('sfImageSource'); } stream_wrapper_register('sfImageSource', 'sfImageSourcePropel') or die('Failed to register protocol..'); $this->testSourceUri = sfImageSourcePropel::buildURIfromParameters($this->testParameters); }
/** * Register the 's3://' stream wrapper * * @param Aws\S3\S3Client $client * @param string $protocol */ public static function register(Aws\S3\S3Client $client, $protocol = 's3') { if (in_array($protocol, stream_get_wrappers())) { stream_wrapper_unregister($protocol); } stream_wrapper_register($protocol, __CLASS__, STREAM_IS_URL); static::$client = $client; }
public function tearDown() { foreach (array('webdav', 'webdavs') as $wrapper) { if (in_array($wrapper, stream_get_wrappers())) { stream_wrapper_unregister($wrapper); } } }
protected function setUp() { // remove any xmlseq stream-wrapper as it might be a left-over from a previous test if (in_array('xmlseq', stream_get_wrappers())) { stream_wrapper_unregister('xmlseq'); } parent::setUp(); }
private function register($return = true) { if (in_array("file", stream_get_wrappers())) { stream_wrapper_unregister('file'); } stream_wrapper_register('file', $this->registered_cLass); return $return; }
/** * Register the 's3://' stream wrapper * * @param S3Client $client Client to use with the stream wrapper */ public static function register_streamwrapper($s3_uploads) { static::$s3_uploads = $s3_uploads; if (in_array('s3', stream_get_wrappers())) { stream_wrapper_unregister('s3'); } stream_wrapper_register('s3', __CLASS__, STREAM_IS_URL); }
public static function unregister($scheme) { if (!isset(self::$basePaths[$scheme])) { return; } unset(self::$basePaths[$scheme]); stream_wrapper_unregister($scheme); }
/** * @param $scheme * @return $this */ public function remove($scheme) { if (isset($this->items[$scheme])) { stream_wrapper_unregister($scheme); unset($this->items[$scheme]); } return $this; }
/** * Wrap a stream from libsmbclient-php into a regular php stream * * @param \SMBBundle\SMB\NativeState $state * @param resource $smbStream * @param string $mode * @return resource */ public static function wrap($state, $smbStream, $mode) { stream_wrapper_register('nativesmb', '\\SMBBundle\\SMB\\NativeStream'); $context = stream_context_create(array('nativesmb' => array('state' => $state, 'handle' => $smbStream))); $fh = fopen('nativesmb://', $mode, false, $context); stream_wrapper_unregister('nativesmb'); return $fh; }