Get a table object, create it if it does not exist.

@throws UnexpectedValueException  If the table object doesn't implement DatabaseTableInterface
@return KDatabaseTableInterface
358289
public function getTable()
    {
        if (!($this->_table instanceof KDatabaseTableInterface))
        {
            //Make sure we have a table identifier
            if (!($this->_table instanceof KObjectIdentifier)) {
                $this->setTable($this->_table);
            }

            $this->_table = $this->getObject($this->_table);

            if (!($this->_table instanceof KDatabaseTableInterface))
            {
                throw new UnexpectedValueException(
                    'Table: ' . get_class($this->_table) . ' does not implement KDatabaseTableInterface'
                );
            }
        }

        return $this->_table;
    }
1331295
public function getRequest()
    {
        if(!$this->_request instanceof DispatcherRequestInterface)
        {
            //Setup the request
            $this->_request->user = $this->getUser();

            $this->_request = $this->getObject('dispatcher.request', ObjectConfig::unbox($this->_request));

            if(!$this->_request instanceof DispatcherRequestInterface)
            {
                throw new \UnexpectedValueException(
                    'Request: '.get_class($this->_request).' does not implement DispatcherRequestInterface'
                );
            }
        }

        return $this->_request;
    }
1171852
public function getFamily(): FamilyInterface
    {
        $familyCode = $this->getConfiguration()->getOption('family');
        if (null === $familyCode) {
            throw new UnexpectedValueException(
                "Missing 'family' configuration option for {$this->getConfiguration()->getCode()}"
            );
        }

        return $this->familyRegistry->getFamily($familyCode);
    }
748790
public function getState()
    {
        if(!$this->__state instanceof KModelStateInterface)
        {
            $this->__state = $this->getObject($this->__state, array('model' => $this));

            if(!$this->__state instanceof KModelStateInterface)
            {
                throw new UnexpectedValueException(
                    'State: '.get_class($this->__state).' does not implement KModelStateInterface'
                );
            }
        }

        return $this->__state;
    }
1052416
public BaseTable getTable()
    {
        BaseTable table = (BaseTable)super.getTable();
        if (table == null)    // It's possible that m_table was set in an overriding init method.
        {
            DatabaseOwner databaseOwner = null;
            if (this.getRecordOwner() != null)
                databaseOwner = this.getRecordOwner().getDatabaseOwner();
            if (databaseOwner != null)
            {
                BaseDatabase database = (BaseDatabase)databaseOwner.getDatabase(this.getDatabaseName(), this.getDatabaseType(), null);
                m_table = database.makeTable(this);
            }
        }
        return (BaseTable)super.getTable();
    }
600179
private function createProperty()
    {
        $propType = $this->propertyType();
        if (empty($propType)) {
            $ident = $this->propertyIdent();
            if ($ident && is_string($ident)) {
                $message = sprintf('Missing property type for property "%s"', $ident);
            } else {
                $message = sprintf('Missing property type');
            }
            throw new UnexpectedValueException($message);
        }

        $prop = $this->propertyFactory()->create($propType);

        $prop->setIdent($this->propertyIdent());
        $prop->setData($this->propertyData());

        return $prop;
    }
1228715
public function build(): GetDatabaseTableNamesRequest
	{
		$instance = new GetDatabaseTableNamesRequest();
		if ($this->databaseId === null) {
			throw new BuilderException('Property [databaseId] is required.');
		}
		$instance->databaseId = $this->databaseId;
		return $instance;
	}
667605
public function mapObjects()
    {
        if ($this->mapObjects === null) {
            $objType = $this->objType();
            if (!$objType) {
                throw new UnexpectedValueException(sprintf(
                    '%1$s cannot create collection map. Object type is not defined.',
                    get_class($this)
                ));
            }

            $loader = $this->collectionLoader();
            $loader->setModel($this->proto());

            $collectionConfig = $this->collectionConfig();
            if (is_array($collectionConfig) && !empty($collectionConfig)) {
                unset($collectionConfig['properties']);
                $loader->setData($collectionConfig);
            }

            $callback = function(&$obj) {
                $obj->mapInfoboxTemplate = $this->infoboxTemplate();

                if ($this->latProperty() && $this->latProperty()) {
                    $obj->mapShowMarker = true;
                    $obj->mapLat = $this->getPropertyValue($obj, $this->latProperty());
                    $obj->mapLon = $this->getPropertyValue($obj, $this->lonProperty());

                    if (!$obj->mapLat || !$obj->mapLon) {
                        $obj = null;
                    }
                } else {
                    $obj->mapShowMarker = false;
                }

                if ($this->pathProperty()) {
                    $mapPath = $this->getPropertyValue($obj, $this->pathProperty());
                    if ($mapPath) {
                        $obj->mapShowPath = true;
                        // Same type of coords.
                        $obj->mapPath = $this->formatPolygon($mapPath);

                        if (!$obj->mapPath) {
                            $obj = null;
                        }
                    } else {
                        $obj->mapShowPath = false;
                    }
                }

                if ($this->polygonProperty()) {
                    $mapPolygon = $this->getPropertyValue($obj, $this->polygonProperty());
                    if ($mapPolygon) {
                        $obj->mapShowPolygon = true;
                        $obj->mapPolygon = $this->formatPolygon($mapPolygon);

                        if (!$obj->mapPolygon) {
                            $obj = null;
                        }
                    } else {
                        $obj->mapShowPolygon = false;
                    }
                }
            };

            $loader->setCallback($callback->bindTo($this));

            $this->mapObjects = $loader->load();
        }

        foreach ($this->mapObjects as $obj) {
            $GLOBALS['widget_template'] = $obj->mapInfoboxTemplate;
            yield $obj;
            $GLOBALS['widget_template'] = '';
        }
    }
