-
Notifications
You must be signed in to change notification settings - Fork 101
/
gen-event-list.sh
executable file
·30 lines (24 loc) · 1.21 KB
/
gen-event-list.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
#requires pcre2grep
#run this command from a magento root directory to generate a (incomplete?) list of emitted events
#to be used with observer generate autocomplete
MAGE_ROOT=app/code/Magento
pcre2grep --buffer-size=50M -M -r -o1 "eventManager->dispatch\s*\(\s*([\'\"][^\'\"]*[\'\"])" $MAGE_ROOT \
| sed -e 's/.*://g' \
| xargs --replace=EVENT echo 'echo "EVENT"'
#-M is for multiline match
#-r recusrive search
#-o1 outputs only the first capture group (our event)
#regex matches all dispatched events that match regex
#regex matches eventManager->dispatch
#followed by white space then a literal (
#then any number of white space
#then we capture the first string that appears
# capture a ' or a "
# followed by any number of anything that's not a ' or a "
# followed by the matching ' or a "
#this regex will also capture php code within "" that's meant to be evaluated
# such as "admin_system_config_changed_section_{$this->getSection()}" (so far the only match)
#it will also capture strings that begin with a ' and end with a " or vice versa (minor todo: we don't want that, but it shouldn't matter)
#the sed erases the directory paths
#the xargs generates the final echo command list to be used