Skip to content

Instantly share code, notes, and snippets.

@mockiemockiz
Last active August 29, 2015 13:57
Show Gist options
  • Save mockiemockiz/9543396 to your computer and use it in GitHub Desktop.
Save mockiemockiz/9543396 to your computer and use it in GitHub Desktop.
sadas
<?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