/** * @param bool $createIfNull * * @return Filesystem */ public function getStorage($createIfNull = true) { // Use requested file system if one... if (null === ($_storage = $this->get('storage')) && $createIfNull) { $_instance = $this->getInstance(); $_user = $_instance->user; if (empty($_user)) { try { $_user = User::findOrFail($_instance->user_id); } catch (ModelNotFoundException $_ex) { \Log::error('Attempt to create an instance for a non-existent user_id: ' . $_instance->user_id); throw new \RuntimeException('Invalid user assigned to instance.'); } } InstanceStorage::buildStorageMap($_user->storage_id_text); $_storage = $_instance->getStorageRootMount(); $this->setStorage($_storage); } return $_storage; }
/** * @param Instance $instance * @param bool $object If true, the Metadata object is returned instead of the array * * @return array|\DreamFactory\Enterprise\Common\Support\Metadata */ public static function makeMetadata(Instance $instance, $object = false) { if (null === ($_key = AppKey::mine($instance->id, OwnerTypes::INSTANCE))) { // Create an instance key $_key = AppKey::create(['key_class_text' => AppKeyClasses::INSTANCE, 'owner_id' => $instance->id, 'owner_type_nbr' => OwnerTypes::INSTANCE, 'server_secret' => config('dfe.security.console-api-key')]); if (null === $_key) { throw new \RuntimeException('Instance is unlicensed.'); } } $_cluster = static::_lookupCluster($instance->cluster_id); $_md = new Metadata(array_merge(static::$metadataTemplate, ['storage-map' => InstanceStorage::buildStorageMap($instance->user->storage_id_text), 'env' => static::buildEnvironmentMetadata($instance, $_cluster, $_key), 'db' => static::buildDatabaseMetadata($instance), 'paths' => static::buildPathMetadata($instance), 'audit' => static::buildAuditMetadata($instance), 'limits' => static::buildLimitsMetadata($instance)]), $instance->instance_name_text . '.json', $instance->getOwnerPrivateStorageMount()); return $object ? $_md : $_md->toArray(); }
/** * @param string|array|null $append * @param bool|true $create * @param int $mode * @param bool|true $recursive * * @return string */ public function getOwnerPrivatePath($append = null, $create = true, $mode = 0777, $recursive = true) { InstanceStorage::buildStorageMap($this->storage_id_text); return Disk::path([config('provisioning.storage-root', EnterpriseDefaults::STORAGE_ROOT), InstanceStorage::getStorageRootPath(), InstanceStorage::getPrivatePathName(), $append], $create, $mode, $recursive); }