SlideShare a Scribd company logo
1 of 32
Download to read offline
Doctrine2 Behaviour Extensions
zaostřeno na stromy
Nikol Ježková
Doctrine2 Behaviour Extensions
● Tree
● Translatable
● Sluggable
● Uploadable
● Loggable
● Sortable
● Timestampable
● IpTraceable
● Blameable
● SoftDeletable
● References
● ReferenceIntegrity
gedmo/doctrine-extensions
● $ composer require gedmo/doctrine-extensions
●
ORM, ODM
Doctrine 2.2.x – 2.5.x
PHP ≥ 5.4
Kompatibilita
https://github.com/Atlantic18/DoctrineExtensions
Listeners
Translation
Tree
Sluggable
Timestampable
...
onFlush
EntityManager
Entita
Annotace
XML
YAML
EventManager
Doctrine Event System
mapování
Hierarchická data
Nested-Set chování
@GedmoTree
GedmoTreeTreeListener
type [Nested-set, Closure-table, Materialized-path]
level1
2
3
parent
parent
child child
child child
parent
child
Nested-Set behaviour
@GedmoTreeLevel 1 12
5 63 4 9 10
2 7 8 11
@GedmoTree(type="nested")
1
2
3
@GedmoTreeLeft @GedmoTreeRight
@GedmoTreeParent
1
2 3
use GedmoMappingAnnotation as Gedmo;
trait NestedSetEntity
getRootNodes
getPath
getChildren
getLeafs
getNextSiblings
getPrevSiblings
getNodesHierarchy
moveUp
moveDown
NestedTreeRepository
persistAsFirstChild
persistAsFirstChildOf
persistAsLastChild
persistAsLastChildOf
persistAsNextSibling
persistAsNextSiblingOf
persistAsPrevSibling
persistAsPrevSiblingOf
removeFromTree
@GedmoTreeLevel
@GedmoTreeParent
@GedmoTreePath
@GedmoTreePathSource
@GedmoTree(type="materializedPath")
MaterializedPathRepository, trait MaterializedPath
id title parent_id path lvl
1 PC null pc-1 1
2 Notebook 1 pc-1,Notebook-2 2
3 MacBook 2 pc-1,Notebook-2, MacBook-3 3
4 MacBook Air 3 pc-1,Notebook-2, MacBook-3, MacBook Air-4 4
MaterializedPathRepository
getRootNodes [Query / QueryBuilder]
getPath [Query / QueryBuilder]
getNodesHierarchy [Query / QueryBuilder]
getTree [Query / QueryBuilder]
getChildren [Query / QueryBuilder]
childrenHierarchy
@GedmoTreeLevel
@GedmoTreeParent
addClosure
@GedmoTree(type="closure")
@GedmoTreeClosure(class="ClosureEntity")
ClosureTreeRepository
ancestor descendant depth
ClosureEntity extends AbstractClosureEntity
ClosureTreeRepository
getRootNodes [Query / QueryBuilder]
getPath [Query / QueryBuilder]
getNodesHierarchy [Query / QueryBuilder]
getTree [Query / QueryBuilder]
getChildren [Query / QueryBuilder]
childrenHierarchy
removeFromTree
@GedmoUploadable
UploadableListener, interface Uploadable
@GedmoUploadableFilePath
@GedmoUploadableFileName
@GedmoUploadableFileMimeType
@GedmoUploadableFileSize
@GedmoUploadable
path filenameGenerator allowOverwrite appendNumber callback
$fileinfo = $_FILES['foo'];
x
$fileinfo instanceOf UploadableFileInfoFileInfoArray;
// UploadableListener
$listener->addEntityFileInfo($file, $fileinfo);
Translatable
TranslatableListener
@GedmoTranslatable
@GedmoLocale
TranslationRepository
Entita Listener
@GedmoLocale
@GedmoTranslatable
setLocale
$defaultLocale
$locale
class Article implements GedmoTranslatableTranslatable
{ ...
$article = new EntityArticle;
$article->setTitle('Konference');
$article->setContent(Začátek');
// TranslationRepository
$repo->translate($article, 'title', 'de_de', 'Konferenz')
->translate($article, 'content', 'de_de', 'Beginn');
$em->persist($article);
$em->flush();
$article->setLocale('de_de');
$em->refresh($article);
$article->setLocale('cs_cz');
$em->refresh($article);
$article = $repo->findObjectByTranslatedField('title',
'Konferenz', 'EntityArticle');
GedmoTranslatableEntityRepositoryTranslationRepository
@GedmoSlug(
fields={"title", "content"}
separator="="
prefix="begin-"
suffix="-end"
style="lower"
updatable
unique
handlers
)
Sluggable
SluggableListener
begin-konference=phplive=brno=zilina-end
$entity->title = 'Konference PHPLive';
$entity->content = 'Brno Žilina'
@GedmoSlugHandler
● class: RelativeSlugHandler
● options
– relationField
– relationSlugField
● class: TreeSlugHandler
● options
– parentRelationField
– relationSlugField
@GedmoSlug(
handlers={
@GedmoSlugHandler(
class="RelativeSlugHandler",
options={
@GedmoSlugHandlerOption(
name="relationField",
value="entity"
),
@GedmoSlugHandlerOption(
name="relationSlugField",
value="slug"
),
@GedmoSlugHandlerOption(
name="separator",
Value="/"
)
}
)
},
fields={"title"}
)
@GedmoSortablePosition
@GedmoSortableGroup
setPosition(-1)
SortableRepository
getBySortableGroups(['title' => 'PHP live'])
id: 2 – 4 – 5 – 3 – 1
Sortable
SortableRepository
id SortableGroup
$title
SortablePosition
$position
1 PHP live 5
2 PHP live 1
3 PHP live 4
4 PHP live 2
5 PHP live 3
@GedmoTimestampable
● trait TimestampableEntity
@GedmoIpTraceable
● trait IpTraceableEntity
on creatte/update/change
field
value
Timestampable, IpTraceable
TimestampableListener, IpTraceableListener
@GedmoMappingAnnotationBlameable(
on creatte/update/change
field
value
)
Blameable
BlameableListener, trait BlameableEntity
@GedmoVersioned
LogEntryRepository
->revert($entity, 1)
@GedmoLoggable
LoggableListener
id
action
logged_at
object_id
object_class
version
data
trait SoftDeleteableEntity
SoftDeleteable(fieldName="deletedAt")
SoftDeleteableFilter
SoftDeleteableFilter
enable null
disable
find
disableForEntity
enableForEntity
enable
null in DBdisable
delete
disableForEntity
enableForEntity
mark in DB
References, ReferenceIntegrity
entity
entity
ReferencesListener
ReferenceIntegrityListener
● StofDoctrineExtensionsBundle
● gedmo/doctrine-extensions
Uploadable
StofDoctrineExtensionsBundleUploadableUploadableManager
SymfonyComponentHttpFoundationFileUploadedFile
$manager->markEntityToUpload($file, $uploadedFile);
● Kdyby/Doctrine
● rixxi/gedmo
laravel-doctrine/extensions
● Propel
nested_set, sluggable, timestampable, sortable,
versionable
● Eloquent ORM [laravel]
Soft Deleting, Timestamps
● RedBeanPHP
tree
Behaviours v jiných ORM
Děkuji za pozornost :-)

More Related Content

Viewers also liked

Viewers also liked (12)

No tot s guanyar!
No tot s guanyar!No tot s guanyar!
No tot s guanyar!
 
Test
TestTest
Test
 
Guerra
GuerraGuerra
Guerra
 
ตัวแปรชุดและตัวกลุ่มอักขระ
ตัวแปรชุดและตัวกลุ่มอักขระตัวแปรชุดและตัวกลุ่มอักขระ
ตัวแปรชุดและตัวกลุ่มอักขระ
 
Libro de las diferencias
Libro de las diferenciasLibro de las diferencias
Libro de las diferencias
 
Aulas sector primario
Aulas sector primario Aulas sector primario
Aulas sector primario
 
Kazi B. Alam_v6
Kazi B. Alam_v6Kazi B. Alam_v6
Kazi B. Alam_v6
 
Organizador grafico
Organizador graficoOrganizador grafico
Organizador grafico
 
My resume
My resumeMy resume
My resume
 
Taller semana 2_1 (1)
Taller semana 2_1 (1)Taller semana 2_1 (1)
Taller semana 2_1 (1)
 
Tarea seminario 4
Tarea seminario 4Tarea seminario 4
Tarea seminario 4
 
ABC Inds brochure
ABC Inds brochure ABC Inds brochure
ABC Inds brochure
 

Similar to Nikol Ježková: Doctrine2 Behavioral Extensions - zaostřeno na stromy

PigHive presentation and hive impor.pptx
PigHive presentation and hive impor.pptxPigHive presentation and hive impor.pptx
PigHive presentation and hive impor.pptxRahul Borate
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needMatthew Boeckman
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!benfante
 
Building Content Types with Dexterity
Building Content Types with DexterityBuilding Content Types with Dexterity
Building Content Types with DexterityDavid Glick
 
2018 05-11 the way we teach tech - phpday
2018 05-11 the way we teach tech - phpday2018 05-11 the way we teach tech - phpday
2018 05-11 the way we teach tech - phpdayJeroen van der Gulik
 
Managing multiple environments with Ansible
Managing multiple environments with AnsibleManaging multiple environments with Ansible
Managing multiple environments with Ansiblejtyr
 
Integrity and Security in Filesystems
Integrity and Security in FilesystemsIntegrity and Security in Filesystems
Integrity and Security in FilesystemsConferencias FIST
 

Similar to Nikol Ježková: Doctrine2 Behavioral Extensions - zaostřeno na stromy (14)

PigHive.pptx
PigHive.pptxPigHive.pptx
PigHive.pptx
 
PigHive presentation and hive impor.pptx
PigHive presentation and hive impor.pptxPigHive presentation and hive impor.pptx
PigHive presentation and hive impor.pptx
 
PigHive.pptx
PigHive.pptxPigHive.pptx
PigHive.pptx
 
XML parsing using jaxb
XML parsing using jaxbXML parsing using jaxb
XML parsing using jaxb
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
XML for bioinformatics
XML for bioinformaticsXML for bioinformatics
XML for bioinformatics
 
S3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever needS3 & Glacier - The only backup solution you'll ever need
S3 & Glacier - The only backup solution you'll ever need
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!
 
Building Content Types with Dexterity
Building Content Types with DexterityBuilding Content Types with Dexterity
Building Content Types with Dexterity
 
2018 05-11 the way we teach tech - phpday
2018 05-11 the way we teach tech - phpday2018 05-11 the way we teach tech - phpday
2018 05-11 the way we teach tech - phpday
 
Managing multiple environments with Ansible
Managing multiple environments with AnsibleManaging multiple environments with Ansible
Managing multiple environments with Ansible
 
Inside DocBlox
Inside DocBloxInside DocBlox
Inside DocBlox
 
Integrity and Security in Filesystems
Integrity and Security in FilesystemsIntegrity and Security in Filesystems
Integrity and Security in Filesystems
 

Recently uploaded

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

Nikol Ježková: Doctrine2 Behavioral Extensions - zaostřeno na stromy