lock() публичный статический метод

public static lock ( string $key ) : boolean
$key string
Результат boolean
Пример #1
0
 /**
  * create lock file
  * @return void
  */
 public function lock()
 {
     Tool\Lock::lock($this->getLockKey());
 }
Пример #2
0
 /**
  *
  */
 public function setLastExecution()
 {
     Model\Tool\Lock::lock($this->_pidFileName);
 }
Пример #3
0
 /**
  * starts reindex mode for index
  * - new index with new version is created
  * - complete store table for current tenant is resetted in order to recreate a new index version
  *
  * while in reindex mode
  * - all index updates are stored into the new index version
  * - no index structure updates are allowed
  *
  */
 protected function startReindexMode()
 {
     // start reindex mode with pimcore lock
     $success = Tool\Lock::lock(self::REINDEX_LOCK_KEY);
     if (!$success) {
         throw new Exception("Key " . self::REINDEX_LOCK_KEY . " already locked, should not be the case!");
     }
     // increment version and recreate index structures
     $this->indexVersion++;
     Logger::info("Could not put index Mapping -> creating new Index. Version Number: " . $this->indexVersion);
     $this->doCreateOrUpdateIndexStructures(true);
     // reset indexing queue in order to initiate a full re-index to the new index version
     $this->resetIndexingQueue();
 }
Пример #4
0
 /**
  * @param $thumbnailName
  * @param int $page
  * @param bool $deferred $deferred deferred means that the image will be generated on-the-fly (details see below)
  * @return mixed|string
  */
 public function getImageThumbnail($thumbnailName, $page = 1, $deferred = false)
 {
     // just 4 testing
     //$this->clearThumbnails(true);
     if (!\Pimcore\Document::isAvailable()) {
         \Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath() . " no document adapter is available");
         return "/pimcore/static/img/filetype-not-supported.png";
     }
     $thumbnail = Image\Thumbnail\Config::getByAutoDetect($thumbnailName);
     $thumbnail->setName("document_" . $thumbnail->getName() . "-" . $page);
     try {
         if (!$deferred) {
             $converter = \Pimcore\Document::getInstance();
             $converter->load($this->getFileSystemPath());
             $path = PIMCORE_TEMPORARY_DIRECTORY . "/document-image-cache/document_" . $this->getId() . "__thumbnail_" . $page . ".png";
             if (!is_dir(dirname($path))) {
                 \Pimcore\File::mkdir(dirname($path));
             }
             $lockKey = "document-thumbnail-" . $this->getId() . "-" . $page;
             if (!is_file($path) && !Model\Tool\Lock::isLocked($lockKey)) {
                 Model\Tool\Lock::lock($lockKey);
                 $converter->saveImage($path, $page);
                 Model\Tool\Lock::release($lockKey);
             } else {
                 if (Model\Tool\Lock::isLocked($lockKey)) {
                     return "/pimcore/static/img/please-wait.png";
                 }
             }
         }
         if ($thumbnail) {
             $path = Image\Thumbnail\Processor::process($this, $thumbnail, $path, $deferred);
         }
         return preg_replace("@^" . preg_quote(PIMCORE_DOCUMENT_ROOT) . "@", "", $path);
     } catch (\Exception $e) {
         \Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath());
         \Logger::error($e);
     }
     return "/pimcore/static/img/filetype-not-supported.png";
 }
Пример #5
0
 /**
  *
  */
 public function generate()
 {
     $errorImage = PIMCORE_PATH . '/static6/img/filetype-not-supported.png';
     $generated = false;
     if (!$this->asset) {
         $this->filesystemPath = $errorImage;
     } elseif (!$this->filesystemPath) {
         $config = $this->getConfig();
         $config->setName("document_" . $config->getName() . "-" . $this->page);
         try {
             $path = null;
             if (!$this->deferred) {
                 $converter = \Pimcore\Document::getInstance();
                 $converter->load($this->asset->getFileSystemPath());
                 $path = PIMCORE_TEMPORARY_DIRECTORY . "/document-image-cache/document_" . $this->asset->getId() . "__thumbnail_" . $this->page . ".png";
                 if (!is_dir(dirname($path))) {
                     \Pimcore\File::mkdir(dirname($path));
                 }
                 $lockKey = "document-thumbnail-" . $this->asset->getId() . "-" . $this->page;
                 if (!is_file($path) && !Model\Tool\Lock::isLocked($lockKey)) {
                     Model\Tool\Lock::lock($lockKey);
                     $converter->saveImage($path, $this->page);
                     $generated = true;
                     Model\Tool\Lock::release($lockKey);
                 } elseif (Model\Tool\Lock::isLocked($lockKey)) {
                     return "/pimcore/static6/img/please-wait.png";
                 }
             }
             if ($config) {
                 $path = Image\Thumbnail\Processor::process($this->asset, $config, $path, $this->deferred, true, $generated);
             }
             $this->filesystemPath = $path;
         } catch (\Exception $e) {
             Logger::error("Couldn't create image-thumbnail of document " . $this->asset->getRealFullPath());
             Logger::error($e);
             $this->filesystemPath = $errorImage;
         }
         \Pimcore::getEventManager()->trigger("asset.document.image-thumbnail", $this, ["deferred" => $this->deferred, "generated" => $generated]);
     }
 }