<?php
namespace Solwin\Verticalmenu\Setup;

class InstallData implements \Magento\Framework\Setup\InstallDataInterface
{
    /**
     * Menu setup factory
     * 
     * @var \Solwin\Verticalmenu\Setup\MenuSetupFactory
     */
    protected $menuSetupFactory;

    /**
     * constructor
     * 
     * @param \Solwin\Verticalmenu\Setup\MenuSetupFactory $menuSetupFactory
     */
    public function __construct(
        \Solwin\Verticalmenu\Setup\MenuSetupFactory $menuSetupFactory
    )
    {
        $this->menuSetupFactory = $menuSetupFactory;
    }


    /**
     * {@inheritdoc}
     */
    public function install(\Magento\Framework\Setup\ModuleDataSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
    {
        /** @var \Solwin\Verticalmenu\Setup\MenuSetup $menuSetup */
        $menuSetup = $this->menuSetupFactory->create(['setup' => $setup]);
        // Create Root Menu Node
        $menu = $menuSetup->createMenu();
        $menu
            ->setPath('1')
            ->setLevel(0)
            ->setPosition(0)
            ->setChildrenCount(0)
            ->setMenu_title('ROOT')
            ->setInitialSetupFlag(true)
            ->save();

    }
}
