Skip to content

Instantly share code, notes, and snippets.

@phptek
Created January 31, 2019 22:19
Show Gist options
  • Save phptek/5043582927dd60b3ee28385fe31e8aff to your computer and use it in GitHub Desktop.
Save phptek/5043582927dd60b3ee28385fe31e8aff to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Replace Eklektos' namespaces with the one used in your project.
#
# Run the following command from the directory containing your project's "app" or "mysite" directory:
#
# $> ./namespaceify.sh 'Foo\Bar' app
#
# This will convert for example: namespace Eklektos\Eklektos\Model\FooBar into: namespace Foo\Bar\Model\FooBar
namespace=$( echo $1 | sed -e 's#\\#\\\\#g' )
dir=$2
if [ \( -z "$namespace" -o -z "$dir" \) ]; then
echo "Incorrect parameters passed."
exit 1
fi
if [ ! -d "$dir" ]; then
echo "Couldn't find directory: $dir"
exit 1
fi
for file in $( find "$dir" -type f | xargs grep -l 'Eklektos' )
do
sed -i -e "s#Eklektos\\\Eklektos#$namespace#g" $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment