Return an array of all elements in the $substitutionGroup
@param string $substitutionGroup
@return array[QName]
325755
public function getElementsInSubstitutionGroup( $substitutionGroup )
	{
		// Check the substitution group exists as an element
		if ( isset( $this->elements[ $substitutionGroup ] ) )
		{
			$result[] = \lyquidity\xml\qname( $substitutionGroup, $this->processedSchemas );
		}
		else if ( ! isset( $this->types[ $substitutionGroup ] ) )
		{
			return false;
		}

		foreach ( $this->elements as $key => $element )
		{
			if ( ! isset( $element['substitutionGroup'] ) )
			{
				continue;
			}

			if ( ! $this->resolveToSubstitutionGroup( $element['substitutionGroup'], array( $substitutionGroup ) ) )
			{
				continue;
			}

			$result[] = \lyquidity\xml\qname( $key, $this->processedSchemas );
		}

		return $result;
	}
427592
public function serialize(Group $group, array $options = [])
    {
        return [
            'id' => $group->getUuid(),
            'name' => $group->getName(),
            'roles' => array_map(function (Role $role) use ($options) {
                return $this->roleSerializer->serialize($role, $options);
            }, $group->getEntityRoles()->toArray()),
            'organizations' => array_map(function (Organization $organization) use ($options) {
                return $this->organizationSerializer->serialize($organization, $options);
            }, $group->getOrganizations()->toArray()),
        ];
    }
360375
public function getFullName(): ?string
    {
        if (null === $this->getName()) {
            return null;
        }

        if (!($this instanceof ElementHasParentInterface)) {
            return $this->getName();
        }

        $parents = $this->getParents();

        if ($parents->empty()) {
            return $this->getName();
        }

        $chain = $parents->append($this);
        $sliced = new Collection();
        foreach ($chain->reverse() as $el) {
            if (null === $el->getName()) {
                break;
            }
            $sliced->prepend($el);
        }
        if (1 === count($sliced)) {
            return $this->getName();
        }

        $names = [];
        $first = $sliced->first();
        foreach ($sliced as $el) {
            if ($el === $first) {
                $names[] = $el->getName();
            } else {
                $names[] = $el->getParent()->searchSame($el);
            }
        }

        return $names[0] . '[' . implode('][', array_slice($names, 1)) . ']';

    }
968314
public function gatherElementsFromType( $type )
	{
		if ( is_string( $type ) )
		{
			$type = $this->getType( $type );
		}

		if ( ! is_array( $type ) ) return false;

		$elements = array();

		foreach ( array( 'elements', 'sequence', 'choice', 'group' ) as $typeComponent )
		{
			if ( ! isset( $type[ $typeComponent ] ) )
			{
				continue;
			}

			foreach ( $type[ $typeComponent ] as $id => $element )
			{
				if ( $id == 'restrictionType')
				{
					continue;
				}

				if ( $id == 'elements' )
				{
					$elements += $element;
					continue;
				}

				$result = $this->gatherElementsFromType( $element );
				if ( ! $result )
				{
					$elements[ "{$element['prefix']}:{$element['name']}" ] = $element;
				}

				$elements += $result;
			}

		}

		return $elements;
	}
524304
public static function getConfig($optionGroup, $optionName)
    {
        if (!array_key_exists($optionGroup, self::$config) || !is_array(self::$config[$optionGroup])) {
            return;
        }

        if (!array_key_exists($optionName, self::$config[$optionGroup])) {
            return;
        }

        return self::$config[$optionGroup][$optionName];
    }
441972
private function sortGroup(array $group)
    {
        if (empty($group)) {
            return [];
        }

        if ($this->sortType == self::SORT_TYPE_LENGTH) {
            usort($group, function ($a, $b) {
                $cmp = strlen($b) - strlen($a);

                if ($cmp === 0) {
                    $a = strtolower($a);
                    $b = strtolower($b);

                    $cmp = strcmp($b, $a);
                }

                return $cmp;
            });
        } elseif ($this->sortType == self::SORT_TYPE_ALPHABETIC) {
            usort($group, function ($a, $b) {
                $a = strtolower($a);
                $b = strtolower($b);

                $cmp = strcmp($b, $a);
                if ($cmp === 0) {
                    $cmp = strlen($b) - strlen($a);
                }

                return $cmp;
            });
        }

        if ($this->sortDirection == self::SORT_DIRECTION_ASC) {
            $group = array_reverse($group);
        }

        return $group;
    }
47948
protected function getVariables($showAll)
    {
        $scopeVars = $this->context->getAll();
        \uksort($scopeVars, function ($a, $b) {
            $aIndex = \array_search($a, self::$specialNames);
            $bIndex = \array_search($b, self::$specialNames);

            if ($aIndex !== false) {
                if ($bIndex !== false) {
                    return $aIndex - $bIndex;
                }

                return 1;
            }

            if ($bIndex !== false) {
                return -1;
            }

            return \strnatcasecmp($a, $b);
        });

        $ret = [];
        foreach ($scopeVars as $name => $val) {
            if (!$showAll && \in_array($name, self::$specialNames)) {
                continue;
            }

            $ret[$name] = $val;
        }

        return $ret;
    }
