Ejemplo n.º 1
0
 /**
  * lint a file, pass errors to the queue
  * @param string $file path/to/file
  * @return bool
  */
 private function lintFile($file)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->write('lint file ' . $file . ' ... ');
     }
     $status = false;
     $handler = XMLFileHandler::createXmlHandlerFromFile($file);
     try {
         $handler->getDOMDocument();
         $status = true;
     } catch (XMLHandlerException $e) {
         $msg = new \stdClass();
         if ($handler->hasErrors()) {
             $formatter = new ErrorFormatter($handler->getXmlErrors());
             $formatter->setPrefix('    > ');
             $msg->file = $file;
             $msg->message = $formatter->getErrorsAsString();
         } else {
             $msg->file = $file;
             $msg->message = sprintf('    > %s (Exception: "%s")' . PHP_EOL, $e->getMessage(), get_class($e));
         }
         $this->errorQueue->add($this->errorQueue->count(), $msg);
     }
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         if ($status === false) {
             $this->output->writeln('<error>errors</error>');
         } else {
             $this->output->writeln('<info>passed.</info>');
         }
     } else {
         if ($status === false) {
             $this->output->write('<error>F</error>');
         } else {
             $this->output->write('.');
         }
     }
     return $status;
 }
Ejemplo n.º 2
0
 /**
  * @param \SplObserver $cliente
  */
 public function setCliente(\SplObserver $cliente)
 {
     $this->filaDeclientes->add($cliente);
 }