Наследование: extends Pimcore\Model\AbstractModel
Пример #1
0
 /**
  * @static
  * @return Sanitycheck
  */
 public static function getNext()
 {
     $sanityCheck = new Sanitycheck();
     $sanityCheck->getDao()->getNext();
     if ($sanityCheck->getId() and $sanityCheck->getType()) {
         return $sanityCheck;
     } else {
         return null;
     }
 }
Пример #2
0
 /**
  * Clear all relations in the database
  * @param Element\ElementInterface $element
  */
 public function cleanAllForElement($element)
 {
     try {
         $id = $element->getId();
         $type = Element\Service::getElementType($element);
         //schedule for sanity check
         $data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", array($id, $type));
         if (is_array($data)) {
             foreach ($data as $row) {
                 $sanityCheck = new Element\Sanitycheck();
                 $sanityCheck->setId($row['sourceid']);
                 $sanityCheck->setType($row['sourcetype']);
                 $sanityCheck->save();
             }
         }
         $this->db->delete("dependencies", $this->db->quoteInto("sourceid = ?", $id) . " AND " . $this->db->quoteInto("sourcetype = ?", $type));
         $this->db->delete("dependencies", $this->db->quoteInto("targetid = ?", $id) . " AND " . $this->db->quoteInto("targettype = ?", $type));
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
Пример #3
0
 /**
  *
  */
 public static function runSanityCheck()
 {
     $sanityCheck = Sanitycheck::getNext();
     while ($sanityCheck) {
         $element = self::getElementById($sanityCheck->getType(), $sanityCheck->getId());
         if ($element) {
             try {
                 self::performSanityCheck($element);
             } catch (\Exception $e) {
                 \Logger::error("Element\\Service: sanity check for element with id [ " . $element->getId() . " ] and type [ " . self::getType($element) . " ] failed");
             }
             $sanityCheck->delete();
         } else {
             $sanityCheck->delete();
         }
         $sanityCheck = Sanitycheck::getNext();
         // reduce load on server
         \Logger::debug("Now timeout for 3 seconds");
         sleep(3);
     }
 }