JamesMoss\Flywheel\Repository::findAll PHP Method

findAll() public method

Returns all the documents within this repo.
public findAll ( ) : array
return array An array of Documents.
    public function findAll()
    {
        $ext = $this->formatter->getFileExtension();
        $files = $this->getAllFiles();
        $documents = array();
        foreach ($files as $file) {
            $fp = fopen($file, 'r');
            $contents = fread($fp, filesize($file));
            fclose($fp);
            $data = $this->formatter->decode($contents);
            if (null !== $data) {
                $doc = new $this->documentClass((array) $data);
                $doc->setId($this->getIdFromPath($file, $ext));
                $documents[] = $doc;
            }
        }
        return $documents;
    }

Usage Example

 /**
  * @return EncryptedTransaction[]
  */
 public function findAll()
 {
     /** @var EncryptedTransactionDocument[] $result */
     $result = $this->repository->findAll();
     $encryptedTransactions = $this->documentArrayToObjectArray($result);
     return $encryptedTransactions;
 }
All Usage Examples Of JamesMoss\Flywheel\Repository::findAll