This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
| <?php | |
| /** | |
| * Implements hook_form_alter(). | |
| * | |
| * Redirects user logins to the front page. | |
| */ | |
| function HOOK_form_user_login_alter(&$form, &$form_state) { | |
| $form['#action'] = url('user', array('query' => array('destination' => '<front>'))); | |
| } |
| // This is how you would use it. Pass in your collection | |
| // along with an individual callback as well as a batch callback | |
| Mage::getSingleton('stcore/resource_iterator_batched')->walk( | |
| $collection, | |
| array($this, 'batchIndividual'), | |
| array($this, 'batchAfter'), | |
| self::BATCH_SIZE | |
| ); | |
| public function batchIndividual($model) |
| class FormErrorsSerializer { | |
| public function serializeFormErrors(\Symfony\Component\Form\Form $form, $flat_array = false, $add_form_name = false, $glue_keys = '_') | |
| { | |
| $errors = array(); | |
| $errors['global'] = array(); | |
| $errors['fields'] = array(); | |
| foreach ($form->getErrors() as $error) { | |
| $errors['global'][] = $error->getMessage(); |
| var App = { | |
| myProperty : 'someValue', | |
| jqueryVar1 : $('.someClass'), | |
| jqueryVar2 : $('.someOtherClass'), | |
| jqueryVar3 : $('#id'), | |
| myConfig:{ | |
| useCaching:true, | |
| language: 'en' | |
| }, |
| <?php | |
| namespace Vendor\Module\Block\Adminhtml\Widget; | |
| class ImageChooser extends \Magento\Backend\Block\Template | |
| { | |
| /** | |
| * @var \Magento\Framework\Data\Form\Element\Factory | |
| */ | |
| protected $_elementFactory; |
| List of PHP 7 Packages: https://launchpad.net/ubuntu/+source/php7.0 | |
| Disclaimer: I get unreliable results when I don't run these commands seperately and in order. | |
| vagrant ssh | |
| sudo apt-get update | |
| sudo add-apt-repository ppa:ondrej/php | |
| sudo apt-get install php7.0 | |
| sudo apt-get update |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
| <?php | |
| namespace AppBundle\Controller; | |
| use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
| use Psr\Log\LoggerInterface; | |
| /** | |
| * This class is now a service, so you can use normal __construct DI if you want! | |
| */ |
# Install x-code command line tools
xcode-select --install
# Install homebrew itself