SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
6.
Il processo di sviluppo basato sulla
collaborazione, sulla reciproca soddisfazione e
sul senso di responsabilità permette di ottenere
un alto valore per il cliente.
7.
bundle = è una cartella con una struttura ben
definita, che può ospitare qualsiasi cosa, dalle
classi ai controllori e alle risorse web
http://symfony.com/it/doc/current/cookbook/bundles/best_practices.html
8.
bundle = uno spazio dei nomi di PHP ovvero un
namespace, con con una classe Bundle
http://symfony.com/it/doc/current/cookbook/bundles/best_practices.html
9.
bundle = una libreria sufficientemente astratta
da essere utilizzata in contesti diversi tra loro
10.
la realizzazione di un bundle non è valore
per il cliente
11.
Richiesta
un sito web con contenuti aggiornabili
disponibili in diverse lingue
12.
Analisi
gli strumenti esistenti sono valutati come non
adatti
22.
interface LocaleInterface
{
function setLocale($locale);
function getLocale();
function getDefaultLocale();
}
23.
use AcmeCoreBundleModelTranslatingInterface;
use AcmeCoreBundleLocaleLocaleInterface;
interface TranslatableInterface
{
function addTranslation(TranslatingInterface $translation);
function getTranslations();
function setLocale(LocaleInterface $locale);
}
24.
use AcmeCoreBundleModelTranslatableInterface;
interface TranslatingInterface
{
function setTranslatable(TranslatableInterface $translatable);
function getLocale();
function setLocale($string);
}
25.
class Article
{
/**
* @ORMOneToMany
* (targetEntity="ArticleI18n", mappedBy="translatable")
*/
protected $translations;
public function getTitle()
{
return $this->getTranslation()->getTitle();
}
}
26.
class Article
{
/**
* @ORMOneToMany
* (targetEntity="ArticleI18n", mappedBy="translatable")
*/
protected $translations;
public function getTitle()
{
return $this->getTranslation()->getTitle();
}
}
27.
class ArticleI18n
{
/**
* @ORMManyToOne(targetEntity="Article", inversedBy="translations"
* @ORMJoinColumn(name="article_id", referencedColumnName="id")
*/
protected $translatable;
/**
* @ORMColumn(type="string", length=128)
*/
private $title;
public function getTitle()
{
return $this->title;
}
}
54.
class Article extends Translatable
{
/**
* @ORMOneToMany
* (targetEntity="ArticleI18n", mappedBy="translatable")
*/
protected $translations;
public function getTitle()
{
return $this->getTranslation()->getTitle();
}
}
55.
Una volta testata anche l'integrazione e
verificato che la richiesta del cliente è stata
soddisfatta, abbiamo prodotto il valore richiesto
e ci possiamo fermare.
59.
Il grosso è fatto, ora dovremo:
- esporre una configurazione semantica
- gestire le dipendenze (composer) e la configurazione dei test
- aggiungere la documentazione, la licenza ecc.
61.
namespace PUGXI18nBundle;
use SymfonyComponentHttpKernelBundleBundle;
use PUGXI18nBundleDependencyInjectionPUGXI18nExtension;
class PUGXI18nBundle extends Bundle
{
public function getContainerExtension()
{
return new PUGXI18nExtension();
}
}
62.
namespace PUGXI18nBundleDependencyInjection;
use SymfonyComponentConfigDefinitionBuilderTreeBuilder;
use SymfonyComponentConfigDefinitionConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('pugx_i18n');
return $treeBuilder;
}
}
63.
namespace PUGXI18nBundleDependencyInjection;
use SymfonyComponentDependencyInjectionContainerBuilder;
use SymfonyComponentConfigFileLocator;
use SymfonyComponentHttpKernelDependencyInjectionExtension;
use SymfonyComponentDependencyInjectionLoaderYamlFileLoader;
class PUGXI18nExtension implements Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$path = __DIR__.'/../Resources/config'
$loader = new YamlFileLoader($container, new FileLocator($path));
$loader->load('services.yml');
}
public function getAlias()
{
return 'pugx_i18n';
}
}