Dev Symfony2 rapide avec un framework de contenu

Post on 20-Aug-2015

615 views 1 download

Tags:

Transcript of Dev Symfony2 rapide avec un framework de contenu

DEV SF2 RAPIDEAVEC UN FRAMEWORK DE

CONTENU

VOTRE DÉVOUÉBertrand Dunogier (@bdunogier)Ingénieur lead extensibilitéeZ Systems, eZ Publish,

http://ez.nohttp://github.com/ezpublish-community

POURQUOI DU DEVRAPIDE ?

ET POURQUOI LE WEB D'ABORD ?

"CONTENT IS KING""Content is where I expect much of the real

money will be made on the Internet, just as it wasin broadcasting"

Bill Gates, 1996

"640K ought to be enough for anybody"

Bill Gates, jamais

ET LES CMS ?

LE WEB CHANGE...

HEUREUSEMENT QUE...

MAIS ET MON CMS ?

PHP AUSSI A CHANGÉ

FONDAMENTAUX

LE CONTENUVersions - Sécurité - Modèle flexible - Sémantique - i18n

S'INTÉGRERET NON

S'IMPOSERcomposer create-project symfony/framework-standard-edition my_project

cd my_project

composer require ezsystems/ezpublish-kernel

INTÉGRERET NON

RÉINVENTERdevenir un élément d'un ensemble et non une fin en soi.

composer require white-october/pagerfanta-bundle 1.0.*composer require whiteoctober/breadcrumbs-bundle ~1.0.1...

DE CMSÀ

CONTENT FRAMEWORK

DU CONCRET

EZ PUBLISHDOMAIN LANGUAGE

REPOSITORY

CONTENT TYPEEnsemble nommé de FIELD DEFINITION.

article, communiqué de presse, image, film...

FIELD DEFINITIONChamp nommé référençant un FIELD TYPE.

titre, fichier, réalisateur, année de sortie, affiche, diamètre...

Traduisible ou non, a ses options propres

FIELD TYPEPlus petite entité de stockage de données. A ses propres

templates d'affichage et d'édition.

ligne de texte, texte riche, relation, adresse email, localisation, case àcocher...

CONTENTUne instance d'un CONTENT TYPE.

Composé de une ou plusieurs VERSION, dont 0..1 publiée.

VERSIONEnsemble de FIELD correspondant aux DEFINITION du

CONTENT TYPE.

Peut avoir 1 à N langues

LOCATIONUn emplacement d'un CONTENT dans l'arbre de contenu.

CONTEXTE D'EXÉCUTIONLE SITEACCESS

Niveau supplémentaire de paramétrage, contextuel auxrequêtes.

ezpublish: siteaccess: default_siteaccess: main_site list: - site_fr - site_en match: Map\Host: site.com: site_en site.fr: site_fr # m.site.com: mobile_site_en

AFFICHER DU CONTENU

ROUTES DYNAMIQUES- Root location - Articles [dossier] - Technologie (fr) ou Technology (en) [catégorie] - Le contenu, simplement [article, location #123]

http://site.fr/Articles/Technologie/Le-contenu-simplementhttp://site.com/Articles/Technology/Content-made-simplehttp://site.com/Articles/Technology/Kontentsu-o-kantan-ni

seront dynamiquement routés verscontroller( "ez_content:viewLocation", {"locationId": 123, "viewType": "full"})

SUB-REQUEST{{ render( controller( "ez_content:viewLocation", {"locationId": 123, "viewType": "full"} )) }}

CHOIX AUTOMATIQUEDU TEMPLATE

ezpublish: default: location_view: block: article: template: "AcmeBundle:full:article.html.twig" match: Identifier\ContentType: [article]

OU DU CONTRÔLEURezpublish: mobile_site: content_view: full: article: template: "AcmeBundle:full:article.html.twig" match: Identifier\ContentType: [article] controller: AcmeBundle:Default:viewLocation

FONCTIONS TWIGNom d'un CONTENT dans la langue en cours

{{ ez_content_name(content) }}

Valeur du FIELD body en allemand{{ ez_field_value(content, 'body', 'ger-DE' ) }}

Rendu HTML du FIELD titre, via son template{{ ez_render_field(content, 'titre') }}

Tester si le FIELD titre est vide{{ ez_is_field_empty(content, 'titre') }}

API DU REPOSITORY

PHPSERVICES

ContentService, LocationService, SectionService, UserService,SearchService...

VALUE OBJECTSContent, ContentCreateStruct, User, UrlAlias, SearchHit...

// charger$contentService = $container->get( 'ezpublish.api.service.content' );$content = $contentService->loadContent( 42 );

// créer$struct = $contentService->newContentCreateStruct( $contentTypeService->loadContentType( 'article' ));$struct->fields['titre']['fre-FR'] = 'Le contenu, simplement';$struct->fields['titre']['eng-GB'] = 'Content made simple';$struct->fields['titre']['jpn-JP'] = 'コンテンツ、ちょうど';

$content = $contentService->createContent( $struct );$contentService->publishVersion( $content, 1 );

RESTHTTP/1.1 GET /api/ezp/v2/content/objects/64Host: site.comAccept: application/vnd.ez.api.Content+json

HTTP/1.1 DELETE /api/ezp/v2/content/objects/64/versions/1Host: site.com

GESTION UTILISATEURSMulti-utilisateurs, basé sur des rôles, extensible

(FOSUserBundle)

CONTENU RICHEEditeur XML, transformation XSLT, format de saisie extensible

CACHE HTTPCONTEXTUEL

$response->headers->set( 'X-Location-Id', $locationId );$response->setVary( 'X-User-Hash' );

INTEGRATIONDBAL, PagerFanta, FOSUserBundle...

EXTENSIBILITÉField Types, storage engines

ET L'INTERFACE ?

ON Y TRAVAILLE

(Avec YUI...)

FINDES QUESTIONS ?

@bdunogier http://github.com/bdunogier

http://joind.in/talk/view/11958