Zend certified PHP/Magento developer

Why does my plugin work only when I add Page Result object as a dependency?

I’m trying to add a layout update to a specific group of CMS pages. I created a plugin class that applies a layout update if a certain condition is met. The plugin works if I use the following class but if remove the constructor and the page result dependency it doesn’t work. Why does the plugin work only if the dependency is added?

This works

class UpdateLayout
{
    private $_pageResult;

    public function __construct(MagentoFrameworkViewResultPage $pageResult) {
        $this->_pageResult = $pageResult;
    }

    public function afterPrepareResultPage(MagentoCmsHelperPage $subject,  $result){

        if ($result instanceof MagentoFrameworkViewResultPage && $result->getConfig()->getPageLayout() == '1column-with-custom-css') {
            $result->addHandle('cms_page_custom_css');

        }
        return $result;
    }

}

This doesn’t

class UpdateLayout
{
//    private $_pageResult;
//
//    public function __construct(MagentoFrameworkViewResultPage $pageResult) {
//        $this->_pageResult = $pageResult;
//    }

    public function afterPrepareResultPage(MagentoCmsHelperPage $subject,  $result){

        if ($result instanceof MagentoFrameworkViewResultPage && $result->getConfig()->getPageLayout() == '1column-with-custom-css') {
            $result->addHandle('cms_page_custom_css');

        }
        return $result;
    }

}