mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
Activity Reasons, Activity Reasons Category, Activity Types in Translatable strings
This commit is contained in:
parent
e9fdfb341d
commit
5bd8b22569
@ -33,9 +33,9 @@ class ActivityReason
|
|||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $label;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ActivityReasonCategory
|
* @var ActivityReasonCategory
|
||||||
@ -59,29 +59,42 @@ class ActivityReason
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set label
|
* Set name
|
||||||
*
|
*
|
||||||
* @param string $label
|
* @param array $name
|
||||||
*
|
*
|
||||||
* @return ActivityReason
|
* @return ActivityReason
|
||||||
*/
|
*/
|
||||||
public function setLabel($label)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->label = $label;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get label
|
* Get name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array | string
|
||||||
*/
|
*/
|
||||||
public function getLabel()
|
public function getName($locale = null)
|
||||||
{
|
{
|
||||||
return $this->label;
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set category
|
* Set category
|
||||||
*
|
*
|
||||||
|
@ -33,12 +33,18 @@ class ActivityReasonCategory
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $label;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $active;
|
private $active;
|
||||||
|
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return 'blop';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,27 +58,40 @@ class ActivityReasonCategory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set label
|
* Set name
|
||||||
*
|
*
|
||||||
* @param string $label
|
* @param array $name
|
||||||
*
|
*
|
||||||
* @return ActivityReasonCategory
|
* @return ActivityReasonCategory
|
||||||
*/
|
*/
|
||||||
public function setLabel($label)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->label = $label;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get label
|
* Get name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLabel()
|
public function getName($locale = null)
|
||||||
{
|
{
|
||||||
return $this->label;
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ class ActivityType
|
|||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class ActivityType
|
|||||||
/**
|
/**
|
||||||
* Set name
|
* Set name
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param array $name
|
||||||
*
|
*
|
||||||
* @return ActivityType
|
* @return ActivityType
|
||||||
*/
|
*/
|
||||||
@ -63,11 +63,24 @@ class ActivityType
|
|||||||
/**
|
/**
|
||||||
* Get name
|
* Get name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array | string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName($locale = null)
|
||||||
{
|
{
|
||||||
return $this->name;
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class ActivityReasonCategoryType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('label')
|
->add('name', 'translatable_string')
|
||||||
->add('active')
|
->add('active')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ class ActivityReasonType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('label')
|
->add('name', 'translatable_string')
|
||||||
->add('active')
|
->add('active')
|
||||||
->add('category')
|
->add('category', 'translatable_activity_reason_category')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class ActivityTypeType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('name')
|
->add('name', 'translatable_string')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
68
Form/Type/TranslatableActivityReasonCategory.php
Normal file
68
Form/Type/TranslatableActivityReasonCategory.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of TranslatableActivityReasonCategory
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class TranslatableActivityReasonCategory extends AbstractType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var RequestStack
|
||||||
|
*/
|
||||||
|
private $requestStack;
|
||||||
|
|
||||||
|
public function __construct(RequestStack $requestStack)
|
||||||
|
{
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'translatable_activity_reason_category';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return 'entity';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||||
|
$resolver->setDefaults(
|
||||||
|
array(
|
||||||
|
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
||||||
|
'property' => 'name['.$locale.']'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -8,9 +8,8 @@ Chill\ActivityBundle\Entity\ActivityReason:
|
|||||||
generator:
|
generator:
|
||||||
strategy: AUTO
|
strategy: AUTO
|
||||||
fields:
|
fields:
|
||||||
label:
|
name:
|
||||||
type: string
|
type: json_array
|
||||||
length: 255
|
|
||||||
active:
|
active:
|
||||||
type: boolean
|
type: boolean
|
||||||
manyToOne:
|
manyToOne:
|
||||||
|
@ -8,9 +8,8 @@ Chill\ActivityBundle\Entity\ActivityReasonCategory:
|
|||||||
generator:
|
generator:
|
||||||
strategy: AUTO
|
strategy: AUTO
|
||||||
fields:
|
fields:
|
||||||
label:
|
name:
|
||||||
type: string
|
type: json_array
|
||||||
length: 255
|
|
||||||
active:
|
active:
|
||||||
type: boolean
|
type: boolean
|
||||||
lifecycleCallbacks: { }
|
lifecycleCallbacks: { }
|
||||||
|
@ -9,6 +9,5 @@ Chill\ActivityBundle\Entity\ActivityType:
|
|||||||
strategy: AUTO
|
strategy: AUTO
|
||||||
fields:
|
fields:
|
||||||
name:
|
name:
|
||||||
type: string
|
type: json_array
|
||||||
length: 255
|
|
||||||
lifecycleCallbacks: { }
|
lifecycleCallbacks: { }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
activitytype:
|
chill_activity_activitytype:
|
||||||
path: /{_locale}/admin/activitytype/
|
path: /{_locale}/admin/activitytype/
|
||||||
defaults: { _controller: "ChillActivityBundle:ActivityType:index" }
|
defaults: { _controller: "ChillActivityBundle:ActivityType:index" }
|
||||||
options:
|
options:
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
# chill_activity.example:
|
chill.activity.form.type.translatableactivityreasoncategory:
|
||||||
# class: Chill\ActivityBundle\Example
|
class: Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory
|
||||||
# arguments: [@service_id, "plain_value", %parameter%]
|
arguments:
|
||||||
|
- "@request_stack"
|
||||||
|
tags:
|
||||||
|
- { name: form.type, alias: translatable_activity_reason_category }
|
64
Resources/migrations/Version20150702093317.php
Normal file
64
Resources/migrations/Version20150702093317.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Application\Migrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
class Version20150702093317 extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Schema $schema
|
||||||
|
*/
|
||||||
|
public function up(Schema $schema)
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReason DROP COLUMN label;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReason ADD COLUMN name JSON;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityType DROP COLUMN name;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityType ADD COLUMN name JSON;');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Schema $schema
|
||||||
|
*/
|
||||||
|
public function down(Schema $schema)
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN name;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReason DROP COLUMN name;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityReason ADD COLUMN label VARCHAR(255) NOT NULL;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityType DROP COLUMN name;');
|
||||||
|
$this->addSql('ALTER TABLE ActivityType ADD COLUMN name VARCHAR(255) NOT NULL;');
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Label</th>
|
<th>Name</th>
|
||||||
<th>Active</th>
|
<th>Active</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ path('chill_activity_activityreason_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
<td><a href="{{ path('chill_activity_activityreason_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||||
<td>{{ entity.label }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
<td>{{ entity.active }}</td>
|
<td>{{ entity.active }}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<td>{{ entity.id }}</td>
|
<td>{{ entity.id }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Label</th>
|
<th>Name</th>
|
||||||
<td>{{ entity.label }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Active</th>
|
<th>Active</th>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Label</th>
|
<th>Name</th>
|
||||||
<th>Active</th>
|
<th>Active</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
<td><a href="{{ path('chill_activity_activityreasoncategory_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||||
<td>{{ entity.label }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
<td>{{ entity.active }}</td>
|
<td>{{ entity.active }}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<td>{{ entity.id }}</td>
|
<td>{{ entity.id }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Label</th>
|
<th>Name</th>
|
||||||
<td>{{ entity.label }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Active</th>
|
<th>Active</th>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
{% for entity in entities %}
|
{% for entity in entities %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ path('chill_activity_activitytype_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
<td><a href="{{ path('chill_activity_activitytype_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
|
||||||
<td>{{ entity.name }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<td>{{ entity.name }}</td>
|
<td>{{ entity.name|localize_translatable_string }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user