public function testIsLocatedInsideAPhar() { $this->assertFalse(PharExtractor::isLocatedInsideAPhar('/var/www/my_file')); $this->assertFalse(PharExtractor::isLocatedInsideAPhar('http://example.com/index.php')); $this->assertFalse(PharExtractor::isLocatedInsideAPhar('/var/www/phar://test.phar/my_file')); $this->assertTrue(PharExtractor::isLocatedInsideAPhar('phar:///var/www/test.phar/my_file')); }
/** * @param string $icon * * @return $this */ public function setIcon($icon) { // This makes the icon accessible for native commands when it's embedded inside a phar if (PharExtractor::isLocatedInsideAPhar($icon)) { $icon = PharExtractor::extractFile($icon); } $this->icon = $icon; return $this; }
/** * {@inheritdoc} */ public function send(Notification $notification) { if (!$notification->getBody()) { throw new InvalidNotificationException($notification, 'Notification body can not be empty'); } $builder = new ProcessBuilder(); if (self::SUPPORT_BINARY_PROVIDED === $this->support && $this instanceof BinaryProvider) { $dir = rtrim($this->getRootDir(), '/') . '/'; $embeddedBinary = $dir . $this->getEmbeddedBinary(); if (PharExtractor::isLocatedInsideAPhar($embeddedBinary)) { $embeddedBinary = PharExtractor::extractFile($embeddedBinary); foreach ($this->getExtraFiles() as $file) { PharExtractor::extractFile($dir . $file); } } $builder->setPrefix($embeddedBinary); } else { $builder->setPrefix($this->getBinary()); } $this->configureProcess($builder, $notification); $process = $builder->getProcess(); $process->run(); return $process->isSuccessful(); }