Beispiel #1
0
 /**
  * Init environemnt
  *
  * @param string $root absolute path to magento root
  * @param string $moduleName
  * @param string $companyName
  * @param array $params (such as author, license etc.) to substitude in templates
  */
 public function __construct($root, $moduleName, $companyName, array $params)
 {
     $this->_mage = new Mtool_Magento($root);
     $this->_moduleName = ucfirst($moduleName);
     $this->_companyName = ucfirst($companyName);
     $this->_templateParams = $params;
     $this->_moduleDir = $this->_mage->getCodepoolPath() . $this->_companyName . DIRECTORY_SEPARATOR . $this->_moduleName;
     $this->_moduleConfigsDir = $this->_moduleDir . DIRECTORY_SEPARATOR . 'etc';
     $this->_moduleSqlDir = $this->_moduleDir . DIRECTORY_SEPARATOR . 'sql';
 }
Beispiel #2
0
 /**
  * Find module by entity namespace
  *
  * @param string $root - path to the working directory
  * @param Mtool_Codegen_Entity_Abstract $entity
  * @param string $namespace - namespace name
  * @param array $templateConfig
  * @return Mtool_Codegen_Entity_Module | null
  */
 public static function byNamespace($root, $entity, $namespace, array $templateConfig)
 {
     $configNamespace = $entity->getConfigNamespace();
     $mage = new Mtool_Magento($root);
     // Find all local config.xml files
     $configs = $mage->findInCode('config.xml', $mage->getCodepoolPath());
     try {
         // Find entity definition through local modules
         $classPrefix = $entity->lookupOriginEntityClass($namespace, $configs);
         // Extract module and company names from class prefix
         list($companyName, $moduleName) = explode('_', $classPrefix);
         return new Mtool_Codegen_Entity_Module($root, $moduleName, $companyName, $templateConfig);
     } catch (Mtool_Codegen_Exception_Entity $e) {
         return null;
     } catch (Exception $e) {
         throw $e;
     }
 }