/** * Adds a file from a string to the archive. * * @param string $local The path to the file in the archive. * @param string $contents The contents of the file. */ public function addFromString($local, $contents = null) { if (null === $this->dispatcher) { parent::addFromString($local, $contents); return; } $event = new PreAddFromStringEvent($this, $local, $contents); $this->dispatcher->dispatch(Events::PRE_ADD_FROM_STRING, $event); if (!$event->isSkipped()) { parent::addFromString($event->getLocal(), $event->getContents()); $event = new PostAddFromStringEvent($this, $event->getLocal(), $event->getContents()); $this->dispatcher->dispatch(Events::POST_ADD_FROM_STRING, $event); } }
/** * Logs when a file is added from a string. * * @param PostAddFromStringEvent $event The event arguments. */ public function onPostAddFromString(PostAddFromStringEvent $event) { $this->logger->info(sprintf('The string has been added as "%s".', basename($event->getLocal())), array('local' => $event->getLocal())); }