private function mergePresetAttachableObjects($data)
    {
        if (is_string($data)) {
            $groupIdent = $data;
            if ($this instanceof ObjectContainerInterface) {
                if ($this->hasObj()) {
                    $groupIdent = $this->obj()->render($groupIdent);
                }
            } elseif ($this instanceof ModelInterface) {
                $groupIdent = $this->render($groupIdent);
            }

            $presetGroups = $this->config('groups');
            if (isset($presetGroups[$groupIdent])) {
                $data = $presetGroups[$groupIdent];
            }
        }

        if (is_array($data)) {
            $presetTypes = $this->config('attachables');
            $attachables = [];
            foreach ($data as $attType => $attStruct) {
                if (is_string($attStruct)) {
                    $attType   = $attStruct;
                    $attStruct = [];
                }

                if (!is_string($attType)) {
                    throw new InvalidArgumentException(
                        'The attachment type must be a string'
                    );
                }

                if (!is_array($attStruct)) {
                    throw new InvalidArgumentException(sprintf(
                        'The attachment structure for "%s" must be an array',
                        $attType
                    ));
                }

                if (isset($presetTypes[$attType])) {
                    $attStruct = array_replace_recursive(
                        $presetTypes[$attType],
                        $attStruct
                    );
                }

                $attachables[$attType] = $attStruct;
            }

            $data = $attachables;
        }

        return $data;
    }
private function mergePresetAttachableObjects($data)
    {
        if (is_string($data)) {
            $groupIdent = $data;
            if ($this instanceof ObjectContainerInterface) {
                if ($this->hasObj()) {
                    $groupIdent = $this->obj()->render($groupIdent);
                }
            } elseif ($this instanceof ModelInterface) {
                $groupIdent = $this->render($groupIdent);
            }

            $presetGroups = $this->config('groups');
            if (isset($presetGroups[$groupIdent])) {
                $data = $presetGroups[$groupIdent];
            }
        }

        if (is_array($data)) {
            $presetTypes = $this->config('attachables');
            $attachables = [];
            foreach ($data as $attType => $attStruct) {
                if (is_string($attStruct)) {
                    $attType   = $attStruct;
                    $attStruct = [];
                }

                if (!is_string($attType)) {
                    throw new InvalidArgumentException(
                        'The attachment type must be a string'
                    );
                }

                if (!is_array($attStruct)) {
                    throw new InvalidArgumentException(sprintf(
                        'The attachment structure for "%s" must be an array',
                        $attType
                    ));
                }

                if (isset($presetTypes[$attType])) {
                    $attStruct = array_replace_recursive(
                        $presetTypes[$attType],
                        $attStruct
                    );
                }

                $attachables[$attType] = $attStruct;
            }

            $data = $attachables;
        }

        return $data;
    }
private function mergePresetAttachableObjects ( $ data ) { if ( is_string ( $ data ) ) { $ groupIdent = $ data ; if ( $ this instanceof ObjectContainerInterface ) { if ( $ this -> hasObj ( ) ) { $ groupIdent = $ this -> obj ( ) -> render ( $ groupIdent ) ; } } elseif ( $ this instanceof ModelInterface ) { $ groupIdent = $ this -> render ( $ groupIdent ) ; } $ presetGroups = $ this -> config ( 'groups' ) ; if ( isset ( $ presetGroups [ $ groupIdent ] ) ) { $ data = $ presetGroups [ $ groupIdent ] ; } } if ( is_array ( $ data ) ) { $ presetTypes = $ this -> config ( 'attachables' ) ; $ attachables = [ ] ; foreach ( $ data as $ attType => $ attStruct ) { if ( is_string ( $ attStruct ) ) { $ attType = $ attStruct ; $ attStruct = [ ] ; } if ( ! is_string ( $ attType ) ) { throw new InvalidArgumentException ( 'The attachment type must be a string' ) ; } if ( ! is_array ( $ attStruct ) ) { throw new InvalidArgumentException ( sprintf ( 'The attachment structure for "%s" must be an array' , $ attType ) ) ; } if ( isset ( $ presetTypes [ $ attType ] ) ) { $ attStruct = array_replace_recursive ( $ presetTypes [ $ attType ] , $ attStruct ) ; } $ attachables [ $ attType ] = $ attStruct ; } $ data = $ attachables ; } return $ data ; }
Parse the given data and merge the preset attachment types.

@param  string|array $data The attachable objects data.
@throws InvalidArgumentException If the attachment type or structure is invalid.
@return array Returns the merged attachable objects data.
Parse the given data and merge the preset attachment types .