Upgrading to 2.2
... composer.json
file, being sure to only replace the core Symfony libraries, and not any
custom lines you may have added. In this case, the doctrine-fixtures-bundle
is custom, so I’ll leave it alone:
"require": {
},
Also, be sure ...
Inserting Data via Fixtures
... this
data fixtures.
In our case, it would be great to pre-fill our table with some Starships!
Doctrine even has a package adding this fake fixtures data! At your terminal, run ...
Migrations
We created an entity class! But... that's it. The corresponding table does
not yet exist in our database.
Let's think. In theory, Doctrine knows about our entity, all of its properties
and their ORM\Column attributes ...
Attachments with Async Messenger Emails
...
php bin/console app:author-weekly-report:send
Ah! Explosion! Incorrect string value? Wow. Okay. What we're seeing is a real-world
limitation of the doctrine transport: it can't handle binary data. This may change
in ...
Saving Relations
... favorite, always-excited
astronaut commenter: Mike Ferengi:
Then, $comment1->setContent(), and use one of our hardcoded comments:
Perfect! Because we're creating this manually, we need to persist it to Doctrine.
At the ...
Criteria System Champion Collection Filtering
... better way?! Introducing, Doctrine's Criteria system: a part of Doctrine
that's so useful... and yet... I don't think anyone knows it exists!
Here's how it looks: create a $criteria variable set to Criteria::create ...
Controlling Data Fixtures in a Test
... parent
test class:
// src/Yoda/UserBundle/Tests/Controller/RegisterControllerTest.php
// ...
public function testRegister()
{
}
Now, grab the Doctrine entity manager by getting the doctrine service
and calling getManager ...
Filters
... CategoryRepository and add some andWhere()
calls in here for fc.discontinued = true.
But what if we wanted this WHERE clause to be added automatically, and everywhere
across the site? That's possible, and it's called a Doctrine ...
Filters Automatically Modify Queries
Thanks to our cool new method, we can filter out discontinued fortune
cookies. But what if we want to apply some criteria like this globally to
every query to a table? Like, telling Doctrine that whenever we query for ...
Custom Filter apply
... data provider, not
via some magic system that runs after them.
Let's look at how this is done in the core Doctrine data provider. Hit Shift+Shift,
search for doctrinedataprovider and include non project items. There it is ...
The Failure Transport
... can have as
many transports as you want. This one starts with doctrine://default. If
you look at our .env file... hey! That's exactly what our
MESSENGER_TRANSPORT_DSN environment variable is set to! Yep, both our async
and ...
Collection Magic with Criteria
... object even has a filter()
method to make this easier!
But... there's a problem. If we did this, Doctrine would query for all of the
comments, even though we don't need all of the comments. If your collection is
pretty small ...
Custom Queries
How do you write custom queries in Doctrine? Well, you're already familiar with
writing SQL, and, yea, it is possible to write raw SQL queries with Doctrine.
But, most of the time, you won't do this. Instead, because ...
OneToMany The Inverse Side of a Relationship
OneToMany: The Inverse Side of a Relationship¶
Earlier, we gave every Event an owner. This was our first Doctrine relationship:
a ManyToOne from Event to User.
This lets us do things like call $event->getOwner ...
Query Extension Auto-Filter a Collection
... this filter to be automatic. An API client should
never see unpublished listings. Filters are a good choice for optional stuff,
but not this.
Another option is called a Doctrine filter. It's got a similar name, but is
a ...
The King of Relations ManyToOne
... ManyToOne association.
The second type is called a ManyToMany association. To use a different example,
this would be if each product had many tags, but also each tag related to many
products.
And when it comes to Doctrine ...
Fixtures For some dumb data
... and paste the example from the docs.
Change the namespace above the class to match our project. Notice that the namespace
always follows the directory structure of the file:
Now we just use normal Doctrine code to create ...
An Aside Dependency Injection Parameters
An Aside: Dependency Injection Parameters¶
Cleanse the palette of all the forms stuff and open config.yml. Under
the doctrine key, we see a bunch of percent sign values:
# app/config/config.yml
# ...
doctrine ...
Sharing Data between Fixture Classes
... method called getOrder. Let’s return 10:
// src/Yoda/UserBundle/DataFixtures/ORM/LoadUsers.php
// ...
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
class LoadUsers implements FixtureInterface ...
Symfony 3 Level up with Services and the Container
Our app is coming to life! Thanks to the Doctrine Course
we have a rich data model. And after the course on Configuration,
well, using and configuring services is simple.
Now it's time to level-up with those services ...
2725
Doctrine
Filter Results