Detect the group from the content type using cURL.

@return null|string
970275
protected function detectGroupFromContentType()
    {
        if (extension_loaded('curl'))
        {
            $this->getLogger()->warning('Attempting to determine asset group using cURL. This may have a considerable effect on application speed.');

            $handler = curl_init($this->absolutePath);

            curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($handler, CURLOPT_HEADER, true);
            curl_setopt($handler, CURLOPT_NOBODY, true);
            curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false);

            curl_exec($handler);

            if ( ! curl_errno($handler))
            {
                $contentType = curl_getinfo($handler, CURLINFO_CONTENT_TYPE);

                return starts_with($contentType, 'text/css') ? 'stylesheets' : 'javascripts';
            }
        }
    }
960983
public function get_curl_object() {
        if (!is_null($this->curl)) {
            return $this->curl;
        }

        // Connection to Solr is allowed to use 'localhost' and other potentially blocked hosts/ports.
        $this->curl = new \curl(['ignoresecurity' => true]);

        $options = array();
        // Build the SSL options. Based on pecl-solr and general testing.
        if (!empty($this->config->secure)) {
            if (!empty($this->config->ssl_cert)) {
                $options['CURLOPT_SSLCERT'] = $this->config->ssl_cert;
                $options['CURLOPT_SSLCERTTYPE'] = 'PEM';
            }

            if (!empty($this->config->ssl_key)) {
                $options['CURLOPT_SSLKEY'] = $this->config->ssl_key;
                $options['CURLOPT_SSLKEYTYPE'] = 'PEM';
            }

            if (!empty($this->config->ssl_keypassword)) {
                $options['CURLOPT_KEYPASSWD'] = $this->config->ssl_keypassword;
            }

            if (!empty($this->config->ssl_cainfo)) {
                $options['CURLOPT_CAINFO'] = $this->config->ssl_cainfo;
            }

            if (!empty($this->config->ssl_capath)) {
                $options['CURLOPT_CAPATH'] = $this->config->ssl_capath;
            }
        }

        // Set timeout as for Solr client.
        $options['CURLOPT_TIMEOUT'] = !empty($this->config->server_timeout) ? $this->config->server_timeout : '30';

        $this->curl->setopt($options);

        if (!empty($this->config->server_username) && !empty($this->config->server_password)) {
            $authorization = $this->config->server_username . ':' . $this->config->server_password;
            $this->curl->setHeader('Authorization: Basic ' . base64_encode($authorization));
        }

        return $this->curl;
    }
378330
protected function getContentTypesHash()
    {
        $contentTypeHash = [];
        foreach ($this->contentTypeService->loadContentTypeGroups() as $contentTypeGroup) {
            foreach ($this->contentTypeService->loadContentTypes($contentTypeGroup) as $contentType) {
                $contentTypeHash[$contentType->getName()] = $contentType->identifier;
            }
        }
        ksort($contentTypeHash);

        return $contentTypeHash;
    }
