SlideShare a Scribd company logo
1 of 18
Willkommen
Anti-Pattern #1
Reusage by copy & paste
Every time
you do this,
a baby seal
dies
Photo by Samuel Blanc via Wikimedia Commons
[CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)]
Scenario
Community web application
Users seek other users by
interests
How to input data?
I can haz tagz?
Illustration by Kimhunghan via Wikimedia Commons
[CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0)]
Backend
• fpn/tag-bundle
Frontend
• max-favilli/tagmanager
+ something in between
fpn/tag-bundle
Actually a Doctrine Extension in a Bundle
Pro
•Provides two new Entites: Tag & Tagging
•TagManager handles model access
Con
•Some code to copy into our Entities
•Lots of code to copy into our Controllers
max-favilli/tagmanager
jQuery plugin
working nicely with twitter bootstrap
Pro
• Basically just two form inputs
• Typeahead optional
Con
• Not a composer project
Missing Puzzle Pieces
Form Widget
Data Transformer
Form Type
Form Widget
Two input fields
• visible for UI
• hidden for „tagA, tagB, tagC“
Embed JavaScript & CSS
Initialize JS
Data Transformer
transform()
• convert Tags to „a, b, c“
reverseTransform()
• convert „tagA, tagB, tagC“ to Tags
• create Tags, if not existing
• needs TagManager
Form Type
Provide name for widget
Called in Application FormTypes
Gets TagManager injected
Defines DataTransformer
Save the baby seals
Entity Trait
TaggableSubstriber
make it reusable
Entity Trait
avoid copy & paste for each
functional Entity classes
reference TagManager
• after loading the Entity
• to inform TagManager during flush
TaggableSubscriber
postLoad()
• attach TagManager to Entity
postPersist()
• TagManager->saveTagging($entity)
onFlush()
• save dirty Tags in TagManager
Obsoletes code in Controllers
Make it reusable
Dedicated Bundle
Create composer project
But how to include
external JS & CSS?
Component
RobLoach/component-installer
Add package to composer.json
Configure components-dir
Run composer update
See web/bundles
Live Demo
// TODO
AppKernel: remove FPN bundle
config.yml: remove FPN configuration
Handling typeahead requests
Configure tagmanager via Symfony
Documentation :(
(re-)use it!
http://github.com/fogs/TaggingBundle

More Related Content

Similar to How I Built A Reusable Symfony2 TaggingBundle

Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1benDesigning
 
Introduction to Cloud Computing - COA101
Introduction to Cloud Computing - COA101Introduction to Cloud Computing - COA101
Introduction to Cloud Computing - COA101Martin Hamilton
 
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)Nathan Yergler
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerFITC
 
COP449 - Introduction to Cloud Computing
COP449 - Introduction to Cloud ComputingCOP449 - Introduction to Cloud Computing
COP449 - Introduction to Cloud ComputingMartin Hamilton
 
Start Up Austin 2017: If How and When to Adopt Microservices
Start Up Austin 2017: If How and When to Adopt MicroservicesStart Up Austin 2017: If How and When to Adopt Microservices
Start Up Austin 2017: If How and When to Adopt MicroservicesAmazon Web Services
 
The Affiliate 2 0 Litmus Test
The Affiliate 2 0 Litmus TestThe Affiliate 2 0 Litmus Test
The Affiliate 2 0 Litmus TestAffiliate Summit
 
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole Lang
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole LangOSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole Lang
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole LangNETWAYS
 
Liferay DevCon 2014: Lliferay Platform - A new and exciting vision
Liferay DevCon 2014: Lliferay Platform - A new and exciting visionLiferay DevCon 2014: Lliferay Platform - A new and exciting vision
Liferay DevCon 2014: Lliferay Platform - A new and exciting visionJorge Ferrer
 
Bitrix24 Presentation
Bitrix24 PresentationBitrix24 Presentation
Bitrix24 PresentationBitrix, Inc.
 
