@param string $type
@param array  $options

@return QueriableResourceInterface
776536
private static function getQueriableResource($type, array $options = [])
    {
        if (!array_key_exists($type, self::$cache['resources']) || self::haveOptionsBeenUpdated($type, $options)) {
            self::$cache['options'][$type] = $options;
            self::$cache['resources'][$type] = new QueriableResource($type, $options);
        }
        return self::$cache['resources'][$type];
    }
638969
protected function createType($type, $options = array())
	{
		$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);

		$class = __NAMESPACE__ . '\\Type\\' . ucfirst($type);

		if (!class_exists($class))
		{
			throw new InvalidArgumentException("Type [$type] not supported.");
		}

		return new $class($options);
	}
614726
public function column($name, $type = null, $options = [])
    {
        return $this->addColumn($name, $type, $options);
    }
12621
protected function _getTypeOutput(array $options, $url, $type)
    {
        $type = Str::low($type);
        if ($type === 'css') {
            return $this->_getCssOutput($options, $url);
        }

        return $this->_getScriptOutput($options, $url);
    }
1162704
public function getQuery(array $options = []) : Query
    {
        $documentPersister = $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);

        $query = $this->query;

        $query['query'] = $this->expr->getQuery();
        $query['query'] = $documentPersister->addDiscriminatorToPreparedQuery($query['query']);
        $query['query'] = $documentPersister->addFilterToPreparedQuery($query['query']);

        $query['newObj'] = $this->expr->getNewObj();

        if (isset($query['distinct'])) {
            $query['distinct'] = $documentPersister->prepareFieldName($query['distinct']);
        }

        if ($this->class->inheritanceType === ClassMetadata::INHERITANCE_TYPE_SINGLE_COLLECTION && ! empty($query['upsert']) &&
            (empty($query['query'][$this->class->discriminatorField]) || is_array($query['query'][$this->class->discriminatorField]))) {
            throw new InvalidArgumentException('Upsert query that is to be performed on discriminated document does not have single ' .
                'discriminator. Either not use base class or set \'' . $this->class->discriminatorField . '\' field manually.');
        }

        if (! empty($query['select'])) {
            $query['select'] = $documentPersister->prepareProjection($query['select']);
            if ($this->hydrate && $this->class->inheritanceType === ClassMetadata::INHERITANCE_TYPE_SINGLE_COLLECTION
                && ! isset($query['select'][$this->class->discriminatorField])) {
                $includeMode = 0 < count(array_filter($query['select'], static function ($mode) {
                    return $mode === 1;
                }));
                if ($includeMode && ! isset($query['select'][$this->class->discriminatorField])) {
                    $query['select'][$this->class->discriminatorField] = 1;
                }
            }
        }

        if (isset($query['sort'])) {
            $query['sort'] = $documentPersister->prepareSort($query['sort']);
        }

        if ($this->class->readPreference && ! array_key_exists('readPreference', $query)) {
            $query['readPreference'] = new ReadPreference($this->class->readPreference, $this->class->readPreferenceTags);
        }

        return new Query(
            $this->dm,
            $this->class,
            $this->collection,
            $query,
            $options,
            $this->hydrate,
            $this->refresh,
            $this->primers,
            $this->readOnly
        );
    }
828429
public function create($type)
    {
        $typeOptions    = $this->getOption(self::OPTION_MAPPERS);
        $typeOption     = isset($typeOptions[$type]) ? $typeOptions[$type] : $this->throwException();
        $importerString = isset($typeOption[self::OPTION_MAPPERS_IMPORTER]) ? $typeOption[self::OPTION_MAPPERS_IMPORTER] : $this->throwException();
        $importer       = $this->buildService($importerString, ImportServiceInterface::class);

        if (isset($typeOption[self::OPTION_MAPPERS_MAPPER])) {
            $mapperString = $typeOption[self::OPTION_MAPPERS_MAPPER];
            $mapper       = $this->buildService($mapperString);
        } else {
            $mapper = $this->getDefaultMapper();
        }

        $this->propagate($mapper);
        $importer->setMapper($mapper);

        return $importer;
    }
156963
public function getQuery(string $type = 'select', ...$arguments): QueryObject
    {
        $allowedTypes = [
            'select',
            'insert',
            'insertignore',
            'replace',
            'delete',
            'update',
            'criteriaonly',
        ];

        if (\in_array(strtolower($type), $allowedTypes, true) === false) {
            throw new Exception($type . ' is not a known type.', 1);
        }

        $queryArr = $this->adapterInstance->$type($this->statements, ...$arguments);

        return new QueryObject($queryArr['sql'], $queryArr['bindings'], $this->getConnection());
    }
841287
public static function createFromResource(Resource $resource, array $options = [])
    {
        $entity = new self();

        $entity->applyResource($resource);

        return $entity;
    }
430649
public function setCache($type, array $options = array())
    {
        $this->cacheType = $type;
        $this->cacheOptions = $options;

        return $this;
    }
841230
public static function queryBuilderStatic(array $options = []) : \Object\Query\Builder {
		$class = get_called_class();
		$model = new $class();
		$options['cache_tags'] = $options['cache_tags'] ?? [];
		$sql = $model->sql([
			'where' => $options['where'] ?? []
		], $options['cache_tags']);
		// alias
		$alias = $options['alias'] ?? 'a';
		unset($options['alias']);
		$object = new \Object\Query\Builder($model->db_link, $options);
		$object->from($sql, $alias);
		// registered ALC
		if (empty($options['skip_acl'])) {
			\Object\ACL\Registered::process('\\' . get_called_class(), $object, [
				'initiator' => $options['initiator'] ?? null,
				'existing_values' => $options['existing_values'] ?? null
			]);
		}
		return $object;
	}
209955
public function getQuery(array $options = array())
    {
        $query = $this->query;
        $query['query'] = $this->expr->getQuery();
        $query['newObj'] = $this->expr->getNewObj();
        return new Query($this->collection, $query, $options);
    }
338359
public function exchangeDeclare($exchange, $type, $options = array())
    {
        $args = new Writer();
        $args->writeShort($options['ticket'])
            ->writeShortStr($exchange)
            ->writeShortStr($type)
            ->writeBit($options['passive'])
            ->writeBit($options['durable'])
            ->writeBit($options['auto_delete'])
            ->writeBit($options['internal'])
            ->writeBit($options['no_wait'])
            ->writeTable($options['arguments']);
        return $args;
    }
1303156
public function instance($type = null, $options = array())
	{
		$type = $type ?: $this->getType();

		$signature = serialize(array($type, $options));

		// If the given type has not been created before, we will create the instances
		// here and cache it so we can return it next time very quickly. If there is
		// already a type created by this name, we'll just return that instance.
		if (!isset($this->types[$signature]))
		{
			try
			{
				$document = $this->createType($type, $options);
			}
			catch (Exception $e)
			{
				$document = $this->createType('html', $options);
			}

			$this->types[$signature] = $document;
		}

		return $this->types[$signature];
	}
209627
public function options($options)
    {
        foreach ($this->queries as $query) {
            $query->options($options);
        }

        return $this;
    }
1196875
public static function query($options = array())
	{
		$timestamp_start_name = static::temporal_property('start_column');
		$timestamp_end_name = static::temporal_property('end_column');
		$max_timestamp = static::temporal_property('max_timestamp');

		$query = Query_Temporal::forge(get_called_class(), static::connection(), $options)
			->set_temporal_properties($max_timestamp, $timestamp_end_name, $timestamp_start_name);

		//Check if we need to add filtering
		$class = get_called_class();
		$timestamp = \Arr::get(static::$_lazy_filtered_classes, $class, null);

		if( ! is_null($timestamp))
		{
			$query->where($timestamp_start_name, '<=', $timestamp)
				->where($timestamp_end_name, '>', $timestamp);
		}
		elseif(static::get_primary_key_status() and ! static::get_primary_key_id_only_status())
		{
			$query->where($timestamp_end_name, $max_timestamp);
		}

		return $query;
	}
259114
public function get($index, $type, $id, $options = [])
    {
        return $this->db->get([$index, $type, $id], $options);
    }
211189
public function send(string $type, array $options = []): bool
    {
        $type = $this->typeRegistry->get($type);
        $builder = MessageBuilder::fromType($type, $options);
        $message = ResolvedMessage::fromBuilder($builder);

        return $this->driver->send($message);
    }