PHP code example of bubnov / twig-markers
1. Go to this page and download the library: Download bubnov/twig-markers 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/ */
bubnov / twig-markers example snippets
protected function onMarkerLink()
{
if($context = $this->findContext('App\ProjectBundle\Entity\Project'))
{
return $context->getLink();
}
return false;
}
protected function findContext($findContext)
{
$contextClass = get_class($this->context);
if($contextClass === $findContext)
{
return $this->context;
}
//Try to find requested context from provided
switch($contextClass)
{
case 'App\ReportBundle\Entity\Widget':
switch($findContext)
{
case 'App\ReportBundle\Entity\Report':
return $this->context->getReport();
break;
case 'App\ProjectBundle\Entity\Project':
return $this->context->getReport()->getProject();
break;
}
break;
case 'App\ReportBundle\Entity\Report':
switch($findContext)
{
case 'App\ProjectBundle\Entity\Project':
return $this->context->getProject();
break;
}
break;
}
return false;
}