diff --git a/src/Icons/IconSet.php b/src/Icons/IconSet.php index d10e3a05cc6..dc9004c5eb4 100644 --- a/src/Icons/IconSet.php +++ b/src/Icons/IconSet.php @@ -38,9 +38,13 @@ public function contents() return $this->files()->map->getContents()->all(); } - public function get(string $name): string + public function get(string $name): ?string { - return $this->filesystem->get($this->directory.'/'.$name.'.svg'); + $path = $this->directory.'/'.$name.'.svg'; + + return $this->filesystem->exists($path) + ? $this->filesystem->get($path) + : null; } private function files(): Collection diff --git a/tests/Fieldtypes/IconTest.php b/tests/Fieldtypes/IconTest.php index c464446bf3a..102c8f2245a 100644 --- a/tests/Fieldtypes/IconTest.php +++ b/tests/Fieldtypes/IconTest.php @@ -27,6 +27,12 @@ public function it_accepts_svg_strings() $this->assertStringContainsString('assertNull($this->fieldtype()->augment('this-icon-does-not-exist')); + } + private function fieldtype($config = []) { return (new Icon)->setField(new Field('test', array_merge(['type' => 'icon'], $config)));