Exemple #1
0
 /**
  * Implementation Create Backup functionality for Media
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return bool
  */
 public function create()
 {
     $this->_prepareIgnoreList();
     return parent::create();
 }
 /**
  * Performs the benchmark.
  * At the start and at the end of the procedure call loop, it takes a snapshot
  * of PHP background data and returns the difference of both
  *
  * @param bool $withOutput If set to false, output is suppressed (var_dump, echo etc.) (Default: false)
  *
  * @return Snapshot
  */
 public function process($withOutput = false)
 {
     $it = $this->_iterationCount;
     if (!$withOutput) {
         ob_start();
     }
     $start = Snapshot::create();
     while ($it--) {
         call_user_func_array($this->_operation, $this->_args);
     }
     $end = Snapshot::create();
     if (!$withOutput) {
         ob_get_clean();
     }
     return $end->diff($start);
 }
Exemple #3
0
 switch ($_POST['task']) {
     case 'loadCategories':
         $document = Document::fromDatabase($_POST['documentID']);
         echo json_encode($document->getCategories());
         break;
     case 'saveCategories':
         $document = Document::fromDatabase($_POST['documentID']);
         $document->changeCategories(json_decode(stripslashes($_POST['categories']), true));
         break;
     case 'getSnapshots':
         $document = Document::fromDatabase($_POST['documentID']);
         echo json_encode(Snapshot::getList($document));
         break;
     case 'saveSnapshot':
         $document = Document::fromDatabase($_POST['documentID']);
         Snapshot::create($document, json_decode(stripslashes($_POST['documentData']), true), $_POST['timestamp']);
         break;
     case 'loadSnapshot':
         $document = Document::fromDatabase($_POST['documentID']);
         echo json_encode(Snapshot::getData($document, $_POST['snapshotID']));
         break;
     case 'deleteDocument':
         $document = Document::fromDatabase($_POST['id']);
         $document->delete();
         break;
     case 'loadDocuments':
         echo json_encode(Document::getList(Document::FORMAT_JSON));
         break;
     case 'createDocument':
         $document = Document::create($_POST['name']);
         echo $document->getId();
Exemple #4
0
 public static function import(array $data)
 {
     $document = self::create($data['name'], $data['creation_date']);
     $document->changeCategories($data['categories']);
     $data['snapshots'] = array_reverse($data['snapshots']);
     foreach ($data['snapshots'] as $snapshot) {
         Snapshot::create($document, $snapshot['data'], strtotime($snapshot['creation_date']));
     }
 }
 public function crawlWebPage(Webpage $webpage, $mode = 'normal')
 {
     if (!$webpage->needsCrawl()) {
         return false;
     }
     // if it will crash we will remember it
     $webpage->last_status_code = Webpage::STATUS_CODE_CRASH;
     $webpage->save();
     $url = $webpage->url;
     if ($mode == 'debug') {
         //echo $url;
         return true;
     }
     $crawler = new \Arachnid\Crawler($url, 1);
     $crawler->traverse();
     $html = $crawler->getHtml();
     $binary = $crawler->getBinary();
     $tmpLinks = $crawler->getInternalLinks();
     $links = $this->filterLinks($tmpLinks, $webpage);
     $statusCode = $crawler->getStatusCode();
     $snapshot = Snapshot::create(['html' => $html, 'binary' => $binary, 'webpage_id' => $webpage->id, 'status_code' => $statusCode]);
     $snapshot->processChange();
     foreach ($links as $link) {
         Webpage::firstOrCreate(['url' => $link, 'site_id' => $webpage->site_id]);
     }
     $webpage->crawlcount++;
     $webpage->last_status_code = $statusCode;
     $webpage->save();
     return true;
 }