Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

SymfonyCasts

API Platform 2 Part 3: Custom Resources

via SymfonyCasts

Overview

Welcome to part 3 of the Api Platform series! In part 1, we built a fully-featured API. Then in part 2 we leveled-up by adding a robust security system, security checks and user-specific fields.

So what's left? In part 3, we're taking customizations to the next level:

  • A RESTful implementation of a "publish" action
  • Complex ACL rules around who can publish under different conditions
  • Doing custom actions before save with a data persister
  • Truly custom fields via a data provider
  • Completely-custom, non-entity API resources
  • Adding pagination to custom resources
  • Custom filters (for entity and non-entity resources)
  • The input/output DTO system
  • Using UUID's

Phew! Yep, in this tutorial, we're going deep into customizations. Ready? Let's go!

Syllabus

  • App & Test Setup
  • Data Persister Decoration
  • Decorating Data Persisters vs Context Builders
  • Custom Logic Only for some Operations
  • Publishing a Listing
  • Detecting the "Published" State Change
  • Validating Who/When Can Publish
  • Publish State Change Validator Logic
  • Completely Custom Field via a Data Provider
  • Leveraging the Doctrine Data Provider
  • Adding & Populating the Custom Field
  • Custom Item Data Provider
  • Setting a Custom Field Via a Listener
  • Core Listeners & Accessing the "Resource" Objects
  • Doctrine postLoad Listener
  • Completely Custom Resource
  • Custom Resource Data Provider
  • Property Metadata
  • Why/When a Many Relation is IRI Strings vs Embedded
  • Collection "Types" and readableLink
  • Custom Resource GET Item
  • Custom Paginator
  • Pagination Context
  • Custom Resource PUT Operation
  • Custom Filter, getDescription() & properties
  • Custom Filter Logic for Entities
  • Custom Filter for Custom Resources
  • Custom Filter apply()
  • Filter Class Arguments
  • Filter Autowiring
  • Output DTO Class
  • DTO Data Transformer
  • Output Properties & Metadata
  • DTO Quirks
  • DTO Quirks: Embedded Objects
  • Input DTO Class
  • Input DTO: Denormalizing IRI Strings
  • Input Data Transformer
  • Input DTO Update Problems
  • DTO Input "Initializer"
  • DTO Input Initializer Logic
  • DTO Class Organization
  • Type Validation
  • Input DTO Validation
  • UUID's
  • UUID as a API Identifier
  • Setting the UUID on POST
  • UUID Quirk with "id" Name

Taught by

Ryan Weaver

Reviews

Start your review of API Platform 2 Part 3: Custom Resources

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.