492096
private function getUserGroup()
    {
        if (null !== $token = $this->tokenStorage->getToken()) {
            /** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
            if (null !== $user = $token->getUser()) {
                return $user->getGroup();
            }
        }
        return null;
    }
331006
public function getContentType(): string
	{
		if($this->contentType === null)
		{
			$this->contentType = rtrim(strtok((string) $this->headers->get('content-type'), ';'));
		}

		return $this->contentType;
	}
243126
static function FindContentGroup(Content $content)
    {
        $result = null;
        $currContent = $content;
        do
        {
            $result = $currContent->GetUserGroup();
            $currContent = ContentTreeUtil::ParentOf($currContent);
        } 
        while (!$result && $currContent);
        if ($result)
        {
            return $result;
        }
        return self::GetUpperContentGroup($content);
    }
302392
protected function _inspectContentType()
    {
        $mime = null;
        $charset = null;
        if (preg_match('/([-\w\/\.+]+)(;\s*?charset=(.+))?/i', $this->_headers['Content-Type']->value(), $matches)) {
            $mime = $mime ?: $matches[1];
            if (isset($matches[3])) {
                $charset = $charset ?: $matches[3];
            }
        }
        return [$mime, $charset];
    }
1317464
private function parseGroup()
    {
        $group = '';
        if (isset($this->parts['group']['fields'])) {
            if (is_array($this->parts['group']['fields'])) {
                $groupFields = [];
                foreach ($this->parts['group']['fields'] as $field) {
                    $field = is_array($field) ? $field : [$field];
                    $column = isset($field[0]) ? $field[0] : false;
                    $type = isset($field[1]) ? $field[1] : '';

                    $groupFields[] = $this->protect($column).($type ? ' '.strtoupper($type) : '');
                }

                $group .= implode(', ', $groupFields);
            } else {
                $group .= $this->parts['group']['fields'];
            }
        }

        if (isset($this->parts['group']['rollup']) && $this->parts['group']['rollup'] !== false) {
            $group .= ' WITH ROLLUP';
        }

        return $group;
    }
1178896
private static function GetUpperContentGroup(Content $content)
    {
        if ($content->GetPageContent())
        {
            return self::FindPageGroup($content->GetPageContent()->GetPage());
        }
        else if ($content->GetLayoutContent())
        {
            return $content->GetLayoutContent()->
                        GetArea()->GetLayout()->GetUserGroup();
        }
        else if ($content->GetContainerContent())
        {
            return $content->GetContainerContent()->
                        GetContainer()->GetUserGroup();
        }
        return null;
    }
1211420
public function getContentTypeGroups()
    {
        $contentTypeGroups = array();
        foreach ($this->contentTypeGroupReferences as $reference) {
            $contentTypeGroups[] = $this->contentTypeService->loadContentTypeGroup($reference);
        }

        return $contentTypeGroups;
    }
1306820
public function get_content_type() {
		$headers = wp_remote_retrieve_headers( $this->response );
		if ( ! $headers ) {
			return;
		}

		if ( ! is_object( $headers ) || ! method_exists( $headers, 'offsetGet' ) ) {
			return;
		}

		return $headers->offsetGet( 'content-type' );
	}
1255275
protected function askForGroups()
    {
        $default = 0;
        $groups = $this->groups();
        $group_names = collect($groups)->pluck('name')->toArray();
        $selected_group_names =  $this->choice('Groups?', $group_names ,$default, null, true);

        $groups = collect($groups)->filter(function ($group) use ($selected_group_names) {
            return in_array($group->name,$selected_group_names);
        });

        return $groups->pluck('id');
    }
1333885
public function attachmentGroup()
    {
        if ($this->group === null) {
            $config = $this->attachmentsMetadata();
            $group  = AttachmentContainerInterface::DEFAULT_GROUPING;

            if (isset($config['group'])) {
                $group = $config['group'];
                // If the 'default_group' is not set, search for it.
            } elseif (isset($config['default_group'])) {
                $group = $config['default_group'];
            // If the 'default_group' is not set, search for it.
            } elseif (isset($config['default_widget'])) {
                $widget   = $config['default_widget'];
                $metadata = $this->metadata();
                $found    = false;
                if (isset($metadata['admin']['form_groups'][$widget]['group'])) {
                    $group = $metadata['admin']['form_groups'][$widget]['group'];
                    $found = true;
                }

                if (!$found && isset($metadata['admin']['forms'])) {
                    foreach ($metadata['admin']['forms'] as $form) {
                        if (isset($form['groups'][$widget]['group'])) {
                            $group = $form['groups'][$widget]['group'];
                            $found = true;
                            break;
                        }
                    }
                }

                if (!$found && isset($metadata['admin']['dashboards'])) {
                    foreach ($metadata['admin']['dashboards'] as $dashboard) {
                        if (isset($dashboard['widgets'][$widget]['group'])) {
                            $group = $dashboard['widgets'][$widget]['group'];
                            $found = true;
                            break;
                        }
                    }
                }
            }

            if (!is_string($group)) {
                throw new UnexpectedValueException('The attachment grouping must be a string.');
            }

            $this->group = $group;
        }

        return $this->group;
    }
507264
protected function getGroups()
	{
		$groups = array();
		$label = 0;

		foreach ($this->element->children() as $element)
		{
			switch ($element->getName())
			{
				// The element is an <option />
				case 'option':
					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Create a new option object based on the <option /> element.
					$tmp = HtmlSelect::option(
						($element['value']) ? (string) $element['value'] : trim((string) $element),
						Text::alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
						((string) $element['disabled'] == 'true')
					);

					// Set some option attributes.
					$tmp->class = (string) $element['class'];

					// Set some JavaScript option attributes.
					$tmp->onclick = (string) $element['onclick'];

					// Add the option.
					$groups[$label][] = $tmp;
					break;

				// The element is a <group />
				case 'group':
					// Get the group label.
					if ($groupLabel = (string) $element['label'])
					{
						$label = Text::_($groupLabel);
					}

					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Iterate through the children and build an array of options.
					foreach ($element->children() as $option)
					{
						// Only add <option /> elements.
						if ($option->getName() != 'option')
						{
							continue;
						}

						// Create a new option object based on the <option /> element.
						$tmp = HtmlSelect::option(
							($option['value']) ? (string) $option['value'] : Text::_(trim((string) $option)),
							Text::_(trim((string) $option)), 'value', 'text', ((string) $option['disabled'] == 'true')
						);

						// Set some option attributes.
						$tmp->class = (string) $option['class'];

						// Set some JavaScript option attributes.
						$tmp->onclick = (string) $option['onclick'];

						// Add the option.
						$groups[$label][] = $tmp;
					}

					if ($groupLabel)
					{
						$label = count($groups);
					}
					break;

				// Unknown element type.
				default:
					throw new UnexpectedValueException(sprintf('Unsupported element %s in JFormFieldGroupedList', $element->getName()), 500);
			}
		}

		reset($groups);

		return $groups;
	}
1320713
public function group($group = null)
    {
        if ($group !== null) {
            $this->_group = $group;
        }
        return $this->_group;
    }
1191346
function fetchGroupList()
    {
        $this->InGroups = eZContentClassClassGroup::fetchGroupList( $this->attribute( "id" ),
                                                                     $this->attribute( "version" ),
                                                                     true );
        return $this->InGroups;
    }
721274
public function getResourceGroupsUrl() {
        return Http\ResourceGroupsUrl::factory(
            $this->getBaseUrl() . '/groups.json',
            $this->getConfig('privateKey'),
            $this->getPublicKey()
        );
    }