/** * add entity to module * * @access public * @param Ultimate_ModuleCreator_Model_Entity $entity * @return Ultimate_ModuleCreator_Model_Module * @throws Ultimate_ModuleCreator_Exception * @author Marius Strajeru <*****@*****.**> */ public function addEntity(Ultimate_ModuleCreator_Model_Entity $entity) { Mage::dispatchEvent('umc_module_add_entity_before', array('entity' => $entity, 'module' => $this)); if (isset($this->_entities[$entity->getNameSingular()])) { throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An entity with the code "%s" already exists', $entity->getNameSingular())); } $entity->setModule($this); $entity->setIndex(count($this->_entities)); $position = 10 * count($this->_entities); $entity->setPosition($position); $this->_entities[$entity->getNameSingular()] = $entity; if ($entity->getRss()) { $this->setRss(true); } if ($entity->getHasFile()) { $this->setHasFile(true); } if ($entity->getHasImage()) { $this->setHasImage(true); } if ($entity->getAddSeo()) { $this->setAddSeo(true); } if ($entity->getWidget()) { $this->setWidget(true); } if ($entity->getCreateFrontend()) { $this->setCreateFrontend(true); $this->setCanCreateRouter(true); } if ($entity->getCreateList()) { $this->setCreateList(true); } if ($entity->getIsTree()) { $this->setHasTree(true); } if ($entity->getEditor()) { $this->setEditor(true); } if ($entity->getHasConfigDefaults()) { $this->setHasConfigDefaults(true); } if ($entity->getLinkProduct()) { $this->setLinkProduct(true); $this->setHasObserver(true); } if ($entity->getLinkCategory()) { $this->setLinkCategory(true); $this->setHasObserver(true); } if ($entity->getLinkCore()) { $this->setLinkCore(true); } if ($entity->getUrlRewrite()) { $this->setUrlRewrite(true); } if ($entity->getIsEav()) { $this->setHasEav(true); } if ($entity->getIsFlat()) { $this->setHasFlat(true); } if ($entity->getApi()) { $this->setApi(true); } if ($entity->getAllowComment()) { $this->setAllowComment(true); } if ($entity->getAllowCommentByStore()) { $this->setAllowCommentByStore(true); } if ($entity->getHasCountry()) { $this->setHasCountry(true); } if ($entity->getAddSeo()) { $this->setHasSeo(true); } if ($entity->getCanCreateListBlock()) { $this->setCreateFrontend(true); } if ($entity->getShowOnProduct()) { $this->setShowOnProduct(true); } if ($entity->getShowOnCategory()) { $this->setShowOnCategory(true); } if ($entity->getShowInCategoryMenu()) { $this->setShowInCategoryMenu(true); } if ($entity->getSearch()) { $this->setSearch(true); } if ($entity->getProductAttribute() || $entity->getCategoryAttribute()) { $this->setHasCatalogAttribute(true); } if ($entity->getRest()) { $this->setRest(true); } Mage::dispatchEvent('umc_module_add_entity_after', array('entity' => $entity, 'module' => $this)); return $this; }