@param string|array $conversion
@param array $extraAttributes

@return string
349187
public function img($conversion = '', array $extraAttributes = []): string
    {
        if (! (new Image())->canHandleMime($this->mime_type)) {
            return '';
        }

        if (is_array($conversion)) {
            $attributes = $conversion;

            $conversion = $attributes['conversion'] ?? '';

            unset($attributes['conversion']);

            $extraAttributes = array_merge($attributes, $extraAttributes);
        }

        $attributeString = collect($extraAttributes)
            ->map(function ($value, $name) {
                return $name.'="'.$value.'"';
            })->implode(' ');

        if (strlen($attributeString)) {
            $attributeString = ' '.$attributeString;
        }

        $media = $this;

        $viewName = 'image';

        $width = '';

        if ($this->hasResponsiveImages($conversion)) {
            $viewName = config('medialibrary.responsive_images.use_tiny_placeholders')
                ? 'responsiveImageWithPlaceholder'
                : 'responsiveImage';

            $width = $this->responsiveImages($conversion)->files->first()->width();
        }

        return view("medialibrary::{$viewName}", compact(
            'media',
            'conversion',
            'attributeString',
            'width'
        ));
    }
1142352
public function getRubrics(array $ids, array $additionalFields = array())
    {
        return $this->getInternalList(
            'catalog/rubric/get',
            'Rubric',
            array('id' => self::getArray($ids), 'fields' => self::getArray($additionalFields))
        );
    }
1125171
public function remove( $conditions = null, $extraConditions = null )
    {
        foreach ( $this->getTagAttributeLinks() as $tagAttributeLink )
        {
            $tagAttributeLink->remove();
        }

        foreach ( $this->getTranslations() as $translation )
        {
            $translation->remove();
        }

        parent::remove( $conditions, $extraConditions );
    }
