本文整理汇总了PHP中Cake\ORM\Query::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::getOptions方法的具体用法?PHP Query::getOptions怎么用?PHP Query::getOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Query
的用法示例。
在下文中一共展示了Query::getOptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeFind
/**
* beforeFind
* @param Event $event
* @param Query $query
* @param ArrayObject $options
* @param $primary
*/
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
{
$getOptions = $query->getOptions();
if (!array_key_exists('enableSoftDelete', $getOptions) || $getOptions['enableSoftDelete'] == true) {
$modelName = $this->_table->alias();
$booleanField = $this->config('boolean');
$timestampField = $this->config('timestamp');
if ($booleanField !== false && $this->_table->hasField($booleanField)) {
$query->where([$modelName . '.' . $booleanField => false]);
}
if ($booleanField === false && $timestampField !== false && $this->_table->hasField($timestampField)) {
$query->where([$modelName . '.' . $timestampField . ' IS' => null]);
}
}
}
示例2: testGetOptions
/**
* Tests getOptions() method
*
* @return void
*/
public function testGetOptions()
{
$options = ['doABarrelRoll' => true, 'fields' => ['id', 'name']];
$query = new Query($this->connection, $this->table);
$query->applyOptions($options);
$expected = ['doABarrelRoll' => true];
$this->assertEquals($expected, $query->getOptions());
$expected = ['doABarrelRoll' => false, 'doAwesome' => true];
$query->applyOptions($expected);
$this->assertEquals($expected, $query->getOptions());
}
示例3: callFinder
/**
* Calls a finder method directly and applies it to the passed query,
* if no query is passed a new one will be created and returned
*
* @param string $type name of the finder to be called
* @param \Cake\ORM\Query $query The query object to apply the finder options to
* @param array $options List of options to pass to the finder
* @return \Cake\ORM\Query
* @throws \BadMethodCallException
*/
public function callFinder($type, Query $query, array $options = [])
{
$query->applyOptions($options);
$options = $query->getOptions();
$finder = 'find' . $type;
if (method_exists($this, $finder)) {
return $this->{$finder}($query, $options);
}
if ($this->_behaviors && $this->_behaviors->hasFinder($type)) {
return $this->_behaviors->callFinder($type, [$query, $options]);
}
throw new \BadMethodCallException(sprintf('Unknown finder method "%s"', $type));
}
示例4: _dispatchBeforeFind
/**
* Triggers beforeFind on the target table for the query this association is
* attaching to
*
* @param \Cake\ORM\Query $query the query this association is attaching itself to
* @return void
*/
protected function _dispatchBeforeFind($query)
{
$table = $this->target();
$options = $query->getOptions();
$table->dispatchEvent('Model.beforeFind', [$query, new \ArrayObject($options), false]);
}
示例5: _dispatchBeforeFind
/**
* Triggers beforeFind on the target table for the query this association is
* attaching to
*
* @param \Cake\ORM\Query $query the query this association is attaching itself to
* @return void
*/
protected function _dispatchBeforeFind($query)
{
$table = $this->target();
$options = $query->getOptions();
$event = new Event('Model.beforeFind', $table, [$query, $options, false]);
$table->getEventManager()->dispatch($event);
}