Esempio n. 1
0
 /**
  * @param string $queueName
  * @param Priority $priority
  *
  * @return string
  */
 private function getQueueNameWithPrioritySuffix($queueName, Priority $priority)
 {
     $prioritySuffix = '';
     if ('' !== $priority->getName()) {
         $prioritySuffix = static::PRIORITY_SEPARATOR . $priority->getName();
     }
     return $queueName . $prioritySuffix;
 }
 /**
  * @inheritdoc
  *
  * @throws PriorityLevelException
  */
 public function add(Priority $priority)
 {
     $newName = $priority->getName();
     $alreadyAdded = false;
     foreach ($this->priorities as $checkPriority) {
         if ($checkPriority->getName() === $newName) {
             $alreadyAdded = true;
             break;
         }
     }
     if ($alreadyAdded) {
         throw new PriorityLevelException('Level name ' . $priority->getName() . ' already exist.');
     }
     if (isset($this->priorities[$priority->getLevel()])) {
         throw new PriorityLevelException('Level ' . $priority->getLevel() . ' already exist.');
     }
     $priority->setPriorityHandler($this);
     $this->priorities[$priority->getLevel()] = $priority;
     ksort($this->priorities);
     return $this;
 }
Esempio n. 3
0
 /**
  * @param string $queueName
  * @param Priority $priority
  *
  * @return string
  */
 private function getQueuePath($queueName, Priority $priority)
 {
     $prioritySuffix = '';
     if ('' !== $priority->getName()) {
         $prioritySuffix = static::PRIORITY_SEPARATOR . $priority->getName();
     }
     return rtrim($this->repository, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $queueName . $prioritySuffix . '.' . static::QUEUE_FILE_EXTENSION;
 }