2725 search results for Doctrine

178 lines | src/Entity/Question.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Collection;
// ... lines 8 - 14
class Question
{
// ... lines 17 - 147
/**
* @return Collection|Answer[]
*/
public function getAnswers(): Collection
{
return $this->answers;
}
public function addAnswer(Answer $answer): self
{
if (!$this->answers->contains($answer)) {
$this->answers[] = $answer;
$answer->setQuestion($this);
}
return $this;
}
public function removeAnswer(Answer $answer): self
{
if ($this->answers->removeElement($answer)) {
// set the owning side to null (unless already changed)
if ($answer->getQuestion() === $this) {
$answer->setQuestion(null);
}
}
return $this;
}
}
See Code Block in Script
54 lines | app/AppKernel.php
// ... lines 1 - 5
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// ... lines 18 - 20
new AppBundle\AppBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
// ... lines 33 - 52
}
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
58 lines | src/Entity/Comment.php
// ... lines 1 - 2
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommentRepository")
*/
class Comment
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $authorName;
/**
* @ORM\Column(type="text")
*/
private $content;
public function getId()
{
return $this->id;
}
public function getAuthorName(): ?string
{
return $this->authorName;
}
public function setAuthorName(string $authorName): self
{
$this->authorName = $authorName;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
}
See Code Block in Script
47 lines | src/AppBundle/Entity/Security.php
// ... lines 1 - 2
namespace AppBundle\Entity;
// ... line 4
use Doctrine\ORM\Mapping as ORM;
// ... line 6
/**
* @ORM\Entity
* @ORM\Table(name="securities")
*/
class Security
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Enclosure", inversedBy="securities")
*/
private $enclosure;
public function __construct(string $name, bool $isActive, Enclosure $enclosure)
{
$this->name = $name;
$this->isActive = $isActive;
$this->enclosure = $enclosure;
}
public function getIsActive(): bool
{
return $this->isActive;
}
}
See Code Block in Script
95 lines | src/AppBundle/Entity/Subscription.php
// ... lines 1 - 4
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="subscription")
*/
class Subscription
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="User", inversedBy="subscription")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $user;
/**
* @ORM\Column(type="string")
*/
private $stripeSubscriptionId;
/**
* @ORM\Column(type="string")
*/
private $stripePlanId;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $endsAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $billingPeriodEndsAt;
// ... lines 45 - 93
}
See Code Block in Script
101 lines | src/Entity/User.php
// ... lines 1 - 2
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
// ... lines 30 - 99
}
See Code Block in Script
... the user"-logic in the same place if you know what I mean. Yep, setting createdAt via the constructor is super easy...but it only works for createdAt... so has limited usefulness. > One way would be to use stof/doctrine ...
weaverryan
weaverryan
Read Full Comment
App Test Setup

... rules around who can publish an item under different conditions. Then we'll do everything custom: add completely custom fields, completely custom API resources that aren't backed by Doctrine, custom filters and we'll even ...

7:44
Timeline Go Behind-the-Scenes with your Code

... explanatory. Depending on how well you know Doctrine, this might be obvious... or not. This metric refers to whenever one or more entities are hydrated into an object. Notice the count is 3. For this metric, it's not that ...

7:15
Wall Time Exclusive Time Other Wonders

... :createEntity function... whatever that is. If you use Doctrine, you might know what this is - but let's pretend we have no idea. Before we dive further into the root cause behind this slow function, the other way to ...

7:47
Adding the ManyToOne Relation

Hmm. We want each Article to have many Comments... and we want each Comment to belong to one Article. Forget about Doctrine for a minute: let's think about how this should look in the database. Because each Comment ...

9:14
Hey Yamen Imad Nassif! Ah, cool! So, I have an idea :). Well, first, of course, you can use an if statement like this - https://knpuniversity.com/screencast/doctrine-queries/filters#adding-the-filter-logic - to check ...
weaverryan
weaverryan
Read Full Comment
i started using, it seems that on my config files specifically bootstrap.php file i have something like in the next paragraph, i trusted that doctrine was paying attention to the php entities annotations, it seems that ...
sebastian
sebastian
Read Full Comment
ok I dont know if this is a good practice but I am using globals here is how I am doing it so check it out. Might help you. // twig extension ``` namespace AppBundle\Twig; use Doctrine\ORM\EntityManager; class ...
... add an index to a column and then queries will be fast as they were before. So, this question does not related to Doctrine but to DB in general, Doctrine just gives a way to do it. I mean, when to add indexes you need to ...
... \n PHP Fatal error: Uncaught ReflectionException: Class Doctrine\\Common\\DataFixtures\\AbstractFixture not found in /var/www/project/src/AppBundle ...
JuanLuisGarciaBorrego
JuanLuisGarciaBorrego
Read Full Comment
Yo Mateusz Sobczak ! Yes, very good question! Eloquent and Doctrine use the 2 different major "types" of ORM. Eloquent is called an "Active Record"... which basically means that when you query, you actually use the ...
weaverryan
weaverryan
Read Full Comment
Hey Yehuda Am-Baruch! Hmm, yes, I agree with your assessment! I also think that Symfony/Doctrine is still not reading the annotations! Your configuration in config.yml should be ok, but let's change it back to how it ...
weaverryan
weaverryan
Read Full Comment
... basically I don't see a reason to create one if not, as I get the Instance from the Query). Anyway, This also doesn't work, I failed to mention, that I've build another project under symfony 3.0.1, doctrine/orm 2.5.6 where ...
Yehuda Am-Baruch
Yehuda Am-Baruch
Read Full Comment