489385
public function get_roles($group = null)
	{
		// When group is empty, attempt to get groups from a current login
		if ($group === null)
		{
			if ($login = \Auth::instance()
				and is_array($groups = $login->get_groups())
				and isset($groups[0][1]))
			{
				$group = $groups[0][1];
			}
		}

		// if it's a group id, find the corresponding object
		elseif (is_numeric($group) and isset(static::$_valid_groups[$group]))
		{
			$group = static::$_valid_groups[$group];
		}

		// if the group was found, return the roles
		if ($group instanceOf Model\Auth_Group)
		{
			return $group->roles;
		}
		else
		{
			// no group found, so no roles either
			return array();
		}
	}
860194
public function dbGroup($dbGroup = null)
    {
        if ($dbGroup === null)
        {
            return $this->_dbGroup;
        }
        $this->_dbGroup = $dbGroup;

        return $this;
    }
228576
public function getTemplate(array $config)
	{
		foreach ($this->templateGenerators as $type => $generator)
		{
			if (isset($config[$type]))
			{
				return $generator->getTemplate($config[$type]);
			}
		}

		return '';
	}
1310657
public function getCacheGroup($cacheGroup)
    {
        return !empty($this->cacheGroups[$cacheGroup]) ? $this->cacheGroups[$cacheGroup] : null;
    }
848244
public function getNumParams($group = '_default')
	{
		if (!isset($this->_xml[$group]) || !count($this->_xml[$group]->children()))
		{
			return false;
		}

		return count($this->_xml[$group]->children());
	}
331176
public function fetchAll(string $group = null)
    {
        if (static::$options === null) {
            static::$options = $this
                ->createModel()
                ->when($group, function ($query, $group) {
                    return $query->where('group', $group);
                })
                ->orderBy('group', 'asc')
                ->orderBy('key', 'asc')
                ->get();
        }

        return static::$options;
    }
340391
protected function iteratorToArray(Traversable $config, $delimiter) {
		$rows = [];
		
		foreach ($config as $key => $value) {
			if ($value instanceof Traversable) {
				foreach ($this->iteratorToArray($value, $delimiter) as $subkey => $subvalue) {
					$rows[$key . $delimiter . $subkey] = $subvalue;
				}
			} else {
				$rows[$key] = $value;
			}
		}
		
		return $rows;
	}
655733
public static function fromQName( $name )
	{
		$types = SchemaTypes::getInstance();

		if ( $name instanceof QName )
		{
			// If prefix is empty try looking it up
			if ( empty( $name->prefix ) )
			{
				$prefix = $types->getPrefixForNamespace( $name->namespaceURI );
				if ( $prefix ) $name->prefix = $prefix;
			}
			$qname = "{$name->prefix}:{$name->localName}";
		}
		else if ( is_string( $name ) )
		{
			$qname = $name;
		}
		else
		{
			throw new \InvalidArgumentException( "$qname must be string or a QName instance" );
		}

		$element = $types->getElement( $qname );

		if ( ! $element )
		{
			return null;
		}

		$result = new DOMSchemaElement();
		$result->QualifiedName = $name;
		$type = is_array( $element['types'][0] ) && isset( $element['types'][0]['parent'] )
			? $element['types'][0]['parent']
			: $element['types'][0];
		// if ( is_array( $element['types'][0] ) )
		// {
		// 	$x = 1;
		// }
		$elementType = is_array( $type ) ? false : $types->getType( $type );
		$result->ElementSchemaType = $elementType;
		$result->SchemaTypeName = $elementType['name'];
		$result->SubstitutionGroup = isset( $element['substitutionGroup'] ) ? $element['substitutionGroup'] : $type;
		// error_log( __CLASS__ . " need to populate the DOMSchemaElement instance" );
		return $result;
	}
255394
public function substituteCtrlCharacters($string, $substitution = '_')
    {
        static $chars_in = null;

        if (is_null($chars_in)) {

            $chars_in = [];

            for ($cc = 0; $cc < 32; $cc ++) {
                if (in_array($cc, [9, 10, 13])) {
                    continue;
                }

                $chars_in[] = chr($cc);
            }
        }

        return str_replace($chars_in, $substitution, $string);
    }
559890
public function transform(string $config = ''): array
    {
        $parsed = [];
        if (!empty($config)) {
            $config = \parse_ini_string($config, true, INI_SCANNER_RAW);
            if (\is_array($config)) {
                $parsed = $this->processNode($config);
            }
        }
        return $parsed;
    }