Exemplo n.º 1
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;
     }
 }
Exemplo n.º 2
0
 /**
  * Retrurns License text with the asterisk before each string
  *
  * @return string
  */
 protected function _getLicenseStrings($filename = '')
 {
     if (is_readable($filename)) {
         $strings = file($filename);
     } else {
         $strings = file(Mtool_Magento::getMtoolDir() . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'license', FILE_IGNORE_NEW_LINES);
     }
     for ($i = 0; $i < count($strings); $i++) {
         if (preg_match('/^@license\\s+(.*)/', $strings[$i], $matchs)) {
             $licenseShort = $matchs[1];
             unset($strings[$i]);
             continue;
         }
         if (strlen($strings[$i])) {
             $text[] = $strings[$i] . "\n";
         }
     }
     return array(rtrim(' * ' . implode(' * ', $text), "\n"), $licenseShort);
 }
Exemplo n.º 3
0
 /**
  * Find file through modules
  *
  * @param string $search
  * @return RegexIterator
  */
 public function findThroughModules($search)
 {
     return $this->_mage->findInCode($search);
 }