956859
public function getState()
    {
        if(!$this->__state instanceof ModelStateInterface)
        {
            $this->__state = $this->getObject($this->__state, array(
                'model'    => $this,
                'defaults' => $this->getConfig()->state_defaults
            ));

            if(!$this->__state instanceof ModelStateInterface)
            {
                throw new \UnexpectedValueException(
                    'State: '.get_class($this->__state).' does not implement ModelStateInterface'
                );
            }
        }

        return $this->__state;
    }
1325398
protected function getTable($data = null)
    {
        if (is_null($data)) {
            $this->_table = static::$table;
            $this->_prifixTable = (Config::get('database.prefixing') ? Config::get('database.prefixe') : '').static::$table;
            //
            if (!$this->checkTable()) {
                throw new TableNotFoundException(static::$table);
            }
            //
            return $this->_prifixTable;
        } else {
            $this->_prifixTable = $data['prifixTable'];
            $this->_table = static::$table;
        }
    }
43016
function export() {
		$export = array_merge($this->data, $this->cell);
		foreach ($export as &$val) {
			if ($val instanceof Cell) {
				if ($val->isExpr()) {
					throw new \UnexpectedValueException("Cannot export an SQL expression");
				}
				$val = $val->get();
			}
		}
		return $export;
	}
98771
public static function create($data, $class)
    {
        if ('[]' === substr($class, -2)) {
            return self::createCollection($data, substr($class, 0, -2));
        }

        if (null === $data) {
            return null;
        }

        if (!\is_array($data)) {
            throw new \UnexpectedValueException(
                sprintf('Expected null or array, %s given.', \gettype($data))
            );
        }

        return self::createObject($data, $class);
    }
1336114
protected function create_key() {
		if ( is_array( $this->data ) ) {
			$this->data[ $this->key ] = null;
		} elseif ( is_object( $this->data ) ) {
			$this->data->{$this->key} = null;
		} else {
			$type = gettype( $this->data );
			throw new UnexpectedValueException(
				"Cannot create key \"{$this->key}\" on data type {$type}"
			);
		}
	}
1062602
public function sqlFrom()
    {
        if (!$this->hasTable()) {
            throw new UnexpectedValueException(
                'Can not get SQL FROM clause. No table defined.'
            );
        }

        $table = $this->table();
        return '`'.$table.'` AS `'.self::DEFAULT_TABLE_ALIAS.'`';
    }
576479
protected function getMetaClass()
    {
        foreach ($this->builtInClasses as $model => $meta) {
            if ($this instanceof $model) {
                return $meta;
            }
        }

        throw new UnexpectedValueException(sprintf('%s must extends one of Corcel built-in models: Comment, Post, Term or User.', static::class));
    }
1039084
protected function makeNestedDataObject(string $class, $data, $key): DataObjectInterface
    {
        $data = ($data instanceof Arrayable) ? $data->toArray() : $data;

        if ( ! is_array($data)) {

            throw new UnexpectedValueException(
                "Cannot instantiate data object '{$class}' with non-array data for key '{$key}'"
                . (is_scalar($data) || is_object($data) && method_exists($data, '__toString')
                    ?   ' (data: ' . (string) $data . ')'
                    :   null)
            );
        }

        /** @var DataObjectInterface $data */
        return new $class($data);
    }
734311
public function createValueBuilder() {
		if ($this->qualifiedName === null) {
			return new EagerValueBuilder(null);
		}
		
		$file = null;
		try {
			$file = $this->fileManager->getByQualifiedName($this->qualifiedName);
		} catch (QualifiedNameFormatException $e) {
			throw new CorruptedDataException('Failed to lookup value for ' . $this->entityProperty, 0, 
					new CorruptedDataException('Field \'' . $this->entityProperty->getColumnName()
							. '\' of table \'' . $this->entityProperty->getEntityModel()->getTableName() 
							. '\' contains an invalid value: ' . $this->qualifiedName, 0, $e));	
		}
		
		if ($file !== null) {
			return new EagerValueBuilder($file);
		}
		
		return new EagerValueBuilder(new UnknownFile($this->qualifiedName, get_class($this->fileManager)));
	}