function generate(IdentifiableOrmEntity $entity) { $value = $this->generator->generate($entity); if (!is_null($value)) { $value = $this->type->assemble(array($value), new FetchStrategy(FetchStrategy::CASCADE)); } return $value; }
function assebmleSet(array $tuples, FetchStrategy $fetchStrategy) { $objects = array(); $dao = $this->container->getDao(); foreach ($tuples as $tuple) { try { $id = $this->fkType->assemble($tuple, $fetchStrategy); } catch (OrmModelIntegrityException $e) { if (!$this->isNullable()) { throw new OrmModelIntegrityException('cannot be null'); } $id = null; } $objects[] = $id ? $dao->getLazyEntityById($id) : null; } if (empty($objects)) { return array(); } if ($fetchStrategy->is(FetchStrategy::CASCADE)) { // fetch them all $idsToFetch = array(); foreach ($objects as $object) { if ($object && !$object->isFetched()) { $idsToFetch[] = $object->_getId(); } } $dao->getByIds($idsToFetch); } return $objects; }