本文整理匯總了PHP中Doctrine\ORM\Mapping\MappingException::oneToManyRequiresMappedBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP MappingException::oneToManyRequiresMappedBy方法的具體用法?PHP MappingException::oneToManyRequiresMappedBy怎麽用?PHP MappingException::oneToManyRequiresMappedBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Mapping\MappingException
的用法示例。
在下文中一共展示了MappingException::oneToManyRequiresMappedBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _validateAndCompleteOneToManyMapping
/**
* Validates and completes the mapping.
*
* @param array $mapping The mapping to validate and complete.
* @throws MappingException
* @throws InvalidArgumentException
* @return array The validated and completed mapping.@override
*/
protected function _validateAndCompleteOneToManyMapping(array $mapping)
{
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
// OneToMany-side MUST be inverse (must have mappedBy)
if (!isset($mapping['mappedBy'])) {
throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']);
}
$mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
$mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];
if (isset($mapping['orderBy'])) {
if (!is_array($mapping['orderBy'])) {
throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy']));
}
}
return $mapping;
}
示例2: _validateAndCompleteOneToManyMapping
/**
* Validates & completes a one-to-many association mapping.
*
* @param array $mapping The mapping to validate and complete.
*
* @return array The validated and completed mapping.
*
* @throws MappingException
* @throws InvalidArgumentException
*/
protected function _validateAndCompleteOneToManyMapping(array $mapping)
{
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
// OneToMany-side MUST be inverse (must have mappedBy)
if (!isset($mapping['mappedBy'])) {
throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']);
}
$mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval'];
$mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove'];
$this->assertMappingOrderBy($mapping);
return $mapping;
}