Get schema

@param  boolean $reload

@return \Doctrine\DBAL\Schema\Schema
3592
protected function getSchema($reload = false)
    {
        if (!isset($this->dbalSchema) || $reload) {
            $this->dbalSchema = new \Espo\Core\Utils\Database\DBAL\Schema\Schema();
        }

        return $this->dbalSchema;
    }
7597
public function getExtension($reload = false)
	{
		if ($reload || null === $this->extension)
		{
			$this->extension = $this->loadExtension();
		}

		return clone $this->extension;
	}
428393
public function schema($schema = null)
    {
        if (func_num_args()) {
            $this->_schema = $schema;
            return $this;
        }
        if (!$this->_schema) {
            $this->_schema = static::definition();
        }
        return $this->_schema;
    }
472406
public function schema($schema = null) {
        if (!func_num_args()) {
            return $this->_schema;
        }
        $this->_schema = $schema;
        return $this;
    }
893399
public function detachAllRoles($reload = true)
    {
        event(new DetachingRolesFromUser($this));
        $results = $this->roles()->detach();
        event(new DetachedRolesFromUser($this, $results));

        $this->loadRoles($reload);

        return $results;
    }
439656
protected function getSchemaByType(string $type): SchemaInterface
    {
        if ($this->hasCreatedProvider($type) === true) {
            return $this->getCreatedProvider($type);
        }

        $classNameOrCallable = $this->getProviderMapping($type);
        if (\is_string($classNameOrCallable) === true) {
            $schema = $this->createSchemaFromClassName($classNameOrCallable);
        } else {
            \assert(\is_callable($classNameOrCallable) === true);
            $schema = $this->createSchemaFromCallable($classNameOrCallable);
        }
        $this->setCreatedProvider($type, $schema);

        /** @var SchemaInterface $schema */

        $this->setResourceToJsonTypeMapping($schema->getType(), $type);

        return $schema;
    }
786665
public function detachAllPermissions($reload = true)
    {
        event(new DetachingAllPermissions($this));
        $detached = $this->permissions()->update(['group_id' => 0]);
        event(new DetachedAllPermissions($this, $detached));

        $this->loadPermissions($reload);

        return $detached;
    }
309262
public function getData($refresh=false)
	{
		if($this->_data===null || $refresh)
			$this->_data=$this->fetchData();
		return $this->_data;
	}
716125
protected function loadData($reload = false) {
        if ($this->data === null || $reload) {
            $this->db = $this->config['dir'] . DIRECTORY_SEPARATOR . $this->config['name'];
            if (!file_exists($this->db)) {
                $templateFile = $this->config['template'];
                if (file_exists($templateFile)) {
                    copy($templateFile, $this->db);
                } else {
                    file_put_contents($this->db, '{}');
                }
            } else {
                if ($this->config['backup']) {
                   try {
                       //todo make backup of database
                   } catch (\Exception $e) {

                   }
                }
            }
            $this->data = json_decode(file_get_contents($this->db), true);
            if (!$this->data) {
                throw new \InvalidArgumentException('Database file ' . $this->db
                    . ' contains invalid json object. Please validate or remove file');
            }
        }
        return $this->data;
    }
398462
protected function loadData(bool $autoload = true): self
    {
        if ($this->loaded) {
            return $this;
        }

        $this->loaded = true;

        if (empty($this->data) || !is_array($this->data)) {
            if ($this->autoload && $autoload) {
                //Only for non partial selections (excluded already selected)
                $this->data = $this->loadRelated();
            } else {
                $this->data = [];
            }
        }

        return $this->initInstances();
    }
1000226
public function getSchema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = new Schema($this);
        }

        return $this->schema;
    }
208455
public function getSchema()
    {
        if ($this->_schema === null) {
            $this->_schema = $this->_initializeSchema(
                $this->getConnection()
                    ->getSchemaCollection()
                    ->describe($this->getTable())
            );
        }

        return $this->_schema;
    }
569053
public function get($schemaId)
    {
        $class = $this->getSchemaClass();
        $data = static::$schemas[$schemaId];
        /** @var Schema $schema */
        $schema = call_user_func([$class, 'deserializeObject'], $data);
        $schema->getMeta()->setLocation($this->schemasEndpointUrl.$schemaId);

        return $schema;
    }
1354463
public function getFileCollection($refresh = false)
    {
        if ($refresh || !is_object($this->_fileCollection)) {
            $this->_fileCollection = Yii::createObject([
                'class' => 'yii\mongodb\Collection',
                'database' => $this->database,
                'name' => $this->name
            ]);
        }

        return $this->_fileCollection;
    }
1105100
public function syncRoles($slugs, $reload = true)
    {
        /** @var \Illuminate\Database\Eloquent\Collection $roles */
        $roles = app(RoleContract::class)->whereIn('slug', $slugs)->get();

        event(new SyncingRolesWithPermission($this, $roles));
        $synced = $this->roles()->sync($roles->pluck('id'));
        event(new SyncedRolesWithPermission($this, $roles, $synced));

        $this->loadRoles($reload);

        return $synced;
    }
111271
public function schema($request)
    {
        $formName = $request->param('FormName');
        if (!in_array($formName, $this->formNames)) {
            return parent::schema($request);
        }

        return $this->generateSchemaForForm($formName, $request);
    }
1316896
public function detachAllRoles($reload = true)
    {
        event(new DetachingAllRolesFromPermission($this));
        $results = $this->roles()->detach();
        event(new DetachedAllRolesFromPermission($this, $results));

        $this->loadRoles($reload);

        return $results;
    }