本文整理汇总了PHP中EntityRepository::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::getMetadata方法的具体用法?PHP EntityRepository::getMetadata怎么用?PHP EntityRepository::getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::getMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveTable
private function resolveTable($arg)
{
if ($arg == '#') {
$path = array('base');
} else {
$path = explode('.', trim($arg, '.#'));
array_unshift($path, "base");
}
foreach ($path as $index => $item) {
if ($item == 'base') {
$metadata = $this->repository->getMetadata();
$table = $metadata->getTable();
$tableAs = 'base';
if (!$this->getTableAs($tableAs)) {
$this->setTableAs($tableAs, $table, $metadata);
}
} else {
// tabulka
$association = $metadata->getAssociation($item);
$associationClassName = $association->getReferenceClass();
$associationMetadata = $this->repository->getEntityManager()->getRepository($associationClassName)->getMetadata();
$parentTable = $table;
$parentTableAs = $tableAs;
$table = $associationMetadata->getTable();
$tableAs = $tableAs . self::ALIAS_SEPARATOR . $item;
// Nevytvaret novy stejny join. Jen, pokud je jina vazba, nebo jiny nazev.
if (!$this->getTableAs($tableAs)) {
$this->setTableAs($tableAs, $table, $metadata, $parentTableAs, $association);
}
}
}
return $tableAs;
}
示例2: pk
/**
*
* @param type $pk
* @return item|null
*/
public function pk($pk)
{
$pkName = $this->repository->getMetadata()->getPrimaryColumn();
foreach ($this as $item) {
if ($item->{$pkName} == $pk) {
return $item;
}
}
return NULL;
}