Box Platform Developer Workshop
Box Platform Developer WorkshopBox Platform Developer Workshop
Box Platform Developer WorkshopJonathan LeBlanc
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucketjeetendra mandal
 
Exploring the GitHub Service Universe
Exploring the GitHub Service UniverseExploring the GitHub Service Universe
Exploring the GitHub Service UniverseBjörn Kimminich
 

Similar to How I Built A Reusable Symfony2 TaggingBundle (20)

Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Introduction to Cloud Computing - COA101
Introduction to Cloud Computing - COA101Introduction to Cloud Computing - COA101
Introduction to Cloud Computing - COA101
 
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
Technology / Open Source @ Creative Commons (CC Salon SF, August 2009)
 
Reaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and PolymerReaching for the Future with Web Components and Polymer
Reaching for the Future with Web Components and Polymer
 
Online Computer Network Security Assignment Help
Online Computer Network Security Assignment HelpOnline Computer Network Security Assignment Help
Online Computer Network Security Assignment Help
 
COP449 - Introduction to Cloud Computing
COP449 - Introduction to Cloud ComputingCOP449 - Introduction to Cloud Computing
COP449 - Introduction to Cloud Computing
 
Start Up Austin 2017: If How and When to Adopt Microservices
Start Up Austin 2017: If How and When to Adopt MicroservicesStart Up Austin 2017: If How and When to Adopt Microservices
Start Up Austin 2017: If How and When to Adopt Microservices
 
Box Platform Overview
Box Platform OverviewBox Platform Overview
Box Platform Overview
 
The Affiliate 2 0 Litmus Test
The Affiliate 2 0 Litmus TestThe Affiliate 2 0 Litmus Test
The Affiliate 2 0 Litmus Test
 
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole Lang
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole LangOSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole Lang
OSDC 2018 | Git things done with GitLab by Gabriel Hartmann and Nicole Lang
 
Liferay DevCon 2014: Lliferay Platform - A new and exciting vision
Liferay DevCon 2014: Lliferay Platform - A new and exciting visionLiferay DevCon 2014: Lliferay Platform - A new and exciting vision
Liferay DevCon 2014: Lliferay Platform - A new and exciting vision
 
Python Django Training in Bangalore Classroom, Online
Python Django Training in Bangalore Classroom, OnlinePython Django Training in Bangalore Classroom, Online
Python Django Training in Bangalore Classroom, Online
 
Bitrix24fullpresentation
Bitrix24fullpresentationBitrix24fullpresentation
Bitrix24fullpresentation
 
Bitrix24 Presentation
Bitrix24 PresentationBitrix24 Presentation
Bitrix24 Presentation
 
jQuery Migration
jQuery MigrationjQuery Migration
jQuery Migration
 
Box Platform Developer Workshop
Box Platform Developer WorkshopBox Platform Developer Workshop
Box Platform Developer Workshop
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucket
 
Bootstrap with liferay
Bootstrap with liferayBootstrap with liferay
Bootstrap with liferay
 
Exploring the GitHub Service Universe
Exploring the GitHub Service UniverseExploring the GitHub Service Universe
Exploring the GitHub Service Universe
 

Recently uploaded

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

How I Built A Reusable Symfony2 TaggingBundle

Editor's Notes

  1. Willkommen Fragen, Anmerkungen, Meinungen Vorstellung seit 2001 Software & Betrieb Fauler Entwickler Wiederverwendung Hürden Technologie Lizenz Umsetzung
  2. Patterns Anti-Patterns Warum nicht? Robbenbaby
  3. Text-Input? Pre-filled list / checkboxes Tags Suche bei Google, KnpBundles „Tag“ + „Symfony2“ ist vergiftet (DependencyInjection) Wo noch suchen?
  4. Eindeutigkeit der Bezeichner
  5. FormTypes als Service Erlaubt Injection vom TagManager
  6. Code in Entity überflüssig machen Controller soll Entity nach Tags befragen Besser: Event werfen, wenn Entity dirty ist..
  7. JS/CSS files sind nicht teil meines Projekts Composer kümmert sich um Aktualisierung