primary
or
primary-proxy
modifier.
/**
* @property int $id {primary}
* @property int $followers {1:m BookFollowers::$book}
* ...
*/
class Book extends Nextras\Orm\Entity\Entity {}
/**
* @property int $id {primary-proxy}
* @property Book $book {m:1 Book::$followers} {primary}
* @property User $user {m:1 User::$followedBooks} {primary}
* ...
*/
class BookFollowers extends Nextras\Orm\Entity\Entity {}
// old
{1:1d UserEntity::$meta primary}
// new
{1:1 UserEntity::$meta, isMain=true}
=
; values can be an array.
// old
{modifier value another key:value}
{enum self::ONE_CONSTANT self::ANOTHER}
// new
{modifier value, another, key=value, arrayValue=[val1, val2]}
{enum self::ONE_CONSTANT, self::ANOTHER}
// old
{1:m UsersRepository}
{1:m UsersRepository $posts}
// new
{1:m UserEntity::$posts}
{1:m UserEntity::$posts}
order
→ orderBy
primary
→ isMain
// old
{1:m UserEntity::$posts order:id}
{1:m UserEntity::$posts order:id,DESC}
// new
{1:m UserEntity::$posts, orderBy=id}
{1:m UserEntity::$posts, orderBy=[id, DESC]}
// old
{m:m UserEntity::$posts primary}
// new
{m:m UserEntity::$posts, isMain=true}
// old
{primary foo bar}
// old - resulted into string "123"
{default 123}
// new
{default "123"}
// or for int
{default 123}
getEntityClassNames()
that returns accepted entity class names.
class BooksRepository extends Nextras\Orm\Repository\Repository
{
public static function getEntityClassNames()
{
return [Book::class];
}
}
@method
annotations that are not
proxies for its mapper; you have to rewrite these methods manually.
// old
/**
* @method Book|null getByTitle($title)
*/
class BooksRepository extends Nextras\Orm\Repository\Repository
{
// ...
}
// new
class BooksRepository extends Nextras\Orm\Repository\Repository
{
// ...
/**
* @param string $title
* @return Book|null
*/
public function getByTitle($title)
{
return $this->getBy(['title' => $title]);
}
}
IRepository::remove()
method was renamed to
$withCascade
. The cascade is definied as a parameter in
relationship modifier, the removal cascade is not added by default, only the
perists one. See Relationships chapter.
// old
$authorRepository->remove($author, true);
// new
/**
* @property OneHasMany|Book[] $books {1:m Book::$author, cascade=[persist, remove]}
*/
class Author extends Nextras\Orm\Entity\Entity {}
$authorRepository->remove($author, true);
createRelationshipMapper()
and
getRelationshipMapper()
methods.