@param      $type
@param null|string|boolean $group

@return array
974697
public function getAttachmentsByType($type, $group = false)
    {
        $attachments = array();

        /** @var \Justimmo\Model\Attachment $attachment */
        foreach ($this->attachments as $attachment) {
            if ($attachment->getType() == $type && ($group === false || $group == $attachment->getGroup())) {
                $attachments[] =  $attachment;
            }
        }

        return $attachments;
    }
757633
protected function getDefaultAttributes($group)
    {
        if (! ($group instanceof Group)) {
            throw new InvalidArgumentException(
                get_class($this).' can only serialize instances of '.Group::class
            );
        }

        return [
            'nameSingular' => $this->translateGroupName($group->name_singular),
            'namePlural'   => $this->translateGroupName($group->name_plural),
            'color'        => $group->color,
            'icon'         => $group->icon,
        ];
    }
241024
public function clear($type = null)
    {
        if (false === $this->mf->hasCache()) {
            return [];
        }
        return $this->doClear($this->getTypes($type));
    }
205542
protected function validateGroup($group, $groupType) {
		if (is_null($this->resultMap)) {
			//find group column
			if (!array_key_exists($group, $this->columnTypes)) {
				if (is_numeric($group) && array_key_exists(intval($group), $this->columnTypes))
					$group = intval($group);
				else
					throw new \UnexpectedValueException("Group column '$group' not found");
			}
		
			//get group type
			$groupType = is_null($groupType) ? $this->columnTypes[$group] : $groupType;
			$groupColumn = $group;
		
			//obtain group type handler
			$groupTypeHandler = $this->typeManager->getTypeHandler($groupType);
		
			if ($groupTypeHandler === false)
				throw new \UnexpectedValueException("Unknown type '$groupType' defined for group '$group'");
		}
		else {
			//find group property
			if (!array_key_exists($group, $this->properties))
				throw new \UnexpectedValueException("Group property '$group' was not found in result map");
		
			//obtain group column and type handler
			$groupColumn = $this->properties[$group]->getColumn();
			$groupTypeHandler = $this->typeHandlers[$group];
		}
		
		return [$groupColumn, $groupTypeHandler];
	}
821160
public function serialize($data, $group = null)
    {
        $context = new SerializationContext();

        if ($group) {
            $context->setGroups($group);
        }

        return $this->serializer->serialize($data, 'json', $context);
    }
485006
public static function getGroupSetting ($group, $setting)
	{
		return isset (self::$resourceSettings[$group][$setting])? self::$resourceSettings[$group][$setting] : FALSE;
	}
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;
    }
987297
public function group($typeId, $group = null, $code = null)
    {
        return $this->processor->group($this, $typeId, $group, $code);
    }
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;
	}
316992
public static function getKeys($group)
    {
        self::loadKeys();
        self::$keys[$group] = isset(self::$keys[$group]) ? self::$keys[$group] : [];

        return self::$keys[$group];
    }
223968
public function getByKey($key, $group = null) {
        $query =  $this->model
            ->where('key', $key);

        if(! is_null($group))
            $query->where('group', $group);

        return $query->get();
    }
626423
public function getSitesFromGroup($group = '')
    {
        Piwik::checkUserHasSuperUserAccess();

        $group = trim($group);
        $sites = $this->getModel()->getSitesFromGroup($group);

        foreach ($sites as &$site) {
            $this->enrichSite($site);
        }

        $sites = Site::setSitesFromArray($sites);
        return $sites;
    }
268625
public function all($group = null) {
        if(! is_null($group))
            return $this->model->where('group', $group)->lists('value', 'key');

        return $this->model->lists('value', 'key');
    }
356077
public static function getConversionGroupUnits($group = NULL) {
		$conversionGroups = array();
		foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
			if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
				$conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
			}
		}
		return $conversionGroups;
	}
34149
public static function getUidListByGroup($group)
    {
        if (!static::isValidGroupId($group)) {
            return array();
        }

        $group = is_array($group) ? $group : array($group);
        $data = static::select(array('uid'), array('groups' => $group));
        $uid_map = array();
        foreach ($data as $local_ip => $buffer_array) {
            foreach ($buffer_array as $local_port => $items) {
                //$items = ['connection_id'=>['uid'=>x, 'group'=>[x,x..], 'session'=>[..]], 'client_id'=>[..], ..];
                foreach ($items as $connection_id => $info) {
                    if (!empty($info['uid'])) {
                        $uid_map[$info['uid']] = $info['uid'];
                    }
                }
            }
        }
        return $uid_map;
    }
886144
public function init($group)
	{
		// Lets validate if the post type exists and if so, continue.
		$postTypeModel = $this->getPostType($group);
		if(!$postTypeModel){
    		$errorMessages = 'You are not authorized to do this.';
    		return $this->abort($errorMessages);
    	}

		// Receiving the current data of the group
		$config = NikuConfig::where('group', '=', $group)
			->get()
			->keyBy('option_name')
			->toArray();

		$templates = $postTypeModel->view;

		// Appending the key added in the config to the array
        // so we can use it very easliy in the component.
        foreach($templates as $key => $template){

	    	if(!empty($template['customFields'])){

	    		// For each custom fields
	            foreach($template['customFields'] as $ckey => $customField){
	                $templates[$key]['customFields'][$ckey]['id'] = $ckey;

	                // Adding the values to the result
	            	if(!empty($config[$ckey])){
	            		$templates[$key]['customFields'][$ckey]['value'] = $config[$ckey]['option_value'];
	            	}
	            }
	        }
	    }

		$collection = collect([
			'config' => $this->getConfig($postTypeModel),
			'templates' => $templates,
		]);

		return response()->json($collection);
	}
604442
public function all($type = null)
    {
        return array_filter(
            $this->bag,
            /** @var BuilderInterface $builder */
            function (BuilderInterface $builder) use ($type) {
                return $type === null || $builder->getType() == $type;
            }
        );
    }