<?php

namespace Application\Admin\Form\LinkField;

use Application\Core\Model\LinkType;

/**
 * @deprecated
 */
class NolinkHandler extends BaseHandler
{
    /**
     * {@inheritdoc}
     */
    public function getClass($type = '')
    {
        return static::class . '::nolink';
    }

    /**
     * {@inheritdoc}
     */
    public function addTypesOptions($language_id, array $options)
    {
        $options[$this->getClass()] = 'nolink';

        return $options;
    }

    /**
     * {@inheritdoc}
     */
    public function render($name, $language_id, ?LinkType $link_type = null)
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public function renderSpan($name, $language_id, ?LinkType $link_type = null)
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public function getSelectOptions($language_id, array $query_options = [])
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public static function parseAttributes(array $attributes)
    {
        $attributes['module_path'] = null;

        return $attributes;
    }

    /**
     * {@inheritdoc}
     */
    public static function save($attributes, ?LinkType $link_type = null)
    {
        // Se prima avevo un LinkType, lo cancello
        if ($link_type instanceof LinkType) {
            $link_type->delete();
        }

        return null;
    }
}
