mandango/mandango-behaviors — Issue #1: Behaviors Translatable
Author: alexhub79
Created: 2011-10-12 14:12:47+00:00
State: open

I code The Translatable behavior but I have an error with a output directory

*
* This file is part of Doctrator.
*
* Doctrator is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Doctrator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Doctrator. If not, see .
*/

namespace Mandango\Behavior;

use Mandango\Mondator\ClassExtension;
use Mandango\Mondator\Definition\Method;
use Mandango\Mondator\Output;

/**
* The doctrator Translatable behavior.
*
* @package Doctrator
* @author Pablo Díez Pascual
*/
class Translatable extends ClassExtension
{
/**
* @inheritdoc
*/
protected function setUp()
{
$this->addRequiredOption('columns');
$this->addOptions(array(
'output' => $this->configClass['output']
));
}

/**
* @inheritdoc
*/
protected function doNewConfigClassesProcess()
{
// %class%Translation
$translationConfigClass = array(
'columns' => array(
'id' => array('id' => 'auto', 'type' => 'integer'),
'locale' => array('type' => 'string', 'length' => 7),
),
'many_to_one' => array(
'parent' => array('class' => $this->class, 'inversed' => 'translations'),
),

);

$configClassColumns = $this->configClass['behaviors']['translatable']['options']['columns'];
foreach ($this->getOption('columns') as $column) {
if (!isset($configClassColumns[$column])) {
throw new \RuntimeException(sprintf('The column "%s" of the class "%s" does not exists.', $column, $this->class));
}
$translationConfigClass['columns'][$column] = $configClassColumns[$column];

unset($configClassColumns[$column]);
}
$this->configClass['columns'] = $configClassColumns;

$this->newConfigClasses[$this->class.'Translation'] = $translationConfigClass;
$this->newConfigClasses['output'] = new Output($this->configClass['output']);
// relation

$this->configClass['one_to_many']['translations'] = array(
'class' => $this->class.'Translation',
'mapped' => 'parent',

);

}
/**
* @inheritdoc
*/
protected function doClassProcess()
{

// assign extensions

// "translation" method
$method = new Method('public', 'translation', '$locale', <<getTranslations() as \$translation) {
if (\$translation->getLocale() == \$locale) {
return \$translation;
}
}

\$translation = new \\{$this->class}Translation();
\$translation->setParent(\$this);
\$translation->setLocale(\$locale);

\$this->getTranslations()->add(\$translation);

return \$translation;
EOF
);
$method->setDocComment(<<class}Translation The translation entity.
*/
EOF
);

$this->definitions['document_base']->addMethod($method);
}
}

My schema.yml

Model\MongoMenuBundle\Menu:
fields:
name: { type: string, validation: [NotBlank: ~, Type: string] }
title: { type: string, validation: [NotBlank: ~, Type: string] }
embeddedsMany:
contenu: { class: Model\MongoMenuBundle\Contenu, validation: [NotNull: ~] }
behaviors:
slug:
class: Mandango\Behavior\Sluggable
options: { fromField: title}
translatable:
class: Mandango\Behavior\Translatable
options:
columns:
title: title
output: Model\MongoMenuBundle\MenuTranslation
Model\MongoMenuBundle\Contenu:
isEmbedded: true
fields:
title: { type: string, validation: [NotBlank: ~, Type: string] }
text: { type: string, validation: [NotBlank: ~, Type: string] }

Have you an idea