Download the PHP package positibe/cmf-routing-extra-bundle without Composer

On this page you can find all versions of the php package positibe/cmf-routing-extra-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cmf-routing-extra-bundle

PositibeCmfRoutingExtraBundle

The PositibeCmfRoutingExtraBundle add Doctrine ORM support for Symfony CmfRoutingBundle to store routing on orm databses

Installation

To install the bundle just add the dependent bundles:

php composer.phar require positibe/cmf-routing-extra-bundle

Next, be sure to enable the bundles in your application kernel:

<?php
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
        new Symfony\Cmf\Bundle\RoutingAutoBundle\CmfRoutingAutoBundle(),
        new Positibe\Bundle\CmfRoutingExtraBundle\PositibeCmfRoutingExtraBundle(),

        // ...
    );
}

Configuration

Copy the configuration in your configurations packages:

# config/packages/positibe_routing
parameters:
#    locales: [es, en, fr] # Maybe you already have it configured

cmf_routing:
    chain:
        routers_by_id:
            cmf_routing.dynamic_router: 200
            router.default: 100
    dynamic:
        enabled: true
        uri_filter_regexp: "#^(?!(/css/|/js/|/admin/|/security/|/frontend/|/backend/|/public/)).*$#"
        persistence:
            orm:
                route_class: 'Positibe\Bundle\CmfRoutingExtraBundle\Entity\AutoRoute'
#        route_provider_service_id: positibe_routing.route.provider
        generic_controller: PositibeCmfRoutingExtraBundle:GenericContent:index

cmf_routing_auto:
    adapter: positibe_doctrine_orm

Caution:: This bundle use the timestampable, sluggable, translatable and sortable extension of GedmoDoctrineExtension. Be sure that you have the listeners for this extensions enable. You can also to use StofDoctrineExtensionBundle.

Remember to update the schema:

php app/console doctrine:schema:update --force

Using

An entity that has routes must implement Symfony\Cmf\Component\Routing\RouteReferrersInterface.

Add to any entity you want the relation with Positibe\Bundle\CmfRoutingExtraBundle\Entity\AutoRoute and the needed methods:

<?php
// src/AppBundle/Entity/Post.php
namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Cmf\Component\Routing\RouteReferrersInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @ORM\Table(name="app_post")
 * @ORM\Entity(repositoryClass="AppBundle\Entity\PostRepository")
 */
class Post implements RouteReferrersInterface {

    /**
     * @var ArrayCollection|RouteObjectInterface[]
     *
     * @ORM\ManyToMany(targetEntity="Positibe\Bundle\CmfRoutingExtraBundle\Entity\AutoRoute", orphanRemoval=TRUE, cascade="all")
     * @ORM\JoinTable(name="app_post_routes")
     */
    protected $routes;

    public function __construct()
    {
        $this->routes = new ArrayCollection();
    }

    /**
     * @return ArrayCollection|\Symfony\Cmf\Component\Routing\RouteObjectInterface[]
     */
    public function getRoutes()
    {
        return $this->routes;
    }

    /**
     * @param ArrayCollection|\Symfony\Cmf\Component\Routing\RouteObjectInterface[] $routes
     */
    public function setRoutes($routes)
    {
        $this->routes = $routes;
    }

    /**
     * Add a route to the collection.
     *
     * @param \Symfony\Component\Routing\Route $route
     * @return $this
     */
    public function addRoute($route)
    {
        $this->routes[] = $route;

        return $this;
    }

    /**
     * Remove a route from the collection.
     *
     * @param \Symfony\Component\Routing\Route $route
     */
    public function removeRoute($route)
    {
        $this->routes->removeElement($route);
    }
}

Tip: You can use Positibe\Bundle\CmfRoutingExtraBundle\Entity\HasRoutesTrait to simplify the implementation of RouteReferrerInterface methods and mapping. This create a many to many relation without doing nothing more.

<?php
// src/AppBundle/Entity/Post.php
namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Positibe\Bundle\CmfRoutingExtraBundle\Entity\HasRoutesTrait;
use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @ORM\Table(name="app_post")
 * @ORM\Entity(repositoryClass="AppBundle\Entity\PostRepository")
 */
class Post implements RouteReferrersInterface {

    use HasRoutesTrait;

    public function __construct()
    {
        $this->routes = new ArrayCollection();
    }
}

Creating routes

$post = new Post(); //Class that implement `Symfony\Cmf\Component\Routing\RouteReferrersInterface`
$post->setTitle('You're awesome'); //Fill datas
$manager->persist($post);
$manager->flush(); //Flush to be able to take the id of the `$post`

$contentRepository = $this->container->get('cmf_routing.content_repository');
$route = new AutoRoute(); //Class of `Positibe\Bundle\CmfRoutingExtraBundle\Entity\AutoRoute`
$route->setStaticPrefix('/you-are-awesome'); //Set the permalink of post instance
$route->setDefault(RouteObjectInterface::CONTENT_ID, $contentRepository->getContentId($post)); this set ``FQN:id`` into ``content_id``
$route->setContent($post);
$post->addRoute($route);

$em->persist($post);
$em->flush();

Content with Custom Routing

If your content implement Positibe\Bundle\CmfRoutingExtraBundle\Model\CustomRouteInterface, you can update all your routes with the selected controller, without the need of do it on each one.

[yaml]
# app/config/config.yml
positibe_cmf_routing_extra:
    controllers:
        homepage:
            _controller: [FrameworkBundle:Template:template, {template: "index.html.twig"}]
        default:
            _controller: [AppBundle:Default:index, {}]

You have the access to this config through positibe_cmf_routing_extra.route_factory.

Creating automatic routes

See on auto_routing.md.

For more information see the Symfony Cmf Routing Bundle Documentation


All versions of cmf-routing-extra-bundle with dependencies

PHP Build Version
Package Version
Requires symfony/framework-bundle Version ~2.8|~3.0
symfony-cmf/routing-bundle Version ~2.0
symfony-cmf/routing-auto-bundle Version ~2.0
doctrine/orm Version ~2.5
gedmo/doctrine-extensions Version ~2.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package positibe/cmf-routing-extra-bundle contains the following files

Loading the files please wait ....