PHP code example of secit-pl / route-injector-bundle

1. Go to this page and download the library: Download secit-pl/route-injector-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

secit-pl / route-injector-bundle example snippets


use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @InjectRoute("route_name", configuration options...);
 */
private $url;

use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

class Example
{
    /**
     * @var string
     *
     * @InjectRoute("route_name", parametersMapping={"param": "getRouteParam"});
     */
    private $url;
    
    private $routeParam = '';
    
    /**
     * @return string
     */
    public function getUrl()
    {
        return $this->url;
    }
    
    /**
     * @return string
     */
    public function getRouteParam()
    {
        return $this->routeParam;
    }
    
    /**
     * @param string $value
     */
    public function setRouteParam($value)
    {
        $this->routeParam = $value;
    }
}

$processor = $this->container->get('secit.route_injector.processor');
$exampleEbject = new Example();
$exampleEbject->setRouteParam('test');
$processor->injectRoutes($exampleEbject);

namespace ExampleBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @ORM\Table(name="example")
 * @ORM\Entity()
 */
class Example
{
    /**
     * @var string
     *
     * @ORM\Column(name="param", type="string")
     */
    private $param;

    /**
     * @var string
     *
     * @InjectRoute("route_name", parametersMapping={"param": "getParam"});
     */
    private $url;
    
    /**
     * @return string
     */
    public function getParam()
    {
        return $this->string;
    }
    
    /**
     * @param string $param
     */
    public function setParam($param)
    {
        $this->string = $param;
    }
    
    /**
     * @return string
     */
    public function getUrl()
    {
        return $this->url;
    }
}

$exampleObject = new ExampleBundle\Entity\Example();

$this->getDoctrine()->getManager()->persist($exampleObject);

namespace ExampleBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @ORM\Table(name="example")
 * @ORM\Entity()
 */
class Example
{
    ...
    
    /**
     * @var string
     *
     * @ORM\Column(name="url", type="string", length=255)
     * @InjectRoute("route_name", parametersMapping={"param": "getParam"});
     */
    private $url;
    
    ...
}

@InjectRoute("route_name", configuration options...);

@InjectRoute("route_name", parametersMapping={"param": "publicGetterMethodName"});

@InjectRoute("route_name", absolute=true);

@InjectRoute("route_name", injectIfNotEmpty=true);