Set the default registry instance to a specified instance.

@param  Zend_Registry $registry An object instance of type Zend_Registry,
or a subclass.
@return void
@throws Zend_Exception if registry is already initialized.
491136
public static function setInstance(Zend_Registry $registry)
    {
        if (self::$_registry !== null) {
            include_once 'Zend/Exception.php';
            throw new Zend_Exception('Registry is already initialized');
        }

        self::setClassName(get_class($registry));
        self::$_registry = $registry;
    }
1272957
public function register($identifier, $value)
    {
        if ($this->isRegistered($identifier)) {
            throw new RegistryException(
                RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_TEXT . '(identifier: ' . $identifier . ')',
                RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_CODE
            );
        }

        $this->registry[$this->section][$identifier] = $value;
    }
596659
public function setRegistrations(array $registrations): self
    {
        array_map(function (Registration $r) {
        }, $registrations); // type check
        $this->registrations = $registrations;
        return $this;
    }
1311578
private function buildRegistries()
    {
        if (is_object($this->entity) && $this->isRegistryEntity($this->entity)) {
            $this->buildRegistryFromObject();
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Cannot build registries: current entity must be an instance of %s, current `%s`.',
                'BackBee\Bundle\Registry\RegistryEntityInterface',
                gettype($this->entity)
            ));
        }

        foreach ($this->registries as $registry) {
            $this->entity->{$registry->getKey()} = $registry->getValue();
        }
    }
481897
public function handle(ManagerRegistry $registry)
    {
        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();

        if (!$this->option('sql')) {
            $this->error('ATTENTION: This operation should not be executed in a production environment.');
        }

        foreach ($names as $name) {
            $em   = $registry->getManager($name);
            $tool = new SchemaTool($em);

            $this->message('Creating database schema for <info>' . $name . '</info> entity manager...', 'blue');

            if ($this->option('sql')) {
                $sql = $tool->getCreateSchemaSql($em->getMetadataFactory()->getAllMetadata());
                $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
            } else {
                $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
            }
        }

        $this->info('Database schema created successfully!');
    }
58375
public function setDefaultException(\Exception $defaultException = null)
    {
        if (!$defaultException instanceof Exception) {
            @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED);
        }
        $this->defaultException = $defaultException;
    }
267238
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->Controller = $this->_registry->getController();

        $this->_addFromConfigure();

        // set up the default helper
        $this->Controller->helpers['Utils.Menu'] = [];
    }
405616
public S setRegistry(RegistryConfig registry) {
        if (this.registry == null) {
            this.registry = new ArrayList<RegistryConfig>();
        }
        this.registry.add(registry);
        return castThis();
    }
107807
public function set(string $name, $value = null) : void
    {
        Arr::set($this->registry, $name, $value);
    }
148162
protected function registerRegistry()
    {
        $app = app();

		$this->app->singleton('registry', function ($app) {

			$config = $app->config->get('registry', array());

			return new Registry($app['db'], $app['registry.cache'], $config);

		});

    }
961413
public function createContext(Registry $registry)
    {
        // List of schemas can evolve, but we don't want to generate new schema dynamically added, so we "clone" the array
        // to have a fixed list of schemas
        $schemas = array_values($registry->getSchemas());

        /** @var Schema $schema */
        foreach ($schemas as $schema) {
            $jsonSchema = $this->serializer->deserialize(file_get_contents($schema->getOrigin()), 'Joli\Jane\Model\JsonSchema', 'json', [
                'document-origin' => $schema->getOrigin()
            ]);

            $this->chainGuesser->guessClass($jsonSchema, $schema->getRootName(), $schema->getOrigin() . '#', $registry);
        }

        foreach ($registry->getSchemas() as $schema) {
            foreach ($schema->getClasses() as $class) {
                $properties = $this->chainGuesser->guessProperties($class->getObject(), $schema->getRootName(), $class->getReference(), $registry);

                foreach ($properties as $property) {
                    $property->setType($this->chainGuesser->guessType($property->getObject(), $property->getName(), $property->getReference(), $registry));
                }

                $class->setProperties($properties);
            }
        }


        return new Context($registry);
    }
