How does \Magento\Eav\Model\Config::_initAttributes() work?

Context: How does \Magento\Eav\Model\Config::getEntityAttributeCodes() work?

https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/Config.php#L357-L363

https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/Config.php#L365-L366

https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/Config.php#L368-L383

https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/Config.php#L385-L389

https://github.com/magento/magento2/blob/958164/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php#L41-L41


https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php#L49-L49


https://github.com/magento/magento2/blob/958164/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php#L124-L124


https://github.com/magento/magento2/blob/958164/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php#L57-L66

https://github.com/magento/magento2/blob/958164/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php#L67-L67

https://github.com/magento/magento2/blob/958164/app/code/Magento/Catalog/Model/ResourceModel/Product/Attribute/Collection.php#L68-L86

The result of the $this->getSelect()->assemble():

SELECT `main_table`.`entity_type_id`, `main_table`.`attribute_code`, `main_table`.`attribute_model`, `main_table`.`backend_model`, `main_table`.`backend_type`, `main_table`.`backend_table`, `main_table`.`frontend_model`, `main_table`.`frontend_input`, `main_table`.`frontend_label`, `main_table`.`frontend_class`, `main_table`.`source_model`, `main_table`.`is_required`, `main_table`.`is_user_defined`, `main_table`.`default_value`, `main_table`.`is_unique`, `main_table`.`note`, `additional_table`.* FROM `eav_attribute` AS `main_table`
 INNER JOIN `catalog_eav_attribute` AS `additional_table` ON additional_table.attribute_id = main_table.attribute_id WHERE (main_table.entity_type_id = 4)

https://github.com/magento/magento2/blob/958164/app/code/Magento/Eav/Model/Config.php#L391-L400

See also: