What is Calling the Add Function?
Permalink
I've been walking through the code and building my first blocks. Placing add() in my block's controller works as advertised. However, I cannot for the life of me find out why add() is even getting called. What is responsible for making sure that function gets called when the block is added?
Thanks for the info. Here's what I found after stepping through the code.
1. Dispatcher runs when adding a block.
2. Dispatcher runs a require for startup/tools.php.
3. Tools runs a require for tools/add_block_popup.php.
4. This file gets the block type class for the block type you selected and calls BlockView's render function passing along the 'add' command, the block type and an array of supporting objects.
5. BlockView then renders, calling the block type controller's setupAndRun function with the 'add' argument.
6. The controller then calls the runTask function with the add argument.
7. The runTask function then calls the block controller's add function.
I was trying to figure this all out manually with my code in Vim. I used NetBeans to step through the process and that helped a lot.
1. Dispatcher runs when adding a block.
2. Dispatcher runs a require for startup/tools.php.
3. Tools runs a require for tools/add_block_popup.php.
4. This file gets the block type class for the block type you selected and calls BlockView's render function passing along the 'add' command, the block type and an array of supporting objects.
5. BlockView then renders, calling the block type controller's setupAndRun function with the 'add' argument.
6. The controller then calls the runTask function with the add argument.
7. The runTask function then calls the block controller's add function.
I was trying to figure this all out manually with my code in Vim. I used NetBeans to step through the process and that helped a lot.
See the code:
https://github.com/concrete5/concrete5/blob/7248d39e53e6fa52b86329b3...