[FLOW3-general] General question regarding i18n

Kevin Ulrich Moschallski km at 3digit.de
Wed May 25 18:50:23 CEST 2011


On 2011-05-25 16:16:22 +0200, Kevin Ulrich Moschallski said:

> Hi,
> 
> i have a general question on topic of i18n. I'm currently working with 
> FLOW3 for a small portal. This portal should be multilanguage and 
> mutli-location. For this i got some inspiration from the TYPO3 package, 
> especially  the \F3\TYPO3CR\Domain\Service\Context object.
> 
> With this object as base i added language and location as properties to 
> my object. Currently i create the context in my index action, which is 
> fine so far because i use extjs for the portal, so all further actions 
> are called from extjs which knows the current language and location 
> from a global variable.
> 
> Now i want to able to call actions directly without the extjs variables 
> setting the language. Therefore i added some parameters to my 
> routers.yaml so i can set the language and location via the url.
> 
> My questions know are:
> 
> 1. Would you set the context in the initialize method of each 
> conroller, maybe with an aspect?
> 
> or
> 
> 2. Would you prefer to set the context object @scope session? Would i 
> then be possible to change language and location while the session is 
> active?
> 
> I'm looking forward to your replies.
> 
> Regards,
> Kevin

Hi,

as i'm currently try to implement this with an aspect i have a small question:

Is it possible to set a property with an aspect? I know that i could 
implement an interface with an aspect, but is implementing only a 
single property also possible?

Here is my code:

<?php
declare(ENCODING = 'utf-8');
namespace F3\Special\Controller\Aspect;

/**
 * Adds the aspect of context to action controllers
 *
 * @aspect
 */
class ActionControllerAspect {

	/**
	 * @var F3\Special\Domain\Service\Context
	 */
	protected $context;
	
	/**
	 * @var \F3\FLOW3\Object\ObjectManagerInterface
	 */
	protected $objectManager;

	/**
	 * Constructor.
	 * The Object Factory will automatically be passed (injected) by the object
	 * framework on instantiating this class.
	 *
	 * @param \F3\FLOW3\Object\ObjectManagerInterface $objectManager The 
object manager
	 */
	public function __construct(\F3\FLOW3\Object\ObjectManagerInterface 
$objectManager) {
		$this->objectManager = $objectManager;
	}
	
	/**
	 * @pointcut methodTaggedWith(context)
	 */
	public function needsContext() {}

	/**
	 * Before advice, setting the context
	 *
	 * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
	 * @return void
	 * @before methodTaggedWith(context)
	 */
	public function generateContext(\F3\FLOW3\AOP\JoinPointInterface $joinPoint) {
		$this->context = 
$this->objectManager->create('F3\Special\Domain\Service\PortalContext');
	}
}
?>


Regards,
Kevin



More information about the FLOW3-general mailing list