src/Service/compileService.php
private function getMetadataArray($objName)
    {
        $xmlFile = ObjectFactoryHelper::getXmlFileWithPath($objName);
        if (!$xmlFile) {
            $dotPos = strrpos($objName, ".");
            $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null;
            $class = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName;
        } else {
            $xmlArr = ObjectFactoryHelper::getXmlArray($xmlFile);
        }

        if ($xmlArr) {
            $keys = array_keys($xmlArr);
            $root = $keys[0];

            // add by mr_a_ton , atrubut name must match with object name
            $dotPos = strrpos($objName, ".");
            $shortObjectName = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName;
            if ($xmlArr[$root]["ATTRIBUTES"]["NAME"] == "") {
                $xmlArr[$root]["ATTRIBUTES"]["NAME"] = $shortObjectName;
            } else {
                if ($shortObjectName != $xmlArr[$root]["ATTRIBUTES"]["NAME"]) {
                    trigger_error("Metadata file parsing error for object $objName. Name attribut [" . $xmlArr[$root]["ATTRIBUTES"]["NAME"] . "] not same with object name. Please double check your metadata xml file again.", E_USER_ERROR);
                }
            }

            //$package = $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"];
            $class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"];
            // if class has package name as prefix, change the package to the prefix
            $dotPos = strrpos($class, ".");
            $classPrefix = $dotPos > 0 ? substr($class, 0, $dotPos) : null;
            $classPackage = $classPrefix ? $classPrefix : null;
            if ($classPrefix) {
                $class = substr($class, $dotPos + 1);
            }
            // set object package
            $dotPos = strrpos($objName, ".");
            $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null;
            if (!$classPackage) {
                $classPackage = $package;
            }
            $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"] = $package;
            return $xmlArr;
        }
        return;
    }
private function getMetadataArray($objName)
    {
        $xmlFile = ObjectFactoryHelper::getXmlFileWithPath($objName);
        if (!$xmlFile) {
            $dotPos = strrpos($objName, ".");
            $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null;
            $class = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName;
        } else {
            $xmlArr = ObjectFactoryHelper::getXmlArray($xmlFile);
        }

        if ($xmlArr) {
            $keys = array_keys($xmlArr);
            $root = $keys[0];

            // add by mr_a_ton , atrubut name must match with object name
            $dotPos = strrpos($objName, ".");
            $shortObjectName = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName;
            if ($xmlArr[$root]["ATTRIBUTES"]["NAME"] == "") {
                $xmlArr[$root]["ATTRIBUTES"]["NAME"] = $shortObjectName;
            } else {
                if ($shortObjectName != $xmlArr[$root]["ATTRIBUTES"]["NAME"]) {
                    trigger_error("Metadata file parsing error for object $objName. Name attribut [" . $xmlArr[$root]["ATTRIBUTES"]["NAME"] . "] not same with object name. Please double check your metadata xml file again.", E_USER_ERROR);
                }
            }

            //$package = $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"];
            $class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"];
            // if class has package name as prefix, change the package to the prefix
            $dotPos = strrpos($class, ".");
            $classPrefix = $dotPos > 0 ? substr($class, 0, $dotPos) : null;
            $classPackage = $classPrefix ? $classPrefix : null;
            if ($classPrefix) {
                $class = substr($class, $dotPos + 1);
            }
            // set object package
            $dotPos = strrpos($objName, ".");
            $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null;
            if (!$classPackage) {
                $classPackage = $package;
            }
            $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"] = $package;
            return $xmlArr;
        }
        return;
    }
/*
public function encode($str,$key) {
$td = mcrypt_module_open('twofish', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
$keystr = substr(md5($key), 0, $ks);
mcrypt_generic_init($td, $keystr, $iv);
$encrypted = mcrypt_generic($td, $str);
mcrypt_module_close($td);
$hexdata = bin2hex($encrypted);
return $hexdata;
}

public function decode($str,$key) {
$td = mcrypt_module_open('twofish', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
$keystr = substr(md5($key), 0, $ks);
mcrypt_generic_init($td, $keystr, $iv);
$encrypted = pack( "H*", $str);
$decrypted = mdecrypt_generic($td, $encrypted);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $decrypted;
}