src/Charcoal/Admin/Widget/GroupAttachmentWidget.php
protected function addAttachmentGroupFromMetadata($reload = false)
    {
        if ($this->obj() instanceof TemplateableInterface) {
            $this->setControllerIdent($this->obj()->templateIdentClass());
        }

        if ($reload || !$this->isAttachmentMetadataFinalized) {
            $obj                 = $this->obj();
            $controllerInterface = $this->controllerIdent();

            $interfaces = [$this->objType()];

            if ($controllerInterface) {
                array_push($interfaces, $controllerInterface);
            }

            $structureMetadata = $this->createMetadata();

            if (count($interfaces)) {
                $controllerMetadataIdent = sprintf('widget/metadata/%s/%s', $obj->objType(), $obj->id());
                $structureMetadata       = $this->metadataLoader()->load(
                    $controllerMetadataIdent,
                    $structureMetadata,
                    $interfaces
                );
            }

            $attachmentWidgets = $structureMetadata->get('attachments.widgets');
            foreach ((array)$attachmentWidgets as $ident => $metadata) {
                $this->addGroup($ident, $metadata);
            }

            $this->isAttachmentMetadataFinalized = true;
        }
    }
protected function addAttachmentGroupFromMetadata($reload = false)
    {
        if ($this->obj() instanceof TemplateableInterface) {
            $this->setControllerIdent($this->obj()->templateIdentClass());
        }

        if ($reload || !$this->isAttachmentMetadataFinalized) {
            $obj                 = $this->obj();
            $controllerInterface = $this->controllerIdent();

            $interfaces = [$this->objType()];

            if ($controllerInterface) {
                array_push($interfaces, $controllerInterface);
            }

            $structureMetadata = $this->createMetadata();

            if (count($interfaces)) {
                $controllerMetadataIdent = sprintf('widget/metadata/%s/%s', $obj->objType(), $obj->id());
                $structureMetadata       = $this->metadataLoader()->load(
                    $controllerMetadataIdent,
                    $structureMetadata,
                    $interfaces
                );
            }

            $attachmentWidgets = $structureMetadata->get('attachments.widgets');
            foreach ((array)$attachmentWidgets as $ident => $metadata) {
                $this->addGroup($ident, $metadata);
            }

            $this->isAttachmentMetadataFinalized = true;
        }
    }
protected function addAttachmentGroupFromMetadata ( $ reload = false ) { if ( $ this -> obj ( ) instanceof TemplateableInterface ) { $ this -> setControllerIdent ( $ this -> obj ( ) -> templateIdentClass ( ) ) ; } if ( $ reload || ! $ this -> isAttachmentMetadataFinalized ) { $ obj = $ this -> obj ( ) ; $ controllerInterface = $ this -> controllerIdent ( ) ; $ interfaces = [ $ this -> objType ( ) ] ; if ( $ controllerInterface ) { array_push ( $ interfaces , $ controllerInterface ) ; } $ structureMetadata = $ this -> createMetadata ( ) ; if ( count ( $ interfaces ) ) { $ controllerMetadataIdent = sprintf ( 'widget/metadata/%s/%s' , $ obj -> objType ( ) , $ obj -> id ( ) ) ; $ structureMetadata = $ this -> metadataLoader ( ) -> load ( $ controllerMetadataIdent , $ structureMetadata , $ interfaces ) ; } $ attachmentWidgets = $ structureMetadata -> get ( 'attachments.widgets' ) ; foreach ( ( array ) $ attachmentWidgets as $ ident => $ metadata ) { $ this -> addGroup ( $ ident , $ metadata ) ; } $ this -> isAttachmentMetadataFinalized = true ; } }
Load attachments group widget and them as form groups.

@param boolean $reload Allows to reload the data.
@throws InvalidArgumentException If structureMetadata $data is note defined.
@throws RuntimeException If the metadataLoader is not defined.
@return void
Load attachments group widget and them as form groups .