Airship\Engine\Keyggdrasil\TreeUpdate::loadSupplier PHP Method

loadSupplier() protected method

Return the appropriate supplier (or create it if it doesn't already exist)
protected loadSupplier ( Channel $chan, array $updateData ) : Supplier
$chan Channel
$updateData array
return Supplier
    protected function loadSupplier(Channel $chan, array $updateData) : Supplier
    {
        // No invalid names:
        $this->supplierName = \preg_replace('#[^A-Za-z0-9\\-_]#', '', $updateData['supplier']);
        try {
            if (!\file_exists(ROOT . '/config/supplier_keys/' . $this->supplierName . '.json')) {
                throw new NoSupplier($this->supplierName);
            }
            return $chan->getSupplier($this->supplierName);
        } catch (NoSupplier $ex) {
            if ($updateData['action'] !== self::ACTION_INSERT_KEY) {
                throw new CouldNotUpdate(\__('For new suppliers, we can only insert their first master key.'), 0, $ex);
            }
            if ($updateData['type'] !== self::KEY_TYPE_MASTER) {
                throw new CouldNotUpdate(\__('Non-master key provided. It is possible that the channel is borked.'), 0, $ex);
            }
            // If we reach here, it's a new supplier.
            $this->isNewSupplier = true;
            return $chan->createSupplier($updateData);
        }
    }