0

I am working on creation of custom module and it is going to be stuck in a problem where i want to add some predefined data to my custom module while installation, so for that i review pre defined modules and found that there is a file installData.php inside Setup of a custom module

I reviewed module-cms all thing is well set and find out a class included inside vendor\magento\module-cms\Setup\insatallData.php

namespace Magento\Cms\Setup;

use Magento\Cms\Model\Page;
use Magento\Cms\Model\PageFactory;
use Magento\Framework\Module\Setup\Migration;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

use Magento\Cms\Model\PageFactory;

where to find this PageFactory class, because if i am able to find this then in that manner i am able create a Factory class for my own module.

thanks.

Amit Dwivedi
  • 1,550
  • 19
  • 37

2 Answers2

1

PageFactory is auto generate class in magento2.

Module with model class have factory class. You can check this PageFactroy class inside

var/generation/Magento/Cms/Model/PageFactory.php. All factory class are autogenerated and its path are found under var/generation/Magento/{{Modulename}}/Model/{{ModelclassFactory.php}}

If your module is custom module not magento core module at that time you have to check Factory class inside var/generation/{{Packagename}}/{{Modulename}}/Model/{{ModelclassFactory.php}}.

ex. your custom module is Company/Test and Test module contain model class, You have to check TestFactory class inside var/generation/Company/Test/Model/TestFactory.php

Rakesh Jesadiya
  • 42,221
  • 18
  • 132
  • 183
1

PageFactory in Magento 2

go through this thread What Triggers the Generation of a Factory in Magento 2 you will understand.

Bojjaiah
  • 3,992
  • 4
  • 56
  • 119