Skip to content

Commit 36e71bc

Browse files
authored
Merge pull request #15 from tattersoftware/ignores
Bugfixes
2 parents 9fc5b0f + c429728 commit 36e71bc

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/Drafter/Handlers/ModelHandler.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace Tatter\Schemas\Drafter\Handlers;
22

33
use CodeIgniter\Config\BaseConfig;
4+
use CodeIgniter\Model;
45
use Config\Services;
56
use Tatter\Schemas\Drafter\BaseDrafter;
67
use Tatter\Schemas\Drafter\DrafterInterface;
@@ -162,12 +163,27 @@ protected function getModels(): array
162163
// Try to load each class
163164
foreach ($classes as $class)
164165
{
165-
// Try to instantiate
166-
try { $instance = new $class(); }
167-
catch (\Exception $e) { continue; }
168-
166+
// Check for ignored namespaces
167+
foreach ($this->config->ignoredNamespaces as $namespace)
168+
{
169+
if (strpos($class, $namespace) === 0)
170+
{
171+
continue 2;
172+
}
173+
}
174+
169175
// Make sure it's really a model
170-
if (! ($instance instanceof \CodeIgniter\Model))
176+
if (! is_a($class, Model::class, true))
177+
{
178+
continue;
179+
}
180+
181+
// Try to instantiate
182+
try
183+
{
184+
$instance = new $class();
185+
}
186+
catch (\Exception $e)
171187
{
172188
continue;
173189
}

0 commit comments

Comments
 (0)