SlideShare a Scribd company logo
1 of 40
Download to read offline
Estendere applicazioni
extbase
Nuovi metodi ed esempi con news system
Presentato da: Cristian Buja T3Camp Italia 2014
Milano 14 - 15 marzo
Cristian Buja
2010
2014
2011
2012
2013
Sulla strada di TYPO3 ed Extbase
Metodi precedenti ad extbase
Xclass Hooks
Xclass prima di TYPO3 6.0
ext_localconf.
php
ext:example
ux_backend.php
associazione
2
3
1dichiarazione
backend.php
typo3
3 REQUISITI
Xclass prima di TYPO3 6.0
3 associazione in ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/backend.php'] =
'typo3conf/examples/xclass/ux_backend.php'
1 dichiarazione in typo3/backend.php
if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/backend.php']);
}
2 sintassi del nome file
ux_[nome_classe].php
TYPO3 6.0 rompe le catene!
ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']
['TYPO3CMSBackendControllerNewRecordController'] = array (
'className' =>
'DocumentationExamplesXclassNewRecordController'
);
Solo associazione !
Cambiamenti nelle classi statiche
Deprecated
t3lib_div
Use
TYPO3CMSCoreUtilityGeneralUtility
GeneralUtility::makeInstance()
GeneralUtility::callUserFunction()
GeneralUtility::getUserObj()
Hooks remains the same…?
Estensioni
$TYPO3_CONF_VARS['EXTCONF'][ extension_key ][ sub_key ] = value
Core
$TYPO3_CONF_VARS['SC_OPTIONS'][ main_key ][ sub_key ][ index ] = function_reference
Moduli BE
$TBE_MODULES_EXT[ backend_module_key ][ sub_key ] = value
Metodi introdotti con extbase
Dependency
Injection Signal / Slot
Dependency Injection (DI)
Injection Extbase
/**
* @var Tx_Extbase_Object_ObjectManagerInterface $objectManager
*/
protected $objectManager;
/**
* @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
* @return void
*/
public function injectObjectManager (
Tx_Extbase_Object_ObjectManagerInterface $objectManager
) {
$this->objectManager = $objectManager;
}
Dependency Injection (DI)
Injection Extbase > 4.7
/**
* @var TYPO3CMSExtbaseSignalSlotDispatcher
* @inject
*/
protected $signalSlotDispatcher;
@inject
is
Comment the code
Dependency Injection (DI)
Costructor injection
/**
* @param TYPO3CMSExtbaseObjectManagerInterface $objectManager
*/
public function __constructor(TYPO3CMSExtbaseObjectManagerInterface $objectManager) {
$this->objectManager = $objectManager;
}
Initialize Object
/**
* Additional inizialization
*/
public function inizializeObject() { ... }
Object manager: istanziare oggetti
GeneralUtility::makeIstance()
ObjectManager->get()
/**
* @var TYPO3CMSExtbaseObjectObjectManagerInterface
* @inject
*/
protected $objectManager;
public function foo () {
...
$cObj = $this->objectManager
->get('TYPO3CMSFrontendContentObjectContentObjectRenderer');
...
}
Extbase: Mappatura delle classi
Typoscript Setup:
config.tx_extbase.object {
TYPO3CMSExtbasePersistenceGenericStorageBackendInterface {
className = TYPO3CMSExtbasePersistenceGenericStorageTypo3DbBackend
}
}
Injection
+ Typoscript
Extbase: Mappatura delle classi
Typoscript Setup:
plugin.tx_example.object {
TYPO3CMSExtbasePersistenceGenericStorageBackendInterface {
className = TYPO3CMSExtbasePersistenceGenericStorageTypo3DbBackend
}
}
Extbase > 6.1
Ovverride global config
Power Up!
Signal / Slot
TYPO3CMSExtbaseSignalSlotDispatcher.php
public function connect (
$signalClassName, $signalName,
$slotClassNameOrObject, $slotMethodName,
$passSignalInformation = TRUE
) { … }
public function dispatch (
$signalClassName, $signalName,
array signalArguments = array()
) { … }
Paradigma Event / Observer
Dispatcher injection
TYPO3CMSExtbaseMvcControllerAbstractController.php
/**
* Injects the signal slot dispatcher
*
* @param TYPO3CMSExtbaseSignalSlotDispatcher $signalSlotDispatcher
*/
public function injectSignalSlotDispatcher(
TYPO3CMSExtbaseSignalSlotDispatcher $signalSlotDispatcher
) {
$this->signalSlotDispatcher = $signalSlotDispatcher;
}
Dispatcher
Connect Slot
ExampleController.php
/**
* Injects the signal slot dispatcher
*
* @param TYPO3CMSExtbaseSignalSlotDispatcher $signalSlotDispatcher
*/
public function initializeObject () {
$this->signalSlotDispatcher->connect( ... );
}
Dispatcher
Observer
Observer
Observer
Dispatch signal
TYPO3CMSExtbaseMvcControllerActionController.php
$this->signalSlotDispatcher->dispatch(
__CLASS__,
'beforeCallActionMethod',
array(
'controllerName' => get_class($this),
'actionMethodName' => $this->actionMethodName,
'preparedArguments' => $preparedArguments
)
);
Dispatcher
Observer
Observer
Observer
Event
Dove mettere le connessioni allo slot?
ext_localcong.php
$signalSlotDispatcher =
TYPO3CMSCoreUtilityGeneralUtility
::makeInstance('TYPO3CMSExtbaseObjectObjectManager')
-> get('TYPO3CMSExtbaseSignalSlotDispatcher');
$signalSlotDispatcher->connect( ... );
Work around in news system
+ metodi al domain object?
+ action a un controller?
Dependency Injection
+ estensioni agiscono sulle medesime classi?
Work around in news system
Cached class
Resources/Private/extend-news.txt
Domain/Model/News
Classes/Domain/Model/News.php
class News extends Tx_News_Domain_Model_News {
protected $newField;
public function getNewField() { … }
public function setNewField($newField) { … }
}
Cached class
ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']
['clearCachePostProc'][$_EXTKEY . '_classcache'] =
'EXT:' . $_EXTKEY .
'/Classes/Cache/ClassCacheBuilder.php:Tx_News_Cache_ClassCacheBuilder->build';
Cosa fa?
Cached class
typo3temp/Cache/Code/cache_phpcode/Domain_Model_News.php
class Tx_News_Domain_Model_News extends Tx_Extbase_DomainObject_AbstractEntity {
…
…
/***********************************************************************
this is partial from: /var/www/html/typo3conf/ext/example/Classes/Domain/Model/News.php
***********************************************************************/
protected $newField;
public function getNewField() { … }
public function setNewField($newField) { … }
}
Estensioni per news system
➔ newsdirsync
➔ roq_newsevent
➔ mfc_author
➔ pb_news_job
➔ newsslider
➔ newsfal
➔ newsextended
Imprevisti in extension manager
Downgrade delle news
Ordine delle dipendenze errato
Esempio: publications con le news
Specifiche mancanti
➔ campi aggiuntivi
➔ ricerca avanzata
➔ layout dedicato
➔ ordinamento alternativo
Cosa vogliamo ottenere
Estendere Domain Model
News
Campi specifici delle publications
Dto/NewsDemand
Campo per ordinamento
Dto/Search
Campi per la form
Campi visibili aggiunti alle news
Ricerca avanzata
Hook:
$GLOBALS ['TYPO3_CONF_VARS'][EXT][news]
['Domain/Repository/AbstractDemandedRepository.php']['findDemanded']
function findDemanded($params, &$parent) { .. }
$params = array(
'demand' => $demand,
'respectEnableFields' => &$respectEnableFields,
'query' => $query,
'constraints' => &$constraints,
);
Layout dedicato
page TSConfig
tx_news.templateLayouts {
1 = News
2 = Publications
}
Template
<f:if condition=“{settings.templateLayout}=2}”>
Layout dedicato
Ordinamento Alternativo
$TYPO3_CONF_VARS['EXT']['news']['orderByNews'] .= ',publication_year';
News Related by Category
lib.news.relatedByCategory = USER
lib.news.relatedByCategory {
userFunc = TYPO3CMSExtbaseCoreBootstrap->run
pluginName = Pi1
extensionName = News
controller = News
action = list
switchableControllerActions.News.1 = list
persistence =< plugin.tx_news.persistence
settings =< plugin.tx_news.settings
settings {
isRelatedByCategory = 1
excludeAlreadyDisplayedNews = 1
useStdWrap = categories
categoryConjunction = and
categories.field = uid
limit = 5
}
}
Detail.html
<!-- Related by category -->
<f:for each="{newsItem.categories}" as="category">
<f:cObject
typoscriptObjectPath="lib.news.relatedByCategory"
data="{category}" />
</f:for>
List.html
...
<f:if condition={settings.isRelatedByCategory}”>
<f:then>
<h4>Related by category: {contentObjectData.title}</h4>
<ul><f:for each”{news}” as=”newsItem”><li><n:link
newsItem="{newsItem}"
settings="{settings}"
>{newsItem.title}</n:link></li><f:for></ul>
</f:then>
...
Parole chiave
Dependency Injection
XClass
Extbase
Hook
Signal / Slot
News
TYPO3
Cached Class
Link Utili
http://docs.typo3.org/TYPO3/CoreApiReference/ApiOverview/Hooks/
http://docs.typo3.org/TYPO3/CoreApiReference/ApiOverview/Xclasses/
http://forge.typo3.org/projects/typo3v4-mvc/wiki/Dependency_Injection_(DI)
http://docs.typo3.
org/flow/TYPO3FlowDocumentation/stable/TheDefinitiveGuide/PartIII/SignalsA
ndSlots.html
http://typo3.org/api/typo3cms/
http://2012.t3campitalia.it/slide-video-typo3-t3camp-italia/slide-come-
modificare-il-core-di-typo3-senza-toccarlo.html
http://docs.typo3.org/typo3cms/extensions/news/
Grazie per l’attenzione

