Last active
August 29, 2015 13:57
-
-
Save mockiemockiz/9543396 to your computer and use it in GitHub Desktop.
sadas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function editModuleFile(){ | |
$modulePath = './module/TestModule/module.php'; | |
$getModuleContent = file_get_contents($modulePath); | |
$oldContent = $getModuleContent; | |
// find getServiceOcnfig(){ return array( 'factories' => array( | |
$getModuleContent = preg_replace_callback('/[public|protected]*? *?function *?getServiceConfig().*?{.*?return.*?array.*?\(.*?\'factories\'.*?array\(/s', function($macthes){ | |
$string = $macthes[0]; | |
$string .= "\n\t\t"; | |
$string .= '\'MockGen\Model\MockGenTable\' => function($sm) {'; | |
$string .= "\n\t\t"; | |
$string .= '},'; | |
return $string; | |
},$getModuleContent); | |
/* | |
* if " find getServiceOcnfig(){ return array( 'factories' => array( " not found | |
* try to find getServiceOcnfig(){ return array( | |
*/ | |
if($oldContent==$getModuleContent){ | |
$getModuleContent = preg_replace_callback('/[public|protected]*? *?function *?getServiceConfig().*?{.*?return.*?array.*?\(.*?/s', function($macthes){ | |
$string = $macthes[0]; | |
$string .= "\n\t "; | |
$string .= '\'factories\' => array('; | |
$string .= "\n\t "; | |
$string .= '),'; | |
return $string; | |
},$getModuleContent); | |
} | |
/* | |
* if " find getServiceOcnfig(){ return array( " not found | |
* try to find getServiceOcnfig(){ | |
*/ | |
if($oldContent==$getModuleContent){ | |
$getModuleContent = preg_replace_callback('/[public|protected]*? *?function *?getServiceConfig().*?{/s', function($macthes){ | |
$string = $macthes[0]; | |
$string .= "\n\t"; | |
$string .= 'return array('; | |
$string .= "\n\t ".'\'factories\' => array('; | |
$string .= "\n\t "; | |
$string .= '),'; | |
$string .= "\n\t"; | |
$string .= ');'; | |
return $string; | |
},$getModuleContent); | |
} | |
echo $getModuleContent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment