public function execute(Command $command) : Layout
 {
     $xml = $this->connection->execute($command, self::GRAMMAR_PATH);
     $errorCode = (int) $xml->ERRORCODE;
     if ($errorCode > 0) {
         throw FileMakerException::fromErrorCode($errorCode);
     }
     return new Layout((string) $xml->LAYOUT['DATABASE'], (string) $xml->LAYOUT['NAME'], ...$this->parseFields($xml, $this->parseValueLists($xml)));
 }
Esempio n. 2
0
 private function getWrappedStream() : StreamInterface
 {
     if (null !== $this->wrappedStream) {
         return $this->wrappedStream;
     }
     return $this->wrappedStream = $this->connection->getAsset($this->assetUri);
 }
 public function execute(Command $command) : CollectionInterface
 {
     $xml = $this->connection->execute($command, self::GRAMMAR_PATH);
     $errorCode = (int) $xml->error['code'];
     $dataSource = $xml->datasource;
     if (8 === $errorCode || 401 === $errorCode) {
         // "Empty result" or "No records match the request"
         return new ItemCollection([], 0);
     } elseif ($errorCode > 0) {
         throw FileMakerException::fromErrorCode($errorCode);
     }
     try {
         $metadata = $this->parseMetadata($xml->metadata[0]);
         $records = [];
         foreach ($xml->resultset[0]->record as $record) {
             $records[] = $this->parseRecord($record, $metadata);
         }
     } catch (UnknownFieldException $e) {
         throw UnknownFieldException::fromConcreteException((string) $dataSource['database'], (string) $dataSource['table'], (string) $dataSource['layout'], $e);
     } catch (Exception $e) {
         throw ParseException::fromConcreteException((string) $dataSource['database'], (string) $dataSource['table'], (string) $dataSource['layout'], $e);
     }
     return new ItemCollection($records, (int) $xml->resultset[0]['count']);
 }