本文整理汇总了PHP中EntityManager::getFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getFilters方法的具体用法?PHP EntityManager::getFilters怎么用?PHP EntityManager::getFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::getFilters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateFilterConditionSQL
/**
* Generates the filter SQL for a given entity and table alias.
*
* @param ClassMetadata $targetEntity Metadata of the target entity.
* @param string $targetTableAlias The table alias of the joined/selected table.
*
* @return string The SQL query part to add to a query.
*/
private function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
{
if (!$this->em->hasFilters()) {
return '';
}
switch ($targetEntity->inheritanceType) {
case ClassMetadata::INHERITANCE_TYPE_NONE:
break;
case ClassMetadata::INHERITANCE_TYPE_JOINED:
// The classes in the inheritance will be added to the query one by one,
// but only the root node is getting filtered
if ($targetEntity->name !== $targetEntity->rootEntityName) {
return '';
}
break;
case ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE:
// With STI the table will only be queried once, make sure that the filters
// are added to the root entity
$targetEntity = $this->em->getClassMetadata($targetEntity->rootEntityName);
break;
default:
//@todo: throw exception?
return '';
break;
}
$filterClauses = array();
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias))) {
$filterClauses[] = '(' . $filterExpr . ')';
}
}
return implode(' AND ', $filterClauses);
}
示例2: makeBlockShared
/**
* Makes a block shared and creates a pointer block in it's place
*
* This method performs the change and persists/flushes to the database.
*
* @param integer $id
* @param integer $rootVersion
*
* @return BlockPointer
*/
public function makeBlockShared($id)
{
if ($this->em->getFilters()->isEnabled('draftversion')) {
$this->em->getFilters()->disable('draftversion');
}
$block = $this->find($id);
$version = $this->getNewVersion($block);
// Duplicate some of the settings to the pointer
$pointer = new PointerBlock();
$pointer->setOwner($block->getOwner());
$pointer->setParent($block->getParent());
$pointer->setReference($block);
$pointer->setRootVersion($version);
// Detach and make shared
$block->setShared(true);
$block->setParent(null);
$block->setOwner(null);
$block->setPosition(0);
$block->setSort(0);
$block->setRootVersion($version);
$this->killLoggableListener();
$this->save($block)->save($pointer);
return $pointer;
}