1000 search results

30 lines | .env
// ... lines 1 - 22
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7
###< doctrine/doctrine-bundle ###
See Code Block in Script
87 lines | src/Repository/UserRepository.php
// ... lines 1 - 6
use Doctrine\Persistence\ManagerRegistry;
// ... lines 8 - 14
class UserRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
// ... line 19
}
// ... lines 21 - 85
}
See Code Block in Script
51 lines | src/Repository/TagRepository.php
// ... lines 1 - 6
use Doctrine\Persistence\ManagerRegistry;
// ... lines 8 - 14
class TagRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
// ... line 19
}
// ... lines 21 - 49
}
See Code Block in Script
82 lines | src/Repository/CommentRepository.php
// ... lines 1 - 8
use Doctrine\Persistence\ManagerRegistry;
// ... lines 10 - 17
class CommentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
// ... line 22
}
// ... lines 24 - 80
}
See Code Block in Script
75 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 8
use Doctrine\Persistence\ManagerRegistry;
// ... lines 10 - 16
class ArticleRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
// ... line 21
}
// ... lines 23 - 73
}
See Code Block in Script
51 lines | src/Repository/ApiTokenRepository.php
// ... lines 1 - 6
use Doctrine\Persistence\ManagerRegistry;
// ... lines 8 - 14
class ApiTokenRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
// ... line 19
}
// ... lines 21 - 49
}
See Code Block in Script
62 lines | .env
// ... lines 1 - 22
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=mysql://root:@127.0.0.1:3306/the_spacebar
###< doctrine/doctrine-bundle ###
// ... lines 30 - 62
See Code Block in Script
105 lines | composer.json
{
// ... lines 2 - 3
"require": {
// ... lines 5 - 8
"doctrine/doctrine-bundle": "^1.6.10|^2.0",
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0",
"doctrine/orm": "^2.5.11",
// ... lines 12 - 44
},
// ... lines 46 - 103
}
See Code Block in Script
105 lines | composer.json
{
// ... lines 2 - 3
"require": {
// ... lines 5 - 8
"doctrine/doctrine-bundle": "^2.0",
// ... lines 10 - 44
},
// ... lines 46 - 103
}
See Code Block in Script
35 lines | src/DataPersister/UserDataPersister.php
// ... lines 1 - 6
use Doctrine\ORM\EntityManagerInterface;
// ... line 8
class UserDataPersister implements DataPersisterInterface
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
// ... lines 17 - 33
}
See Code Block in Script
67 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Criteria;
// ... lines 8 - 16
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 19 - 35
public static function createNonDeletedCriteria(): Criteria
{
// ... lines 38 - 41
}
// ... lines 43 - 65
}
See Code Block in Script
67 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Criteria;
// ... lines 8 - 16
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 19 - 35
public static function createNonDeletedCriteria(): Criteria
{
return Criteria::create()
->andWhere(Criteria::expr()->eq('isDeleted', false))
->orderBy(['createdAt' => 'DESC'])
;
}
// ... lines 43 - 65
}
See Code Block in Script
Which doctrine annotation should I use if I really wanted to assign a $genusScientist to another $genus instead of completely removing it from the database? Thanks.
Using Doctrine's automatic database creation/update via annotations seems like an amazing feature Are migrations used a lot in the Symfony world? Because at this point you might aswell use Laravel :p
Does Doctrine do any caching of ArrayCollections by default? I'm having some issues after doing my clone process above. After doing the clone above, I return the "id" of the $NewGenus. When I later call the Entity Manager to retrieve that new Genus by…
Terry Caliendo
Terry Caliendo
Read Full Comment
80 lines | src/DataFixtures/ArticleFixtures.php
// ... lines 1 - 7
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
// ... lines 9 - 10
class ArticleFixtures extends BaseFixture implements DependentFixtureInterface
{
// ... lines 13 - 78
}
See Code Block in Script
80 lines | src/DataFixtures/ArticleFixtures.php
// ... lines 1 - 7
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
// ... lines 9 - 10
class ArticleFixtures extends BaseFixture implements DependentFixtureInterface
{
// ... lines 13 - 72
public function getDependencies()
{
return [
TagFixture::class,
];
}
}
See Code Block in Script
// ... lines 1 - 4
use Doctrine\Common\Cache\Cache;
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
class MarkdownTransformer
{
// ... lines 10 - 12
public function __construct(MarkdownParserInterface $markdownParser, Cache $cache)
{
// ... lines 15 - 16
}
// ... lines 18 - 33
}
See Code Block in Script
52 lines | src/Repository/GenusRepository.php
// ... lines 1 - 5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
// ... lines 7 - 10
class GenusRepository extends ServiceEntityRepository
{
// ... lines 13 - 50
}
See Code Block in Script
202 lines | src/Entity/Article.php
// ... lines 1 - 5
use Doctrine\Common\Collections\Collection;
// ... lines 7 - 13
class Article
{
// ... lines 16 - 170
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setArticle($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
if ($comment->getArticle() === $this) {
$comment->setArticle(null);
}
}
return $this;
}
}
See Code Block in Script