Airship\Engine\Landing::blueprint PHP Method

blueprint() protected method

Grab a blueprint
protected blueprint ( string $name, $cArgs ) : Blueprint
$name string
$cArgs Constructor arguments
return Blueprint
    protected function blueprint(string $name, ...$cArgs) : Blueprint
    {
        if (!empty($cArgs)) {
            $cache = Util::hash($name . ':' . \json_encode($cArgs));
        } else {
            $cArgs = [];
            $cache = Util::hash($name . '[]');
        }
        if (!isset($this->_cache['blueprints'][$cache])) {
            // CACHE MISS. We need to build it, then!
            $db = $this->airshipChooseDB();
            if ($db instanceof DBInterface) {
                \array_unshift($cArgs, $db);
            }
            try {
                $class = Gears::getName('Blueprint__' . $name);
            } catch (GearNotFound $ex) {
                if ($name[0] === '\\') {
                    // If you pass a \Absolute\Namespace, we will just use it.
                    $class = $name;
                } else {
                    // We default to \Current\Application\Namespace\Blueprint\NameHere.
                    $x = \explode('\\', $this->getNamespace());
                    \array_pop($x);
                    $class = \implode('\\', $x) . '\\Blueprint\\' . $name;
                }
            }
            $this->_cache['blueprints'][$cache] = new $class(...$cArgs);
            if (!$this->_cache['blueprints'][$cache] instanceof Blueprint) {
                throw new InvalidType(\trk('errors.type.wrong_class', 'Blueprint'));
            }
            \Airship\tightenBolts($this->_cache['blueprints'][$cache]);
        }
        return $this->_cache['blueprints'][$cache];
    }