Skip to content

Commit

Permalink
Merge pull request #1006 from FrancoisDoussin/feature/vic-links
Browse files Browse the repository at this point in the history
✨ Add global 301 redirections (and 404 errors)
  • Loading branch information
lenybernard authored Dec 20, 2017
2 parents e1ee860 + a16dc19 commit ea690cc
Show file tree
Hide file tree
Showing 70 changed files with 4,423 additions and 156 deletions.
35 changes: 18 additions & 17 deletions Bundle/BlogBundle/Entity/BlogCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Victoire\Bundle\BlogBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Victoire\Bundle\BusinessEntityBundle\Entity\Traits\BusinessEntityTrait;
Expand Down Expand Up @@ -108,8 +109,8 @@ class BlogCategory
*/
public function __construct()
{
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
$this->articles = new \Doctrine\Common\Collections\ArrayCollection();
$this->children = new ArrayCollection();
$this->articles = new ArrayCollection();
}

/**
Expand Down Expand Up @@ -187,7 +188,7 @@ public function getSlug()
*
* @param string $articles
*
* @return PostPage
* @return BlogCategory
*/
public function setArticles($articles)
{
Expand All @@ -211,7 +212,7 @@ public function getArticles()
*
* @param int $lft
*
* @return Menu
* @return BlogCategory
*/
public function setLft($lft)
{
Expand All @@ -235,7 +236,7 @@ public function getLft()
*
* @param int $lvl
*
* @return Menu
* @return BlogCategory
*/
public function setLvl($lvl)
{
Expand All @@ -259,7 +260,7 @@ public function getLvl()
*
* @param int $rgt
*
* @return Menu
* @return BlogCategory
*/
public function setRgt($rgt)
{
Expand All @@ -283,7 +284,7 @@ public function getRgt()
*
* @param int $root
*
* @return Menu
* @return BlogCategory
*/
public function setRoot($root)
{
Expand All @@ -305,9 +306,9 @@ public function getRoot()
/**
* Set parent.
*
* @param Menu $parent
* @param BlogCategory $parent
*
* @return Menu
* @return BlogCategory
*/
public function setParent(self $parent = null)
{
Expand All @@ -319,7 +320,7 @@ public function setParent(self $parent = null)
/**
* Get parent.
*
* @return Menu
* @return BlogCategory
*/
public function getParent()
{
Expand All @@ -329,9 +330,9 @@ public function getParent()
/**
* Add child.
*
* @param Menu $child
* @param BlogCategory $child
*
* @return Menu
* @return BlogCategory
*/
public function addChild(self $child)
{
Expand All @@ -344,7 +345,7 @@ public function addChild(self $child)
/**
* Remove children.
*
* @param Menu $child
* @param BlogCategory $child
*/
public function removeChild(self $child)
{
Expand All @@ -354,7 +355,7 @@ public function removeChild(self $child)
/**
* Remove children.
*
* @param Menu $child
* @param BlogCategory $child
*/
public function removeChildren(self $child)
{
Expand All @@ -366,7 +367,7 @@ public function removeChildren(self $child)
*
* @param array $children
*
* @return \Victoire\Bundle\BlogBundle\Entity\BlogCategory
* @return BlogCategory
*/
public function setChildren($children)
{
Expand All @@ -376,7 +377,7 @@ public function setChildren($children)
}

/**
* @return \Doctrine\Common\Collections\ArrayCollection
* @return ArrayCollection
*/
public function getChildren()
{
Expand Down Expand Up @@ -416,7 +417,7 @@ public function getBlog()
/**
* @param Blog $blog
*
* @return $this
* @return BlogCategory
*/
public function setBlog(Blog $blog)
{
Expand Down
13 changes: 8 additions & 5 deletions Bundle/CoreBundle/Entity/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Victoire\Bundle\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;
Expand All @@ -25,7 +26,7 @@ class Link
const TARGET_BLANK = '_blank';
const TARGET_MODAL = '_modal';

use \Gedmo\Timestampable\Traits\TimestampableEntity;
use TimestampableEntity;

/**
* @var int
Expand All @@ -40,6 +41,8 @@ class Link
* @var string
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*
* @Assert\Url()
*/
protected $url;

Expand Down Expand Up @@ -338,16 +341,16 @@ public function checkLink(ExecutionContextInterface $context)
// check if the name is actually a fake name
switch ($this->getLinkType()) {
case self::TYPE_VIEW_REFERENCE:
$violation = $this->getViewReference() == null;
$violation = $this->getViewReference() === null;
break;
case self::TYPE_ROUTE:
$violation = $this->getRoute() == null;
$violation = $this->getRoute() === null;
break;
case self::TYPE_URL:
$violation = $this->getUrl() == null;
$violation = $this->getUrl() === null;
break;
case self::TYPE_WIDGET:
$violation = $this->getAttachedWidget() == null;
$violation = $this->getAttachedWidget() === null;
break;
default:
break;
Expand Down
15 changes: 7 additions & 8 deletions Bundle/CoreBundle/Entity/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Knp\DoctrineBehaviors\Model\Translatable\Translatable;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate;
use Victoire\Bundle\BusinessPageBundle\Entity\VirtualBusinessPage;
use Victoire\Bundle\TemplateBundle\Entity\Template;
use Victoire\Bundle\ViewReferenceBundle\ViewReference\ViewReference;
use Victoire\Bundle\WidgetBundle\Entity\Widget;
use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap;

/**
Expand All @@ -29,7 +28,7 @@
*/
abstract class View
{
use \Gedmo\Timestampable\Traits\TimestampableEntity;
use TimestampableEntity;
use Translatable;

/**
Expand Down Expand Up @@ -126,8 +125,6 @@ abstract class View
protected $references;

/**
* @var string
*
* @ORM\ManyToOne(targetEntity="\Victoire\Bundle\TemplateBundle\Entity\Template", inversedBy="inheritors", cascade={"persist"})
* @ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="CASCADE")
*/
Expand All @@ -153,14 +150,16 @@ abstract class View
* @ORM\OrderBy({"id" = "ASC"})
*/
protected $widgets;

/**
* @var bool
*
* @ORM\Column(name="cssUpToDate", type="boolean")
*/
protected $cssUpToDate = false;

/**
* @var bool
* @var string
*
* @ORM\Column(name="roles", type="text", nullable=true)
*/
Expand Down Expand Up @@ -300,7 +299,7 @@ public function hasChildren()
/**
* Get WebView children.
*
* @return string
* @return array
*/
public function getWebViewChildren()
{
Expand Down Expand Up @@ -815,7 +814,7 @@ public function setSlug($slug, $locale = null)
}

/**
* @return array
* @return string
*/
public function getRoles()
{
Expand Down
2 changes: 1 addition & 1 deletion Bundle/CoreBundle/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function initLeftNavbar()
* @param ItemInterface $rootItem
* @param string $title
* @param array $attributes
* @param string $caret
* @param bool $caret
*
* @return \Knp\Menu\ItemInterface
*/
Expand Down
5 changes: 4 additions & 1 deletion Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
trait StateFullRepositoryTrait
{
/**
* @var QueryBuilder
*/
protected $qb;

/**
Expand Down Expand Up @@ -65,7 +68,7 @@ public function clearInstance()
* Run active query.
*
* @param string $method The method to run
* @param string $hydrationMode How the results will be (Object ? Array )
* @param int $hydrationMode How the results will be (Object ? Array )
* @param bool $autoClear AutoClear means reset active instance
*
* @return array()
Expand Down
3 changes: 2 additions & 1 deletion Bundle/CoreBundle/Resources/config/assetic_injector.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"victoire-head":
[
"@VictoireCoreBundle/Resources/public/vendor/jquery/1.10.2/jquery-1.10.2.js",
"@VictoireCoreBundle/Resources/public/js/jquery.noConflict.js"
"@VictoireCoreBundle/Resources/public/js/jquery.noConflict.js",
"@VictoireCoreBundle/Resources/public/js/vic-intercooler.js"
],
"modernizr":
[
Expand Down
11 changes: 7 additions & 4 deletions Bundle/CoreBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
services:

# ================== Widgets ================== #

victoire_core.entity_proxy.fields_builder:
class: Victoire\Bundle\CoreBundle\Form\Builder\EntityProxyFieldsBuilder
arguments:
Expand All @@ -15,6 +17,7 @@ services:
- { name: doctrine.event_subscriber, connection: default }

# ================== MENU ================== #

victoire_core.admin_menu_builder:
class: Victoire\Bundle\CoreBundle\Menu\MenuBuilder
arguments: [ '@knp_menu.factory', '@security.authorization_checker' ]
Expand Down Expand Up @@ -66,6 +69,7 @@ services:
- { name: kernel.event_listener, event: kernel.controller, method: preExecuteAutorun }

# ================== Twig ================== #

victoire_core.twig.cms_extension:
class: Victoire\Bundle\CoreBundle\Twig\Extension\CmsExtension
arguments:
Expand Down Expand Up @@ -122,15 +126,15 @@ services:
tags:
- { name: kernel.event_subscriber }


# ================== Cache =================== #

victoire_core.cache_warmer.entity_proxy_warmer:
class: Victoire\Bundle\CoreBundle\CacheWarmer\EntityProxyWarmer
arguments:
- "@victoire_core.helper.business_entity_helper"
- "@file_locator"
tags:
- { name: kernel.cache_warmer, priority: 100} #Must be lower than victoire_business_entity.warmer
- { name: kernel.cache_warmer, priority: 100} # Must be lower than victoire_business_entity.warmer

victoire_core.entity_proxy.cache_driver:
class: Victoire\Bundle\CoreBundle\CacheWarmer\EntityProxyCacheDriver
Expand Down Expand Up @@ -161,7 +165,6 @@ services:

# ================== View ================== #


victoire_core.view_helper:
class: Victoire\Bundle\CoreBundle\Helper\ViewHelper
arguments:
Expand All @@ -188,7 +191,6 @@ services:
victoire_core.current_view:
class: Victoire\Bundle\CoreBundle\Helper\CurrentViewHelper


twig.extension.routing:
class: 'Victoire\Bundle\CoreBundle\Twig\Extension\RoutingExtension'
public: false
Expand Down Expand Up @@ -217,6 +219,7 @@ services:
- { name: data_collector, template: 'VictoireCoreBundle:Profiler:widget_cache', id: 'victoire_core.victoire_collector', priority: 200 }

# ================== Repositories ================== #

victoire.repository.error_page:
class: Doctrine\ORM\EntityRepository
factory: ['@doctrine.orm.default_entity_manager', getRepository]
Expand Down
10 changes: 2 additions & 8 deletions Bundle/CoreBundle/Resources/public/js/edit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ function openModal(url) {
if (false === response.success) {
warn(response.message, 10000);
} else {
//remove the previous instance of the modal
$vic('#vic-modal').remove();
//add the html of the modal
$vic('body').append(response.html);
//display the modal
$vic('#vic-modal').vicmodal({
keyboard: true,
backdrop: false
});
$vic('#vic-modal-container').html(response.html);
eval("VicIntercooler.processNodes($vic('#vic-modal-container'));");
}
loading(false);
$vic(document).trigger('victoire_modal_open_after');
Expand Down
Loading

0 comments on commit ea690cc

Please sign in to comment.