/**
  * populates the #thumbnails-json meta on media nodes
  *
  * Parameters:
  *   interval - # of nodes to process per pass, defaults to 25
  *   limit - # of nodes to process per run, defaults to 0 (all)
  *   offset - starting offset, defaults to 0
  *
  * @return void
  */
 public function syncJsonThumbnails()
 {
     $interval = $this->Request->getParameter('interval') or $interval = 25;
     $nodeLimit = $this->Request->getParameter('limit') or $nodeLimit = 0;
     $offset = $this->Request->getParameter('offset') or $offset = 0;
     $nq = new NodeQuery();
     $nq->setParameter('Elements.in', '@images');
     $nq->setParameter('OutTags.select', '#thumbnails.fields');
     $nq->setOrderBy('ActiveDate', 'DESC');
     $nq->setLimit($interval);
     $nq->setOffset($offset);
     $nq = $this->NodeService->findAll($nq, true);
     $nodes = $nq->getResults();
     $processedNodes = 0;
     while (count($nodes) > 0) {
         foreach ($nodes as $node) {
             /* @var Node $node */
             $tags = $node->getOutTags('#thumbnails');
             $thumbs = array();
             foreach ($tags as $tag) {
                 /* @var Tag $tag */
                 $thumb = new stdClass();
                 $thumb->value = $tag->TagValue;
                 $thumb->url = $tag->TagLinkNode->jump('#url');
                 $thumb->size = intval($tag->TagLinkNode->jump('#size'));
                 $thumb->height = intval($tag->TagLinkNode->jump('#height'));
                 $thumb->width = intval($tag->TagLinkNode->jump('#width'));
                 $thumbs[] = $thumb;
             }
             $this->NodeService->updateMeta($node->NodeRef, '#thumbnails-json', JSONUtils::encode($thumbs));
             echo $node->Slug . "\n";
         }
         $this->TransactionManager->commit()->begin();
         $processedNodes += count($nodes);
         if ($nodeLimit > 0 && $processedNodes >= $nodeLimit) {
             break;
         }
         $offset = $offset + $interval;
         unset($nodes);
         $nq->setLimit($interval);
         $nq->setOffset($offset);
         $nq->clearResults();
         $nq = $this->NodeService->findAll($nq, true);
         $nodes = $nq->getResults();
     }
 }
 public function updateMeta(NodeRef $nodeRef, $metaID, $value = null)
 {
     $metaID = ltrim($metaID, '#');
     $this->NodePermissions->checkThrow(__FUNCTION__, $nodeRef, $metaID, false);
     return parent::updateMeta($nodeRef, $metaID, $value);
 }