CakePHP 3.0 / DebugKit Plugin Element Override - php

I am trying to override the template file for the environment panel in the CakePHP 3.0 DebugKit. The file is located at
app/vendor/cakephp/debug_kit/src/Template/Element/environment_panel.ctp
According to the docs, placing my own file at
app/src/Template/Plugin/cakephp/debug_kit/Element/environment_panel.ctp
should automagically display my template instead of the plugin's, however, my file is being ignored. I've tried leaving out the cakephp directory, and using camel case for the vendor/plugin names. What am I doing wrong?

After two more hours of experimentation I found the correct path:
app/src/Template/Plugin/DebugKit/Element/environment_panel.ctp
To clarify the confusion I had: the debug kit is not considered a composer/vendor-type plugin mentioned in the docs I linked in the question, so it doesn't need the ../cakephp/.. intermediate directory.
Additionally, the directory needed to be CamelCased instead of copied verbatim from the vendor directories.
ALSO: in apparent conflict with the Element docs, you CAN override a plugin element without setting the ['plugin' => false] option.

Related

Editing bootstrap.php to customize Dotenv behaviour

I'm not satisfied by the Symfony Dotenv default behaviour, because I would like to have i.e. a .env.override which would override existing environment values.
So I would like to add the following code in config/bootstrap.php
$envLocal = dirname(__DIR__).'/.env.override';
if (file_exists($envLocal)) {
(new Dotenv(false))->overload($envLocal);
}
Is it a problem to edit this file (config/bootstrap.php)? Can it be erased by future Symfony updates?
You can modify bootstrap.php to your heart's content.
The file is created when you run create-project symfony/skeleton, but it's part of your application files (it's not a dependency), so it's your responsibility to maintain it, and use it as you see fit.
Actually, if you upgraded your application to a version of Symfony that expected a different behaviour of bootstrap.php (or public/index.php, or (bin/console) you may need to update these files (among others).

unable to find template, after generating bundle

ok this might be a very strange thing.
it's not the first time I work a symfony project but:
I used the symfony generate:bundle command and after that I created a bundle. Lets call it "CrimeBundle".
I saw it made a folder inside the src/
It also made automatically a DefaultController and an index.html.twig file.
Now whenever I use:
return $this->render('CrimeBundle:Default:index.html.twig');
it doesn't work: I get the error:
Unable to find template "CrimeBundle:Default:index.html.twig" (looked into: /Users/admin/sites/solve/app/Resources/views, /Users/admin/sites/solve/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
however it works whenever I use the namespaced twig path like:
return $this->render('#Crime/Default/index.html.twig');
I like the first option, because on my other projects I use it too. None of them are the same version, currently I use: 3.4.1
Again the file is there, because it works with namespaced twig paths.
I can't understand why return $this->render('CrimeBundle:Default:index.html.twig'); wouldn't work as symfony generated this code.
According to this - https://symfony.com/doc/3.4/templating.html#referencing-templates-in-a-bundle
That's the only reference type the support for bundle templates
#BundleName/directory/filename.html.twig
If you go to docs for symfony 3.1 you'll see that was the last version that supported old reference
AcmeBlogBundle:Blog:index.html.twig
Maybe you can create a pull request for this file
SensioGeneratorBundle/bundle/DefaultController.php.twig

Symfony 1.4 - Doctrine - Custom Plugin - How do I get plugin model files to reside in plugin directory?

I am creating a custom plugin, and am trying to keep all related model files contained within the plugin directory structure. However, when I build the model, some files get dropped into lib/model/doctrine/... and others in plugins/userPlugin/lib/model/... . According to Doctrine docs I can add a "package" option to the schema.yml file, and generated model files will be created in the location as defined by my dot-notation entry, for example:
# plugins/userPlugin/config/doctrine/schema.yml
connection: store-rw-user
options:
# Fully expect resulting model files to be dropped in this directory (vs the main model dir)
package: userPlugin.lib.model.doctrine
....
As mentioned, this config setup still results in model files being dropped into the main lib/model/doctrine directory. I even tried this, to no avail:
# plugins/userPlugin/config/doctrine/schema.yml
connection: store-rw-user
options:
package: userPlugin
package_custom_path: /tmp/userPlugin
....
Just wanted to see if the files were dropped in the /tmp directory, but they were not.
Before I start tearing apart the source code, I figured I would ask first, to see if there is something I am missing.
It's perfectly normal to get model files in your project directory after building. The purpose of this is to let you customize the plugin model on per-project basis, because the classes inside these files inherit from the classes defined in the plugin's files. I use plugins too, and most of the time, all the code I write resides in the plugin's model files.

Load single CakePHP plugin with App::build()

Is it possible to load a single plugin from outside the cake root using App::build()?
If I do:
App::build(array(
'Plugin' => array('/full/path/to/plugin_dir/')
));
..I can load a whole directory of plugins but what if I only want to use one of them? Is this possible? (I get errors when using a path to the specific plugin directory).
(P.s. This is cake version 2.1)
From the bootstrap.php in a baked application:
CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit
You have to add the directory with the plugin in it via App::build() and then the plugin itself with the method above.
While using "App::build()" you are not "loading" all the files in there. You are defining the paths where cake searches for php to include in case it has to.
Nothing will be loaded if it is not need since Cakephp 2.0. Everythings is about lazy loading ^^
How this is, what you are searching for ;)

ILIAS plugin development

I'm working with a learning management system called ILIAS; trying to develop a plugin for the PersonalDesktopHook [pdhk] plugin slot.
Sadly I'm stuck with deploying the simplest plugin:
Created a directory for my plugin:
ilias/Customizing/global/plugins/Services/PersonalDesktop/PluginName
Created a plugin.php file as described in the documentation (with matching id, etc.).
Created a classes/class.ilPluginNamePlugin.php file containing a ilPluginNamePlugin extending the abstract ilPersonalDesktopHookPlugin class located in
ilias/Services/PersonalDesktop/classes/class.ilPersonalDesktopHookPlugin.php
Still my plugin isn't showing up in the Services/PersonalDesktop component menu (Administration).
Did I miss something or is the plugin development documentation out of date?
(I followed the ILIAS development guide's "Implementing Plugins" section.)
This answer is late, but this seems to be a common issue in ilias plugin development. The following things should be checked:
Is the path really correct (including case of the file/folders name). In this case it isn't, it should be: ./Customizing/global/plugins/Services/PersonalDesktop/PersonalDesktopHook/PluginName . If you are unsure consult: https://www.ilias.de/docu/goto_docu_pg_27031_42.html or the xml of the corresponding service/module, in this case: ./Services/PersonalDesktop/service.xml
Check that you have a plugin.php file with the correct $id set (in this case: pdsk).
Check that your webserver has read permissions for you plugin to be listed in the administration.

Categories