1000 search results

Hooking up the Scientist Removal JavaScript

…Mixed in with AJAX call for notes is our DELETE call. Click the little sha, then go to the Doctrine tab. Ooh, look at this: DELETE FROM genus_scientist WHERE genus_id = 11 AND user_id = 11 Gosh darn it that's nice…

2:50
EntityType Checkboxes with ManyToMany

…to change the genusScientists property, that's what we should call the field. The type will be EntityType: This is your go-to field type whenever you're working on a field that is mapped as any of the Doctrine relations. We used it earlier…

5:39
Saving the Inverse Side of a ManyToMany

… What's going on!? This is the moment where someone who doesn't know what we're about to learn, starts to hate Doctrine relations. Earlier, we talked about how every relationship has two sides. You can start with a Genus and talk about the…

4:03
Tracking Cancelations in our Database

…month: Cool! To deactivate the subscription in the controller, it's as easy as saying $subscription->deactivateSubscription() and then saving it to the database with the standard persist() and flush() Doctrine code: And that should do it! Let's give this guy a try. Go…

7:57
Webhook: Subscription Canceled

…be canceled. Below, really simple, say $subscription->cancel(). Then, use the Doctrine entity manager to save this to the database: Mind blown! Back in the controller, call this! Above the switch statement, add a $subscriptionHelper variable set to $this->get('subscription_helper'): Finally, call $subscriptionHelper…

5:08
Testing Part 2: Faking the Event Lookup

…that true is false on line 43 It looks like our webhook is not working, because the subscription is still active. But actually, that's not true: Doctrine is tricking us! In reality, the database has been updated to show that the Subscription is canceled…

5:06
Adding a Cache Service

…it entirely on our own. First, we need to configure the bundle. To see what keys it has, find the terminal and run: The list has a new entry: doctrine_cache. Re-run the command with this: Nice! There's our huge configuration example! Ok…

3:27
JoinColumn & Relations in Fixtures

…Alice will now look at the 10 Genus objects matching this pattern and select a random one each time. Reload the fixtures: It's alive! Check out the results again with doctrine:query:sql: Every single one has a random genus. Do you love it…

3:15
Inserting new Objects

…on a slow query. I still can't believe it's working - things never work on the first try! To triple-check it, head to the terminal. To run a raw SQL query, use: There they are. So inserting objects with Doctrine... pretty darn easy.

5:07
Process that Form!

…to use that associative array to create a new Genus object, populate it with the data, and save it via Doctrine. But, it would be awesomesauce if the form framework could do our job for us. I mean, use the data to automatically create the…

2:46
Binding Forms to Objects: data_class

…Look at this! A free drop-down with almost no work. It also noticed that isPublished should be a checkbox because that's a boolean field in Doctrine: And since firstDiscoveredAt is a date, it rendered it with year-month-day drop-down boxes. Now…

4:44
Custom Query in EntityType

…So, if you pass a query_builder option and set it to an anonymous function, Doctrine will pass that the entity repository for this specific entity. All we need to do is create whatever query builder we want and return it. In the form, add…

3:30
The All-Important User Class

…somewhere else - like a central authentication server. In those cases, you will still have a User class, you just won't store it with Doctrine. More on that as we go along. Ok, we've got the empty user class: let's fill it in!

4:22
The UserInterface Methods (Keep some Blank!)

…feel ok leaving these blank. So in our application, we want to store users in the database. So let's set this class up with Doctrine. Copy the use statement from SubFamily and paste it here: Next, I'll put my cursor inside the class…

4:19
Users Need Passwords (plainPassword)

…plain-text password on the User and encode it automatically via a Doctrine listener when it saves. To do that, add a new property on User called plainPassword. But wait! Don't persist this with Doctrine: we will of course never store plain-text passwords:…

3:32
Weird Endpoint: The tagline as a Resource?

…the route should be /api/programmers/{nickname}/tagline. To be super hip, add an @Method annotation: we know this should only match PUT requests: Like before, type-hint the Programmer argument so that Doctrine will query for it for us, using the nickname value. And…

5:47
Filtering / Searching

…things by returning $qb at the bottom: If you were using something like Elastic Search, then you wouldn't be making this query through Doctrine: you'd be doing it through elastic search itself. But the idea is the same: prepare some search for Elastic…

4:14
Adding Links via Annotations

…a few minutes! To create this cool system, we need to understand a bit about annotations. Every annotation - like Table or Entity from Doctrine - has a class behind it. That means we need a Link class. Create a new directory called Annotation. Inside add a…

6:22
Tests with the Container

…means we have an easy way to clear data. Create a new private function called purgeDatabase(). Because we have the Doctrine DataFixtures library installed, we can use a great class called ORMPurger. Pass it the EntityManager - so $this->getService('doctrine')->getManager(). To clear things out…

4:23
Test Fixtures and the PropertyAccess Component

…what a wonderfully trained function: Let's save this! Since we'll need the EntityManager a lot in this class, let's add a protected function getEntityManager(). Use getService() with doctrine.orm.entity_manager. And since I love autocomplete, give this PHPDoc: Now $this->getEntityManager()…

6:24