Register Stream Wrapper

@param iWrapperStream $wrapper
@param null           $label   Wrapper Label
- If Not Set Using iSWrapper::getLabel

@throws \Exception If Wrapper Registered Before
480987
static function register(iWrapperStream $wrapper, $label = null)
    {
        if ($label == null)
            $label = $wrapper->getLabel();

        if ($pos = strpos($label, ':') !== false)
            throw new \Exception(sprintf(
                '(%s) Is Invalid Label Provided For Stream Wrapper.'
                . ' It must include just a name like "http".'
                , $label
            ));

        stream_wrapper_register($label, get_class($wrapper));

        // Set the default stream context which will be used whenever
        // file operations (fopen(), file_get_contents(), etc...) are
        // called without a context parameter.
        $options = array(
            $label => \Poirot\Std\cast($wrapper->optsData())->toArray()
        );

        stream_context_set_default($options);
    }
775075
public function getLabelWrapper($key = null, $default = null)
    {
        if (!isset($this->attributes['labelWrapper'])) {
            return $default;
        }
        if (!is_null($key) && !array_key_exists($key, $this->attributes['labelWrapper'])) {
            return $default;
        }
        if (is_null($key)) {
            return $this->attributes['labelWrapper'];
        }
        if (!is_null($key) && array_key_exists($key, $this->attributes['labelWrapper'])) {
            return $this->attributes['labelWrapper'][$key];
        }
    }
652660
private function initContentWrapper()
    {
        if ($this->getAutoloader()->isRestored()) {
            return $this;
        }

        if (null === $contentwrapperConfig = $this->getConfig()->getContentwrapperConfig()) {
            throw new BBException('None class content wrapper found');
        }

        $namespace = isset($contentwrapperConfig['namespace']) ? $contentwrapperConfig['namespace'] : '';
        $protocol = isset($contentwrapperConfig['protocol']) ? $contentwrapperConfig['protocol'] : '';
        $adapter = isset($contentwrapperConfig['adapter']) ? $contentwrapperConfig['adapter'] : '';

        $this->getAutoloader()->registerStreamWrapper($namespace, $protocol, $adapter);

        return $this;
    }
917676
public function getFormGroup($name = null, $label = null, $wrapperElement)
    {
        if (is_null($label)) {
            return $this->getFormGroupWithoutLabel($name, $wrapperElement);
        }
        return $this->getFormGroupWithLabel($name, $label, $wrapperElement);
    }
339310
protected void registerLabelAttributes() {
        addAttributeProcessor(new EllipsisLmlAttribute(), "ellipsis");
        addAttributeProcessor(new LabelAlignmentLmlAttribute(), "labelAlign", "labelAlignment");
        addAttributeProcessor(new LineAlignmentLmlAttribute(), "lineAlign", "lineAlignment");
        addAttributeProcessor(new TextAlignmentLmlAttribute(), "textAlign", "textAlignment");
        addAttributeProcessor(new WrapLmlAttribute(), "wrap");
    }
