In this article I will show a simple way to log every change to doctrine 2 entity. This one will not be copy / paste. Just check out the code and help yourself. 1. Create event service /** * @developer Ivan Gospodinow */ namespace Application\Service; use Application\Entity\DbLogEntity; use Application\Entity\AbstractEntity; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; use \DateTime; class DoctrineLogChangesService […]
As always we go straight to coding. Download how-to-create-google-login-on-my-site-with-openid-in-5-min.zip
function csvToArray($file){ $rows = array(); $headers = array(); if(file_exists($file) && is_readable($file)){ $handle = fopen($file, 'r'); while (!feof($handle) ) { $row = fgetcsv($handle, 10240); if(empty($headers)) $headers = $row; else if(is_array($row)) $rows[] = array_combine($headers, $row); } fclose($handle); } else { throw new Exception($file.' doesn`t exist or is not readable.'); } return $rows; } Simple as that. Suggestions […]
This simple function will allow us to control php performance at level we need. /** * Calculates the processor load in % * @see sys_getloadavg * @author Ivan Gospodinow * @site ivangospodinow.com * @date 07.02.2013 * @param int $coreCount * @param int $interval * @return float */ function systemLoadInPercent($coreCount = 2,$interval = 1){ $rs = […]
In Zend Framework 2 , layout can be easily changed from module based on controller(name). Step 1. Add in module.config.php file 'controller_layouts' => array( 'MyControllerName' => 'layout/MyControllerName', ), and 'view_manager' => array( //more options 'template_map' => array( 'layout/MyControllerName'=> PATH_TO_TEMPLATE ), ), Step 2. Add in module.php $e->getApplication()->getEventManager()->getSharedManager() ->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); […]
Simple and working solution. ThisĀ code snippet will help you to destroy all dojo widgets. window.widgetsDestroy = function(){ require(['dijit/registry','dojo/query'],function(registry,query){ query('*[id]').forEach(function(node){ var widget = registry.byId(node.id); if(undefined !== widget){ widget.destroy(); } }); }); } Use it with : window.widgetsDestroy(); Suggestions or problems ? Write a comment.
This is something that was bugging me for a while. How can multiple developers work on same wordpress without messing up the code ? The answer came from two wordpress variables : WP_SITEURL and WP_HOME. If the two variables are set , wordpress blog do not get them from the database. Step 1. Adding this […]