More Related Content

What's hot

Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 
Authentication Functions
Authentication FunctionsAuthentication Functions
Authentication Functions
Valerie Rickert
 

What's hot (20)

PHP 8.1: Enums
PHP 8.1: EnumsPHP 8.1: Enums
PHP 8.1: Enums
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
 
Linux shell script-1
Linux shell script-1Linux shell script-1
Linux shell script-1
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere Mortals
 
Php Enums
Php EnumsPhp Enums
Php Enums
 
Twig tips and tricks
Twig tips and tricksTwig tips and tricks
Twig tips and tricks
 
Александр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 EvolutionАлександр Трищенко: PHP 7 Evolution
Александр Трищенко: PHP 7 Evolution
 
Java programs
Java programsJava programs
Java programs
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-1603021543447b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
7b615dc2-ba86-4ecd-8b1f-d0d32de89a0c-160302154344
 
Authentication Functions
Authentication FunctionsAuthentication Functions
Authentication Functions
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка
 
Fewd week5 slides
Fewd week5 slidesFewd week5 slides
Fewd week5 slides
 
Ext oo
Ext ooExt oo
Ext oo
 
TensorFlow local Python XLA client
TensorFlow local Python XLA clientTensorFlow local Python XLA client
TensorFlow local Python XLA client
 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python Developers
 
Import java
Import javaImport java
Import java
 

Similar to Estendere applicazioni extbase

international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
smueller_sandsmedia
 
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
JongWon Kim
 

Similar to Estendere applicazioni extbase (20)

TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase framework
 
TYPO3 6.2 for extension developer
TYPO3 6.2 for extension developerTYPO3 6.2 for extension developer
TYPO3 6.2 for extension developer
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
Flight Data Analysis
Flight Data AnalysisFlight Data Analysis
Flight Data Analysis
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
My Development Story
My Development StoryMy Development Story
My Development Story
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, Macoscope
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
Using and reusing CakePHP plugins
Using and reusing CakePHP pluginsUsing and reusing CakePHP plugins
Using and reusing CakePHP plugins
 
How to recognise that the user has just uninstalled your app
How to recognise that the user has just uninstalled your appHow to recognise that the user has just uninstalled your app
How to recognise that the user has just uninstalled your app
 
OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 

Recently uploaded

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
Enterprise Knowledge
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 

Estendere applicazioni extbase