897580
final void setCompatibilityWrapper(JSCompatibleMessageImpl wrapper) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.entry(this, tc, "setCompatibilityWrapper", wrapper);

        synchronized (getMessageLockArtefact()) {
            compatibilityWrapperOrSelf = wrapper;
            // If we are our own master & e've just been wrapped in a JSCompatibleMessage, then we
            // need to update the master reference.
            if (master == this) {
                setMaster();
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            JmfTr.exit(this, tc, "setCompatibilityWrapper");
    }
115325
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
    {
        if (!$data) {
            // TODO: Don't rely on $_POST
            if (isset($_POST) && !empty($_POST)) {
                $value = 'no';
            } elseif ($this->get('default_state') == 'on') {
                $value = 'yes';
            } else {
                $value = 'no';
            }
        } else {
            $value = ($data['value'] === 'yes' ? 'yes' : 'no');
        }

        $label = Widget::Label();

        if ($this->get('required') !== 'yes') {
            $label->appendChild(new XMLElement('i', __('Optional')));
        }

        $input = Widget::Input('fields'.$fieldnamePrefix.'['.$this->get('element_name').']'.$fieldnamePostfix, 'yes', 'checkbox', ($value === 'yes' ? array('checked' => 'checked') : null));

        $label->setValue($input->generate(false) . ' ' . $this->get('label'));

        if ($flagWithError != null) {
            $wrapper->appendChild(Widget::Error($label, $flagWithError));
        } else {
            $wrapper->appendChild($label);
        }
    }
1185310
public function render(ElementInterface $element, $groupWrapper = null, $controlWrapper = null)
    {
        $labelHelper         = $this->getLabelHelper();
        $elementHelper       = $this->getElementHelper();
        $elementErrorsHelper = $this->getElementErrorsHelper();
        $descriptionHelper   = $this->getDescriptionHelper();
        $groupWrapper        = $groupWrapper ? : $this->groupWrapper;
        $controlWrapper      = $controlWrapper ? : $this->controlWrapper;
        $renderer            = $elementHelper->getView();

        $id = $element->getAttribute('id') ? : $element->getAttribute('name');

        $label = $element->getLabel();
        if (null === $label) {
            $label = $element->getOption('label') ? : $element->getAttribute('label');
        }

        if (method_exists($renderer, 'plugin')) {
            if ($element instanceof \Zend\Form\Element\Radio) {
                $renderer->plugin('form_radio')->setLabelAttributes(array(
                    'class' => 'radio',
                ));
            }
        }

        $elementString       = $elementHelper->render($element);
        $descriptionString   = $descriptionHelper->render($element);
        $elementErrorsString = $this->renderErrors ? $elementErrorsHelper->render($element) : null;

        $controlMarkup = sprintf($controlWrapper, $id, $elementString, $descriptionString, $elementErrorsString);

        if ($label) {
            $element->setLabelAttributes(array('class' => 'control-label'));
            $labelString = $labelHelper($element, $label);

            switch ($this->labelPosition) {
                case self::LABEL_PREPEND:
                    $controlMarkup = $labelString . $controlMarkup;
                    break;
                case self::LABEL_APPEND:
                default:
                    $controlMarkup .= $labelString;
                    break;
            }
        }

        $addtClass   = $element->getMessages() ? ' error' : '';
        $groupMarkup = sprintf($groupWrapper, $addtClass, $id, $controlMarkup);

        return $groupMarkup;
    }
175589
protected function renderControl(ElementInterface $element, $elementString, $id, $controlWrapper = null)
    {
        $description = $this->getDescriptionHelper()->render($element);
        $label       = $this->renderLabel($element);
        $control     = $this->renderControlWrapper($id, $element, $elementString, $description, $controlWrapper);
        if ($label) {
            switch ($this->labelPosition) {
                case self::LABEL_PREPEND:
                    return $label . $control;
                case self::LABEL_APPEND:
                default:
                    return $control . $label;
            }
        }
        return $control;
    }
1099692
public static function getResource(StreamInterface $stream)
    {
        $mode = null;
        if ($stream->isReadable()) {
            $mode = 'r';
        }

        if ($stream->isWritable()) {
            $mode = !empty($mode) ? 'r+' : 'w';
        }

        if (empty($mode)) {
            throw new WrapperException("Stream is not available in read or write modes");
        }

        return fopen(self::localFilename($stream), $mode);
    }
1227747
public function initializeStreamWrapper()
    {
        $stream = new Stream('accompli', array(
                'recipe' => realpath(__DIR__.'/Resources/recipe'),
            ), false);

        StreamManager::create()->registerStream($stream);
    }
1092250
private function createConfigWrapper(): ConfigWrapper
    {
        $factory = new LazyLoadingValueHolderFactory();
        $initializer = function (&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) {
            $initializer = null;
            $wrappedObject = new ConfigWrapper($this->aggregator->getConfig());

            return true;
        };

        return $factory->createProxy(ConfigWrapper::class, $initializer);
    }
1366672
public static function register($flags = null)
    {
        $protocol = static::PROTOCOL;

        if (static::isRegistered()) {
            return true;
        }
        if (null === $flags) {
            $flags = STREAM_IS_URL;
        }

        return stream_wrapper_register($protocol, static::class, $flags);
    }
656194
public function registerStreamWrapper($protocol=null)
    {
        if ($this->registered_wrapper) {
            throw new \RuntimeException("Unregister the wrapper before registering it again!");
        }
        if ($protocol && !$this->protocol) {
            $this->protocol = $protocol; 
        }
        $this->registered_wrapper = true;
        self::$handlers[$this->protocol] = $this;
        return stream_wrapper_register($this->protocol, __CLASS__, 0);
    }
796294
public function init($streamWrapper = self::STREAM_WRAPPER_TEMP, $maxMemory = 5242880)
    {

        // weather we've already set a filename open the input stream
        if ($tmpFilename = $this->getTmpFilename()) {
            if (!$this->inputStream = fopen($tmpFilename, 'r+')) {
                throw new \Exception(sprintf('Can\'t open input temporary filename %s', $tmpFilename));
            }
        } else {
            if (!$this->inputStream = fopen($streamWrapper . '/maxmemory:' . $maxMemory, 'r+')) {
                throw new \Exception(sprintf('Can\'t open stream wrapper %s', $streamWrapper));
            }
        }
    }
168092
void bootstrapPlugin(IProducerRegistry producerRegistry) throws PHPPluginBootstrapException {

        config.setConfigChangedNotifier(new ConfigChangedNotifierImpl());
        MappersRegistry mappersRegistry = new MappersRegistry();
        listener = new OnProducerDataReceivedListenerImpl(mappersRegistry, producerRegistry);

        for (MapperConfig mapperConfig : config.getMappers()) {

            try {

                mappersRegistry.registerMapper(
                        mapperConfig.getMapperId(),
                        ((Mapper) createInstance(mapperConfig.getMapperClass()))
                );

            } catch (ClassNotFoundException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper class " + mapperConfig.getMapperClass() + " not found", e
                );
            } catch (NoSuchMethodException | IllegalAccessException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper class must have default public constructor", e
                );
            } catch (InvocationTargetException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper constructor throws exception", e
                );
            } catch (InstantiationException e) {
                throw new PHPPluginBootstrapException(
                        "Failed to instance mapper of class " + mapperConfig.getMapperClass(), e
                );
            } catch (ClassCastException e) {
                throw new PHPPluginBootstrapException(
                        "Class " + mapperConfig.getMapperClass() +
                                " is not instance of " + Mapper.class.getCanonicalName(), e
                );
            }

        }

        boolean enableConnectorsInitOnStartup
                = PROPERTY_TRUE_VALUE.equals(startupProperties.getProperty(PROPERTY_CONNECTORS_FORCE_ENABLED));

       configureConnectors(enableConnectorsInitOnStartup);

    }
812263
public function initialize()
    {
        $this->initializeStreamWrapper();
        $this->initializeContainer();
        $this->initializeEventListeners();

        $this->dispatch(AccompliEvents::INITIALIZE);
    }