319135
public function handle(ManagerRegistry $registry)
    {
        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();

        foreach ($names as $name) {
            $em = $registry->getManager($name);

            $this->comment('');
            $this->message('Generating getter and setter for <info>' . $name . '</info> entity manager...', 'blue');

            $cmf = new DisconnectedClassMetadataFactory();
            $cmf->setEntityManager($em);
            $metadatas = $cmf->getAllMetadata();
            $metadatas = MetadataFilter::filter($metadatas, $this->option('filter'));

            $destPath = base_path($this->argument('dest-path') ?:'app/Entities');

            if (!is_dir($destPath)) {
                mkdir($destPath, 0777, true);
            }

            $destPath = realpath($destPath);

            if (!file_exists($destPath)) {
                throw new \InvalidArgumentException(
                    sprintf("Proxies destination directory ' < info>%s </info > ' does not exist.",
                        $em->getConfiguration()->getProxyDir())
                );
            }

            if (count($metadatas)) {

                // Create EntityGenerator
                $entityGenerator = new EntityGenerator();

                $entityGenerator->setGenerateAnnotations($this->option('generate-annotations'));
                $entityGenerator->setGenerateStubMethods($this->option('generate-methods'));
                $entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities'));
                $entityGenerator->setUpdateEntityIfExists($this->option('update-entities'));
                $entityGenerator->setNumSpaces($this->option('num-spaces'));
                $entityGenerator->setBackupExisting(!$this->option('no-backup'));

                if (($extend = $this->option('extend')) !== null) {
                    $entityGenerator->setClassToExtend($extend);
                }

                foreach ($metadatas as $metadata) {
                    $this->comment(
                        sprintf('Processing entity "<info>%s</info>"', $metadata->name)
                    );
                }

                // Generating Entities
                $entityGenerator->generate($metadatas, $destPath);

                // Outputting information message
                $this->comment(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
            }
        }
    }
241427
private static function setDefaultConfig() {
            if (!self::$defaults) {
                self::$defaults = [self::CFG_EXCEPTION_DEPTH        => 10,
                                   self::CFG_LOG_EXCEPTION_LOCATION => true];
            }
        }
57458
public function resetRegistry()
    {
        $aRegKeys = \OxidEsales\Eshop\Core\Registry::getKeys();

        $aSkippedClasses = array();

        foreach ($aRegKeys as $sKey) {
            if (!in_array($sKey, $aSkippedClasses)) {
                $oInstance = null;
                if (!isset($this->registryCache[$sKey])) {
                    try {
                        $oNewInstance = oxNew($sKey);
                        $this->registryCache[$sKey] = $oNewInstance;
                    } catch (\OxidEsales\Eshop\Core\Exception\SystemComponentException $oException) {
                        \OxidEsales\Eshop\Core\Registry::set($sKey, null);
                        continue;
                    }
                }
                $oInstance = clone $this->registryCache[$sKey];
                \OxidEsales\Eshop\Core\Registry::set($sKey, $oInstance);
            }
        }
    }
964051
public function init()
    {
        $this->load();

        if (!empty($this->registry[$this->section])) {
            throw new RegistryException(
                RegistryException::DUPLICATE_INITIATION_ATTEMPT_TEXT . '(section: ' . $this->section . ')',
                RegistryException::DUPLICATE_INITIATION_ATTEMPT_CODE
            );
        }

        $this->getDrupalCommonConnector()->variable_set($this->section, $this->registry[$this->section]);
    }
837979
public static function fromRegistry(ManagerRegistry $registry)
    {
        $drivers = array();
        foreach ($registry->getManagers() as $manager) {
            $drivers[] = self::fromManager($manager);
        }

        return new DriverChain($drivers);
    }
812914
public function setCache($cache, $namespace = null)
    {
        if($cache && ClassRegistryCache::isSupported())
        {
            $this->__registry = new ClassRegistryCache();

            if($namespace) {
                $this->__registry->setNamespace($namespace);
            }
        }
        else
        {
            if(!$this->__registry instanceof ClassRegistry) {
                $this->__registry = new ClassRegistry();
            }
        }

        return $this;
    }