Skip to content

Commit

Permalink
Merge pull request #579 from Victoire/1.7
Browse files Browse the repository at this point in the history
update master
  • Loading branch information
paulandrieux committed Aug 22, 2016
2 parents 0b2e6bd + 33e9569 commit 2c86a73
Show file tree
Hide file tree
Showing 119 changed files with 2,848 additions and 1,257 deletions.
6 changes: 0 additions & 6 deletions Bundle/BlogBundle/Form/BlogSettingsType.php
Expand Up @@ -4,7 +4,6 @@

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Victoire\Bundle\PageBundle\Entity\PageStatus;

Expand All @@ -13,11 +12,6 @@
*/
class BlogSettingsType extends BlogType
{
public function __construct($available_locales, RequestStack $requestStack)
{
parent::__construct($available_locales, $requestStack);
}

/**
* define form fields.
*
Expand Down
10 changes: 0 additions & 10 deletions Bundle/BlogBundle/Form/BlogType.php
Expand Up @@ -4,7 +4,6 @@

use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Victoire\Bundle\PageBundle\Form\BasePageType;

Expand All @@ -13,15 +12,6 @@
*/
class BlogType extends BasePageType
{
/*
* Constructor
*/

public function __construct($availableLocales, RequestStack $requestStack)
{
parent::__construct($availableLocales, $requestStack);
}

/**
* define form fields.
*
Expand Down
8 changes: 2 additions & 6 deletions Bundle/BlogBundle/Resources/config/services.yml
Expand Up @@ -86,10 +86,8 @@ services:

#BLOG
victoire_blog.blog.form.type:
parent: "victoire_core.view.form.type"
class: Victoire\Bundle\BlogBundle\Form\BlogType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type }

Expand All @@ -99,10 +97,8 @@ services:
- { name: form.type }

victoire_blog.blog_settings.form.type:
parent: "victoire_core.view.form.type"
class: Victoire\Bundle\BlogBundle\Form\BlogSettingsType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type }

Expand Down
Expand Up @@ -30,7 +30,6 @@ public function __construct($userClass, BusinessEntityHelper $businessEntityHelp
protected function supports($attribute, $subject)
{
return method_exists($subject, 'getAuthor')
&& $this->businessEntityHelper->findByEntityInstance($subject)
&& 'BUSINESS_ENTITY_OWNER' === $attribute;
}

Expand Down
37 changes: 28 additions & 9 deletions Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php
Expand Up @@ -95,21 +95,40 @@ public function generateEntityPageFromTemplate(BusinessTemplate $businessTemplat

$page->setEntityProxy($entityProxy);
$page->setTemplate($businessTemplate);
/*
* Returns class and parent's uses
*
* @param $class
* @param bool $autoload
* @return array
*/
$class_uses_deep = function ($class, $autoload = true) {
$traits = [];
do {
$traits = array_merge(class_uses($class, $autoload), $traits);
} while ($class = get_parent_class($class));
foreach ($traits as $trait => $same) {
$traits = array_merge(class_uses($trait, $autoload), $traits);
}

return array_unique($traits);
};

if (in_array(Translatable::class, class_uses($entity))) {
foreach ($entity->getTranslations() as $translation) {
$page->setCurrentLocale($translation->getLocale());
$isTranslatableEntity = in_array(Translatable::class, $class_uses_deep($entity));
foreach ($businessTemplate->getTranslations() as $translation) {
if ($isTranslatableEntity) {
$entity->setCurrentLocale($translation->getLocale());
$businessTemplate->setCurrentLocale($translation->getLocale());
$page = $this->populatePage($page, $businessTemplate, $businessProperties, $em, $entity);
}
$page->setCurrentLocale($currentLocale);
$entity->setCurrentLocale($currentLocale);
$businessTemplate->setCurrentLocale($currentLocale);
} else {
$page->setCurrentLocale($translation->getLocale());
$businessTemplate->setCurrentLocale($translation->getLocale());
$page = $this->populatePage($page, $businessTemplate, $businessProperties, $em, $entity);
}

if ($isTranslatableEntity) {
$entity->setCurrentLocale($currentLocale);
}
$page->setCurrentLocale($currentLocale);
$businessTemplate->setCurrentLocale($currentLocale);

if ($seo = $businessTemplate->getSeo()) {
$pageSeo = clone $seo;
Expand Down
2 changes: 2 additions & 0 deletions Bundle/BusinessPageBundle/Entity/BusinessTemplate.php
Expand Up @@ -36,6 +36,8 @@ class BusinessTemplate extends Template implements VictoireQueryInterface
/**
* @var bool
*
* @deprecated author restriction is handled by the "BUSINESS_ENTITY_OWNER" role since 1.7.7 and will be removed in the 1.8
*
* @ORM\Column(name="author_restricted", type="boolean")
*/
protected $authorRestricted;
Expand Down
33 changes: 0 additions & 33 deletions Bundle/BusinessPageBundle/Form/BusinessPageType.php

This file was deleted.

13 changes: 0 additions & 13 deletions Bundle/BusinessPageBundle/Form/BusinessTemplateType.php
Expand Up @@ -5,7 +5,6 @@
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Victoire\Bundle\CoreBundle\Form\ViewType;

Expand All @@ -14,15 +13,6 @@
*/
class BusinessTemplateType extends ViewType
{
/*
* Constructor
*/

public function __construct($availableLocales, RequestStack $requestStack)
{
parent::__construct($availableLocales, $requestStack);
}

/**
* @param FormBuilderInterface $builder
* @param array $options
Expand Down Expand Up @@ -58,9 +48,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'label' => 'victoire.form.business_template.backend_name.label',
'vic_help_block' => 'victoire.form.business_template.backend_name.help_block',
])
->add('authorRestricted', null, [
'label' => 'victoire.form.business_template.author_restricted.label',
])
->add('query', null, [
'label' => 'victoire.form.business_template.query.label',
'vic_business_properties' => $options['vic_business_properties'],
Expand Down
13 changes: 1 addition & 12 deletions Bundle/BusinessPageBundle/Resources/config/services.yml
Expand Up @@ -4,22 +4,11 @@ parameters:

services:
victoire_business_page.business_template.form.type:
parent: "victoire_core.view.form.type"
class: Victoire\Bundle\BusinessPageBundle\Form\BusinessTemplateType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type }

victoire_business_page.business_page.form.type:
class: Victoire\Bundle\BusinessPageBundle\Form\BusinessPageType
arguments:
- "%victoire_i18n.available_locales%"
- "@request_stack"
tags:
- { name: form.type }


victoire_business_page.business_page_helper:
class: Victoire\Bundle\BusinessPageBundle\Helper\BusinessPageHelper
arguments:
Expand Down
Expand Up @@ -70,9 +70,13 @@
<source>victoire.form.business_template.query.label</source>
<target><![CDATA[<i class="fa fa-database"></i> Query <strong>BETA</strong>]]></target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="victoire.form.business_template.author_restricted.label">
<source>victoire.form.business_template.author_restricted.label</source>
<target>Restrict to the entity's author</target>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="form.page.type.roles.label">
<source>form.page.type.roles.label</source>
<target>Permissions needed to display the page</target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501614" resname="form.page.type.roles.help_block">
<source>form.page.type.roles.help_block</source>
<target>Format: BUSINESS_ENTITY_OWNER,PERMISSION_1,PERMISSION_2,...</target>
</trans-unit>
<trans-unit id="230619ccbd8b26a54c359543d88ebb1110501612" resname="victoire.form.business_template.query.vic_help_block">
<source>victoire.form.business_template.query.vic_help_block</source>
Expand Down
Expand Up @@ -70,9 +70,13 @@
<source>victoire.form.business_template.query.label</source>
<target><![CDATA[<i class="fa fa-database"></i> Consulta <strong>BETA</strong>]]></target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="victoire.form.business_template.author_restricted.label">
<source>victoire.form.business_template.author_restricted.label</source>
<target>Restringir el autor de la entidad</target>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="form.page.type.roles.label">
<source>form.page.type.roles.label</source>
<target>Permisos necesarios para mostrar la página</target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501614" resname="form.page.type.roles.help_block">
<source>form.page.type.roles.help_block</source>
<target>Formato: BUSINESS_ENTITY_OWNER,PERMISSION_1,PERMISSION_2,...</target>
</trans-unit>
<trans-unit id="230619ccbd8b26a54c359543d88ebb1110501612" resname="victoire.form.business_template.query.vic_help_block">
<source>victoire.form.business_template.query.vic_help_block</source>
Expand Down
Expand Up @@ -70,9 +70,13 @@
<source>victoire.form.business_template.query.label</source>
<target><![CDATA[<i class="fa fa-database"></i> Requête <strong>BETA</strong>]]></target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="victoire.form.business_template.author_restricted.label">
<source>victoire.form.business_template.author_restricted.label</source>
<target>Restreindre à l'auteur de l'entité</target>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501613" resname="form.page.type.roles.label">
<source>form.page.type.roles.label</source>
<target>Permissions nécessaires à l'affichage de la page</target>
</trans-unit>
<trans-unit id="4c359543d88eb230619ccbd8b26a5b1110501614" resname="form.page.type.roles.help_block">
<source>form.page.type.roles.help_block</source>
<target>Format: BUSINESS_ENTITY_OWNER,PERMISSION_1,PERMISSION_2,...</target>
</trans-unit>
<trans-unit id="230619ccbd8b26a54c359543d88ebb1110501612" resname="victoire.form.business_template.query.vic_help_block">
<source>victoire.form.business_template.query.vic_help_block</source>
Expand Down
Expand Up @@ -37,9 +37,6 @@
<div class="vic-col-md-12">
{{ 'victoire.form.business_template.query.vic_help_block'|trans|raw }}
{{ form_row(form.query) }}
<div class="vic-form-group">
{{ form_row(form.authorRestricted) }}
</div>
{{ form_rest(form) }}
</div>
</div>
Expand Down
31 changes: 27 additions & 4 deletions Bundle/CoreBundle/Entity/View.php
Expand Up @@ -19,10 +19,11 @@
* A victoire view is a visual representation with a widget map.
*
* @Gedmo\Tree(type="nested")
* @Gedmo\TranslationEntity(class="Victoire\Bundle\I18nBundle\Entity\ViewTranslation")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\Entity(repositoryClass="Victoire\Bundle\CoreBundle\Repository\ViewRepository")
* @ORM\Entity(
* repositoryClass="Victoire\Bundle\CoreBundle\Repository\ViewRepository"
* )
* @ORM\Table("vic_view")
* @ORM\HasLifecycleCallbacks
*/
Expand Down Expand Up @@ -158,6 +159,12 @@ abstract class View
* @ORM\Column(name="cssUpToDate", type="boolean")
*/
protected $cssUpToDate = false;
/**
* @var bool
*
* @ORM\Column(name="roles", type="text", nullable=true)
*/
protected $roles;

/**
* Construct.
Expand All @@ -177,7 +184,7 @@ public function __construct()
**/
public function __toString()
{
return $this->getName();
return '#'.$this->getId().' '.$this->getName();
}

/**
Expand Down Expand Up @@ -730,7 +737,7 @@ public function getWidgets()
public function isTemplateOf(View $view)
{
while ($_view = $view->getTemplate()) {
if ($this == $_view) {
if ($this === $_view) {
return true;
}
$view = $_view;
Expand Down Expand Up @@ -792,4 +799,20 @@ public function setSlug($slug, $locale = null)
$this->translate($locale, false)->setSlug($slug);
$this->mergeNewTranslations();
}

/**
* @return array
*/
public function getRoles()
{
return $this->roles;
}

/**
* @param array $roles
*/
public function setRoles($roles)
{
$this->roles = $roles;
}
}
9 changes: 9 additions & 0 deletions Bundle/CoreBundle/Form/CriteriaCollectionType.php
Expand Up @@ -10,4 +10,13 @@
*/
class CriteriaCollectionType extends CollectionType
{
/**
* {@inheritdoc}
*
* @return string
*/
public function getBlockPrefix()
{
return 'criteria_collection';
}
}

0 comments on commit 2c86a73

Please sign in to comment.