<?php

namespace Autogedal\Extend\Block\Blog;

use Magento\Framework\View\Element\Template;
use Magento\Framework\Registry;

class Snippets extends \Magento\Framework\View\Element\Template
{
    protected $_registry;
    protected $_post;
    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    private $storeManager;
    
    public function __construct(
        Template\Context $context,
        Registry $registry,
        array $data = []
    ) {
        $this->_registry = $registry;
        $this->storeManager = $context->getStoreManager();
        parent::__construct($context, $data);
    }
    
    /**
     * @return string
     */
    public function getWebsiteUrl()
    {
        return $this->storeManager->getStore()->getBaseUrl();
    }

    public function getPost()
    {
        if (!$this->_post) {
            $this->_post = $this->_registry->registry('tm_blog_post');
        }
        return $this->_post;
    }
}
