<?php
namespace Autogedal\AutogedalHelper\Block\Widget;

use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;

class CategoryBadge extends Template implements BlockInterface
{
    protected $_template = "widget/category-badges.phtml";

    public function __construct(
        Template\Context $context,
        \Magento\Framework\Registry $registry,
        array $data = []
    )
    {
        parent::__construct($context, $data);
        $this->_scopeConfigInterface = $scopeConfigInterface;
        $this->_registry = $registry;
    }

    public function isForThisProduct($availableCategories)
    {
        if (empty($availableCategories)) {
            return false;
        }
        $availableCategories = explode(",", $availableCategories);

        if (!empty($availableCategories)) {
            $product = $this->_registry->registry('current_product');
            $categoryIds = $product->getCategoryIds();
            $rightCategories = array_intersect($categoryIds, $availableCategories);
            return !empty($rightCategories);
        }
    }
}