apy / apybreadcrumbtrailbundle Goto Github PK
View Code? Open in Web Editor NEWGenerate a dynamic Twig breadcrumbs trail via Annotations, PHP Attributes or PHP methods.
Generate a dynamic Twig breadcrumbs trail via Annotations, PHP Attributes or PHP methods.
Hello,
I've been using the bundle in a Symfony2 project and I'm now trying to implement it in a Symfony5 project. It works great but I'm a bit confused about the overriding of the default template.
Looking through the others issues, I'm not even sure if the bundle supports Symfony 4/5. After trying different things, I'm asking for a little help.
I tried to follow the documentation : https://github.com/APY/APYBreadcrumbTrailBundle/blob/master/src/Resources/doc/override_template.md, but it's not up to date for Symfony5 as the config/config.yml file does not exist anymore. It should be replaced by a "apy_breadcrumb_trail.yaml" file, with the same config inside.
Not a big deal, I did it, but now I've got an error saying that Twig cannot find my template. I tried different syntaxes :
The last one actually works... but it use the default template, not mine.
Following the Symfony documentation, I've put my template in tempaltes/APYBreadcrumbTrailBundle/Resources/views/breadcrumbtrail.html.twig (https://symfony.com/doc/current/bundles/override.html#templates) but nothing ever works.
I'm using the following versions :
Anyone can tell me what I am missing here ? The bundle documentation is still written for Symfony 2, so it's quite confusing.
Thanks a lot !
Hi
the parameter $route
dissapeared in 6f4a45372d1c684cd5b4cea545712e6563f04e7d line 70.
This breaks automatic transform @annotation to #[Attribute] with Rector for users that use that parameter
TwigEngine is deprecated in Symfony 4.3
/**
* This engine knows how to render Twig templates.
*
* @author Fabien Potencier <[email protected]>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TwigEngine implements EngineInterface, StreamingEngineInterface
{
Since APYBreadcrumbTrailBundle uses Twig anyway:
<service id="apy_breadcrumb_trail.twig.extension" class="%apy_breadcrumb_trail.twig.extension.class%">
<argument type="service" id="apy_breadcrumb_trail" />
<argument type="service" id="twig" />
<tag name="twig.extension" />
</service>
(by the name twig.extension
, it should just take the twig service, wich solves the problem).
/**
* BreadcrumbTrailExtension constructor.
* @param Trail $trail
* @param Environment $templating
*/
public function __construct(Trail $trail, Twig\Environment $templating)
{
$this->trail = $trail;
$this->templating = $templating;
}
I found the reason, because the symfony3.4 future versions, the way to configure the service has been changed, but now I do not know how to solve this problem!
Breadcrumb is working fine when browsing pages, but not in functional test.
When there is only one page to display, it works fine. But if for example i try to go to the login page, connect the user and display an other page, i still have the breadcrumb from the login page in addition of the breadcrumb from the current page...
It would be useful to have tags of the bundle, in order to be able to download the last stable version with our project.
What do you think?
Is it possible to override custom APYBreadcrumbTrailBundle::breadcrumbtrail.html.twig template ?
First, thanks for this amazing bundle. I have a suggestion that could be implemented:
There is an attribute to reset the Breadcrumb called: ResetBreadcrumbTrail. There could be another attribute that recieves the name of a route by parameter and continues the trail of an already declared Breadcrumb in that route.
This will help a lot because changes in a parent in the breadcrumb wouldn't break all the breadcrumbs in its descendants.
Is it possible to update symfony/deprecation-contracts to 3.*?
Currently v2.4 is preventing other packages from updating, e.g. api-platform:
Hello is there any way to specify different breadcrumb for each route, when there r multiple on one action?
Hi everyone!
I simply installed the bundle but had this error:
Argument 1 passed to Twig\Environment::getTemplateClass() must be of the type string, null given, called in /var/www/election/vendor/twig/twig/src/Environment.php on line 309
In Resources/config/services.xml the setter injection should set the template property in APY\BreadcrumbTrailBundle\BreadcrumbTrail\Trail with the default template.
The apy_breadcrumb_trail.template is well defined (checked with bin/console debug:container --parameters).
I xdebugged it and the setter is never called.
I suspect the autowire="true" option to be part of the problem because I tried to set autowire="false" on the apy_breadcrumb_trail service definition only and debugging that service with bin/console debug:container APY\BreadcrumbTrailBundle\BreadcrumbTrail\Trail
show the service is autowired.
I checked other bundle with setter injection like the standard symfony/twig-bundle and its setters are well called (but that bundle doesn't use autowiring).
My symfony version: 5.0.11 (so I'm stuck with the last version 1.6 of this bundle).
I read that you test the updates in other closed issue so maybe I got something wrong.
Hi,
I just installed your bundle (look like nice :)), but i have a problem when i used it :
That's what i did to have this error, maybe I missed something ... (I'm on a SF 4.4 project):
What I did wrong ? what I missed ? thank you.
It seems that your annotation class is executed before the ParamConverter
.
The request is not modified and we can not access the real entity.
(by the way I did not manage to call the request argument either ? )
Hi,
I tried the master branch in my sf6.1/ php8.1 app and it seems running perfectly.
will you tag this version ?
regards
The following code doesn't work as intended:
#[Route('/{id}', name: 'inicio')]
#[Breadcrumb(title: "{convocatoria}" , routeName:'concursotraslados_inicio', routeParameters: ['id' => '{id}'])]
public function inicio(Convocatoria $convocatoria) : Response
{
Instead of showing __tostring of the object "convocatoria" it renders as "{convocatoria}" (literal), here is a image:
In the documentation, @ParamConverter is referenced. But that is deprecated and I undestand it shouldn't be used.
Is there an alternative way to do this?
see #64 (comment)
trigger_deprecations
on BreadcrumbListener
when annotations were foundsee
Should we only trigger these deprecations in case PHP 8 is used (and thereby attributes are available)?
Hi,
When using this bundle in symfony 3.4+ you get a deprecation warning.
User Deprecated: The "apy_breadcrumb_trail" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.
Is this bundle still being supported or should I replace it with something else ?
After updating the symfony deprecation-contracts to 2.4 I get these notices:
Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" in "(...)\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection/../Resources/config\services.xml" is deprecated.
and
Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the node "deprecated" in "(...)\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection/../Resources/config\services.xml" is deprecated.
It seems that services.xml is missing the mentioned tags "package" and "version".
... deleted
Hi, could you please tag a new release (for the SF 3 compatibility fixes). Thanks!
Hello,
I am trying to understand how to avoid the translation of strings from the database. Indeed we obtain "missing translations" in the profiler for each entity.
Do you have a solution ?
We tried to pull the latest tag (1.5.3
) via composer a few hours (~10) after it was released to no avail. We reached packagist on twitter, and it looks like the web hook is not configured to push Github updates to packagist (cf. https://twitter.com/AnonTjamps/status/1191796313299570694).
I'm using Symfony 5.1 for a project when i use route parameter in annotation like @breadcrumb("myroute", route={"name"="my_route"}) it's not working. But If i remove(rename) the services.xml in the bundle's config folder, it's work.
Now if i use in annotations variable parameter like @breadcrumb('{User}"), it doesn't work as because services.xml is requested.
I tried to watch in code, but my knowledges is not enought with bundle configuration.
Now if i'm click on a link on my page, now services.xml is requested again
I think something in services.xml is deprecated and something happened with cache
If you'll can solve this bug, it will be super. Your bundle is probably the best for breadcrumbs generation.
Best regards
I'm getting some deprecation notices from the debug toolbar of Symfony framework:
DEPRECATED - Using an instance of "Twig_Function_Method" for function "apy_breadcrumb_trail_render" is deprecated. Use Twig_SimpleFunction instead.
Can you fix this please in order to make it future compatible?
Above all your work is great, its very suitable for me, but I just encountered a problem.
In your example we can add route parameter in annotation like :
@Breadcrumb("Level 4b", route={"name"="level_4b", "parameters"={"var1"=1,"var2"=2}})
How can I dynamically add like "id" or "slug" as parameter in route?
"parameters"={"id"="$id"}
or
"parameters"={"id"="{id}"}
both not work :(
I tried to add this bundle to composer but it says its not compatible with symfony 3.0
Hi,
I've started using this bundle on my SF2.8 app, using annotations. I'm facing this weird issue : the first time I display the page, everything works great. But if I refresh the page, I get the following error
Circular reference detected for service "templating", path: "templating -> twig -> apy_breadcrumb_trail.twig.extension".
Here is my PHP code
/**
* @Breadcrumb("home", route={"name"="home"})
*/
class MyController extends Controller
{
/**
* @Route("/var", name="var")
* @Method({"GET"})
* @Breadcrumb("var", route={"name"="var"})
* @Template()
*/
public function varAction($var)
{
// mycode
return [''var' => $var];
}
}
I'm also overriding the template but only to ass some Micro Data...
Any clue ?
Hi,
First of all i would like to thank you for this bundle.
I found a bug in the 1.7 version.
If you try to access to the object property and the class toString method does not exist you get an error.
exemple :
#[Breadcrumb("{book.title}")]
-> Object of class App\Entity\Book could not be converted to string
The issue is in the Trail.php file line 103 :
$objectValue = (string) $object;
it should be something like
$objectValue = get_class($object);
Best regards
Do you have room for an additional developer in the APY organization?
After updating to Symfony 6.3, we get the following deprecation warnings with version 1.9.2 of this package.
Method "Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load()" might add "void" as a native return type declaration in the future. Do the same in implementation "APY\BreadcrumbTrailBundle\DependencyInjection\APYBreadcrumbTrailExtension" now to avoid errors or add an explicit @return annotation to suppress this message.
Method "Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder()" might add "TreeBuilder" as a native return type declaration in the future. Do the same in implementation "APY\BreadcrumbTrailBundle\DependencyInjection\Configuration" now to avoid errors or add an explicit @return annotation to suppress this message.
I found another tiny bug
you cannot use this annotation to reset the trail cause in the constructor signature $title as no default value
#[Breadcrumb()] ->Too few arguments to function APY\BreadcrumbTrailBundle\Annotation\Breadcrumb::__construct()
Workaround: pass null
#[Breadcrumb(null)]
null
, error on v2Master branch is broken on php8 / symfony, the % sign is not supported in the deprecation message: symfony/symfony#40630.
The problem is in services.xml, i would submit a PR, but im out of the office ๐
The service "apy_breadcrumb_trail.twig.extension" has a dependency on a non-existent service "templating".
Being able to dynamically pass parameters to the breadcrumbs because of the @ParamConverter
is really awesome.
These parameters could come in really handy if they also should be passed to the Twig trans
filter. That way we can use a translation key as the breadcrumb label, and use the parameters in the actual translation.
Would also be nice to configure the translation domain
via an option in the Twig renderer. So something like an OptionResolver
and some extra default configuration parameters would be nice.
Hi,
I find an issue when we removed the deprecated sensioExtraFramework.
The $request->attributes does not have the entity name ($varName) property.
So it can't resolve the title like {user.username}.
I think i can decorate an event to fix add it but it seems a bad solution.
Best regards
I'm customizing the error template and want to add display a breadcrumb. Let's say for the 404-page, it should be:
Home > 404 page.
Is it possible to call your bundle in a template to add objects to the trail, if so, could you give an example?
When attempting to update to the latest version of Symfony, I encounter the following error:
PHP Fatal error: Declaration of APY\BreadcrumbTrailBundle\DependencyInjection\Configuration::getConfigTreeBuilder() must be compatible with Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder(): Symfony\Component\Config\Definition\Builder\TreeBuilder in appName\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection\Configuration.php on line 19
Fatal error: Declaration of APY\BreadcrumbTrailBundle\DependencyInjection\Configuration::getConfigTreeBuilder() must be compatible with Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder(): Symfony\Component\Config\Definition\Builder\TreeBuilder in appName\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection\Configuration.php on line 19
Symfony\Component\ErrorHandler\Error\FatalError^ {#3256
#message: "Compile Error: Declaration of APY\BreadcrumbTrailBundle\DependencyInjection\Configuration::getConfigTreeBuilder() must be compatible with Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder(): Symfony\Component\Config\Definition\Builder\TreeBuilder"
#code: 0
#file: "appName\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection\Configuration.php"
#line: 19
-error: array:4 [
"type" => 64
"message" => "Declaration of APY\BreadcrumbTrailBundle\DependencyInjection\Configuration::getConfigTreeBuilder() must be compatible with Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder(): Symfony\Component\Config\Definition\Builder\TreeBuilder"
"file" => "appName\vendor\apy\breadcrumbtrail-bundle\src\DependencyInjection\Configuration.php"
"line" => 19
]
}
Is it possible to add hash-fragment to breadcrumb route? Ex. /product/{id}#photos
After updating to PHP 8.1 the following warnings are issued:
Deprecated: Return type of APY\BreadcrumbTrailBundle\BreadcrumbTrail\Trail::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor\apy\breadcrumbtrail-bundle\src\BreadcrumbTrail\Trail.php on line 199
Deprecated: Return type of APY\BreadcrumbTrailBundle\BreadcrumbTrail\Trail::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor\apy\breadcrumbtrail-bundle\src\BreadcrumbTrail\Trail.php on line 191
Given PHP 8.0 will be the minium PHP version for v2, running a Rector upgrade script will always upgrade the annotations to attributes.
This idea came up during the PHPWVL talk where Tomas Votruba held a talk about including effortless upgradeability as a Composer Plugin, and is a follow-up of the discussion in #72
route
array values to routeName
, routeParameters
, routeAbsolute
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(AnnotationToAttributeRector::class)->call('configure', [
[
AnnotationToAttributeRector::ANNOTATION_TO_ATTRIBUTE => ValueObjectInliner::inline([
new AnnotationToAttribute(\APY\BreadcrumbTrailBundle\Annotation\Breadcrumb::class),
]),
],
]);
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.