1267238
public function export($item, array $extraAttributes = ['group'], bool $useTypeSettings = false): array
    {
        /** @var Field $item*/
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        if (\count($item::supportedTranslationMethods()) > 1) {
            $extraAttributes = array_merge($extraAttributes, ['translationMethod', 'translationKeyFormat']);
        }
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'group') {
                $attributeObj[$attribute] = $item->$attribute->name;
                $attributeObj[$attribute . 'Id'] = $item->$attribute->id;
            } else if ($attribute === 'required') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }
        if ($useTypeSettings) {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
                'typesettings' => $item->getSettings(),
            ]);
        } else {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
            ], $item->getSettings());
        }

        if (isset($fieldObj['translationMethod']) && $fieldObj['translationMethod'] === 'none') {
            unset($fieldObj['translationMethod']);
        }

        if ($item instanceof Matrix) {
            /**
             * @var Matrix $item
             */
            $blockTypesObj = [];
            foreach ($item->getBlockTypes() as $blockType) {
                $blockTypeObj = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'fields' => [],
                ];
                foreach ($blockType->getFields() as $blockField) {
                    $blockTypeObj['fields'][] = $this->export($blockField, [ 'required' ], true);
                }
                $blockTypesObj[] = $blockTypeObj;
            }
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = $blockTypesObj;
            } else {
                $fieldObj['blockTypes'] = $blockTypesObj;
            }
            unset($fieldObj['contentTable']);
        } else if ($item instanceof Neo) {
            $blockTypesObj = [];
            $blockTypeGroupsObj = [];
            /**
             * @var Neo $item
             */
            foreach ($item->getGroups() as $group) {
                /* @var NeoBlockTypeGroup $blockType */
                $blockTypeGroupsObj[] = [
                    'name' => $group->name,
                    'sortOrder' => (int) $group->sortOrder
                ];
            }
            $fieldObj['groups'] = $blockTypeGroupsObj;
            foreach ($item->getBlockTypes() as $blockType) {
                /* @var NeoBlockType $blockType */
                $blockTypesObj[] = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'sortOrder' => (int) $blockType->sortOrder,
                    'maxBlocks' => (int) $blockType->maxBlocks,
                    'childBlocks' => Json::decodeIfJson((string) $blockType->childBlocks),
                    'maxChildBlocks' => (int) $blockType->maxBlocks,
                    'topLevel' => (bool) $blockType->topLevel,
                    'fieldLayout' => $this->exportFieldLayout($blockType->getFieldLayout()),
                    'requiredFields' => $this->exportRequiredFields($blockType->getFieldLayout()),
                ];
            }
            $fieldObj['blockTypes'] = $blockTypesObj;
        } else if ($item instanceof Date) {
            /**
             * @var Date $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['dateTime'] = 'show' . (
                    ((bool) $fieldObj['typesettings']['showDate'] === false) ? 'Time' : (
                        ((bool) $fieldObj['typesettings']['showTime'] === false) ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['typesettings']['showDate'], $fieldObj['typesettings']['showTime']);
            } else {
                $fieldObj['dateTime'] = 'show' . (
                    ((bool) $fieldObj['showDate']) === false ? 'Time' : (
                        ((bool) $fieldObj['showTime']) === false ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['showDate'], $fieldObj['showTime']);
            }
        } else if ($item instanceof SuperTableField) {
            /**
             * @var SuperTableField $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['typesettings']['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            } else {
                $fieldObj['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            }
            unset(
                $fieldObj['contentTable'], // SuperTable will auto-generate this for us.
                $fieldObj['columns'] // Cannot be set during first save, so we wont export this for now.
            );
        }

        $this->unmapSources($fieldObj);

        return $this->stripNulls($fieldObj);
    }
411462
protected function parseHrefAttributes(?array $attributes) : ?string
    {
        if (empty($attributes)) {
            return null;
        }

        if (isset($attributes['target']) && $attributes['target'] === '_blank') {
            if (!isset($attributes['rel'])) {
                $attributes['rel'] = 'noreferrer noopener';
            }
        }

        $extra = [];

        foreach ($attributes as $attr => $value) {
            $extra[] = $attr . '="' . $value . '"';
        }

        return ' ' . implode(' ', $extra);
    }
1261108
public function selectMultiple($name, $options = array(), $selected = null, array $attributes = array(), array $extra = array())
    {
        $attributes[] = 'multiple';
        return $this->doBuild('select', $name, $selected, $attributes, $extra, $options);
    }
580138
protected function renderAttributes($attributes)
    {
        if (count((array) $attributes) == 0) {
            return '';
        }

        $return = [];

        foreach ($attributes as $key => $value) {
            $return[] = $key . '="' . $value . '"';
        }

        return ' ' . implode(' ', $return);
    }
583462
public function input($type, $name, $value = null, array $attributes = array(), array $extra = array())
    {
        return $this->build($type, $name, $value, $attributes, $extra);
    }
52823
public function body_attributes($additionalclasses = array()) {
        if (!is_array($additionalclasses)) {
            $additionalclasses = explode(' ', $additionalclasses);
        }
        return ' id="'. $this->body_id().'" class="'.$this->body_css_classes($additionalclasses).'"';
    }
1136132
public function findByName($name, $extraDatas = array(), $executeQuery = true)
    {
        $name  = strtoupper($name);
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->createQueryBuilder('resourceNode');
        $queryBuilder->where($queryBuilder->expr()->like('UPPER(resourceNode.name)', ':name'));

        if (0 < count($extraDatas)) {
            foreach ($extraDatas as $key => $extraData) {
                $queryBuilder
                    ->andWhere(sprintf('resourceNode.%s = :%s', $key, $key))
                    ->setParameter(sprintf(':%s', $key), $extraData);
            }
        }

        $queryBuilder
            ->orderBy('resourceNode.name', 'ASC')
            ->setParameter(':name', "%{$name}%");

        return $executeQuery ? $queryBuilder->getQuery()->getResult(): $queryBuilder;
    }
950770
public function generateImage($originalUrl, array $attributesFilters)
    {
        if (empty($attributesFilters)) {
            throw new \InvalidArgumentException('Please provide at least one key for attribute generation (e.g. \'src\') ');
        }

        $image = (new \DOMDocument())->createElement('img');

        try {
            foreach ($attributesFilters as $attributeName => $filters) {
                $attributeValue = $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
                if ('' !== $attributeValue) {
                    $image->setAttribute($attributeName, $attributeValue);
                }
            }
        } catch (ResolutionException $e) {
            $image->setAttribute('src', $originalUrl);
        }

        return $this->renderer->render($image);
    }
726453
public function callShortcode($tag, $attributes, $content, $extra = array())
    {
        if (!$tag || !isset($this->shortcodes[$tag])) {
            return false;
        }
        return call_user_func($this->shortcodes[$tag], $attributes, $content, $this, $tag, $extra);
    }
235797
public function export($item, array $extraAttributes = []): array
    {
        /** @var Section $item */
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)), $this->additionalAttributes($item->type));
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'propagateEntries') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }

        $sectionObj = array_merge([
            'name' => $item->name,
            'handle' => $item->handle,
            'type' => $item->type,
            'enableVersioning' => (bool) $item->enableVersioning,
        ], $attributeObj);

        $siteSettings = $item->getSiteSettings();
        $sectionObj['siteSettings'] = [];
        foreach ($siteSettings as $siteSetting) {
            $hasUrls = (bool) $siteSetting->hasUrls;
            $sectionObj['siteSettings'][] = [
                'siteId' => $siteSetting->getSite()->primary ? null : $siteSetting->getSite()->handle,
                'hasUrls' => $hasUrls,
                'uriFormat' => $hasUrls ? $siteSetting->uriFormat : null,
                'template' => $siteSetting->template,
                'enabledByDefault' => (bool) $siteSetting->enabledByDefault,
            ];
        }
        $entryTypes = $item->getEntryTypes();
        $sectionObj['entryTypes'] = [];
        foreach ($entryTypes as $entryType) {
            $sectionObj['entryTypes'][] = Architect::$processors->entryTypes->export($entryType);
        }

        return $this->stripNulls($sectionObj);
    }
586908
public static function mapAttributes($attributes)
    {
        return ' '.join(' ', array_map(
            function ($sKey) use ($attributes) {
                return is_bool($attributes[$sKey]) ? ($attributes[$sKey] ? $sKey : '') : $sKey.'="'.$attributes[$sKey].'"';
            }, array_keys($attributes)
        ));
    }
659317
public function file($name, array $attributes = array(), array $extra = array())
    {
        return $this->build('file', $name, null, $attributes, $extra);
    }
713851
public function makeAttributesForOption ($attributes)
    {
        $attrs = '';
        if ($attributes) {
            foreach ($attributes as $key => $value) {
                $attrs .= "$key='" . $value . "'";
            }
        }
        return $attrs;
    }
522622
public function transformHtml($html, $attributesFiltersOrConfigurationKey = [], array $extraFilters = [])
    {
        $attributesFilters = $this->prepareFilterParams($attributesFiltersOrConfigurationKey, $extraFilters);

        return $this->htmlTransformer->transformHtml($html, $attributesFilters);
    }