<?php


namespace Autogedal\Extend\Observer;


use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\View\Page\Config as PageConfig;

class CustomerPageRobots implements  ObserverInterface
{
    private  $pageConfig;

    public function __construct(
        PageConfig $pageConfig
    ){
        $this->pageConfig = $pageConfig;
    }

    public function execute(Observer $observer)
    {
        $fullActionName = $observer->getEvent()->getData('full_action_name');

        if (
            in_array($fullActionName, ['customer_account_login', 'customer_account_create', 'customer_account_forgotpassword'])
        ) {
            $this->pageConfig->setMetadata('robots','NOINDEX,FOLLOW');
        }
    }
}
