public function updateTreeNativelyWithProgressMessage($nodeUid) { $nodeUid = (array) $nodeUid; if (0 === count($nodeUid)) { Buffer::dump("\n##### Nothing to update. ###\n"); return; } $convert_memory = function ($size) { $unit = array('B', 'KB', 'MB', 'GB'); return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i]; }; $starttime = microtime(true); Buffer::dump("\n##### Update tree (natively) started ###\n"); foreach ($nodeUid as $uid) { $this->_em->clear(); $starttime = microtime(true); Buffer::dump("\n [START] update tree of {$uid} in progress\n\n"); $this->updateTreeNatively($uid); Buffer::dump("\n [END] update tree of {$uid} in " . (microtime(true) - $starttime) . 's (memory status: ' . $convert_memory(memory_get_usage()) . ')' . "\n"); } Buffer::dump("\n##### Update tree (natively) in " . (microtime(true) - $starttime) . "s #####\n\n"); }
/** * Save Entities. * * @param array $entities */ public function save(array $entities, $check_existing = true) { //KILL LE CRON TOUT LES 3 ARTICLE if ($this->_importedItemsCount === 3) { die; } $id_label = 'get' . ucfirst(array_key_exists('id_label', $this->_import_config) ? $this->_import_config['id_label'] : 'uid'); $starttime = microtime(true); Buffer::dump('Saving ' . count($entities) . ' items...', null, $this->_application->isDebugMode()); foreach ($entities as $entity) { if (null !== $entity && false === $this->_application->getEntityManager()->contains($entity)) { $this->_application->getEntityManager()->persist($entity); unset($entity); } $this->_importedItemsCount++; } $this->_application->getEntityManager()->flush(); $this->_application->getEntityManager()->clear(); //gc_collect_cycles(); $this->getConverter()->afterEntitiesFlush($this, $entities); $this->flushMemory(); Buffer::dump(' in ' . (microtime(true) - $starttime) . ' s (total: ' . $this->_importedItemsCount . ' - memory status: ' . self::convertMemorySize(memory_get_usage()) . ")\n", null, $this->_application->isDebugMode()); }