<?php

namespace KupShop\KupShopBundle\Context\Wrapper;

use KupShop\KupShopBundle\Template\EntityWrapper;
use KupShop\KupShopBundle\Template\ObjectWrapper;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class ContextWrapper extends ObjectWrapper
{
    protected $allowed_methods = ['*'];

    public function getActive()
    {
        $entity = $this->object->getActive();

        if (!$entity) {
            return null;
        }

        return ServiceContainer::getService(EntityWrapper::class)->setObject($entity);
    }

    public function getSupported()
    {
        $entities = $this->object->getSupported();

        return array_map(function ($x) {
            return ServiceContainer::getService(EntityWrapper::class)->setObject($x);
        }, $entities);
    }
}
