I already have model file, but that model doesn't have any test or test fixtures currently. Is there a command in cake console, that would generate test and test fixtures based on already created model. I'm using cakePhP 2.9.
Thank you!
I was able to create following files wit following commands.
cake bake test model "modelName"
cake bake fixture "modelName"
Related
Trying to bake my controllers from a custom template.
As per the cookbook, I've baked a new plugin, and created the following directories:
plugins/MyTemplate/src/Template
plugins/MyTemplate/src/Template/Bake
plugins/MyTemplate/src/Template/Bake/Controller
plugins/MyTemplate/src/Template/Bake/View
In Bake/View I've created the basic CRUD templates, and they're baking fine. In Bake/Controller I've created a controller.twig file. It appears to be ignored. What am I missing?
Using CakePHP 2.6.7
When baking a normal part of an application (e.g. using cake bake model) the console is interactive - it goes through the construction process asking for you to choose options at each stage.
But when using cake bake model MyModel --plugin MyPlugin to do the same for a plugin no options are displayed and it generates the model in the plugin folder using default settings.
Is there a way to make the generation of the individual parts of a plugin interactive in the same manner? (this goes for model/controller/view)
When a model in a plugin is baked using cake bake model MyModel --plugin MyPlugin it uses scaffolding. To avoid this you have to use cake bake model --plugin MyPlugin and then the first option presented will allow you to choose from the possible models to be baked.
Replace model with controller/view as appropriate to bake those as well.
I am developing a plugin in CakePHP 2.x, and I want to translate the error messages from the models.
I was reading the documentation, but its no clear about how extract exactly.
I changed the domain for my models with:
$validationDomain = 'validation_errors';
so cakephp made a validation_errors.pot file.
I have two folders, 'spa' and 'eng', with 'LC_MESSAGES' into them, and 'manager.po' file where I put the translations for my plugin (with the same name).
Where I have to make the .po file from validation_errors.pot? and how I have to name it?
Thanks!
I have a Task model and project model, tasks belongTo a project, what i wish to do is on the afterSave in the task model, update a field in the project model, but im having trouble i've tried using $this->Task->Project->Find(), with no joy. thanks.
You're probably looking for saveAll().
http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveall-array-data-null-array-options-array
Side note: why would you expect 'find()' to save your data?
I've developed a bug tracker using CakePHP 2.4.4. I made this as a standalone cakephp app but now I wanna transfer it to a plugin, in order to reuse it in other projects.
As I already read at the docs (http://book.cakephp.org/2.0/en/plugins.html), I have followed the instructions from there and created the correct folder and files structure. This is what i've done so far: https://github.com/lubbleup/BugCake/tree/plugin
But now,when i try to use the plugin in a separate cakephp installation, I cannot understand how to make of the plugin and, for example, use it's controllers and functionality etc.
can anyone help me out here?
ps:this is my first time trying to create a cakephp plugin
Thank you in advance!
You have to load the plugins your parent app in APP/Config/bootstrap.php
CakePlugin::loadAll();
You do not need AppModel or AppController in your plugin. Your plugin has an own AppController/-Model named PluginNameAppController/PluginNameAppModel.
You can call your plugin at http://host/plugin_name/controller/action/[...]. In your case http://host/bug_cake/issues/view/1 for instance.
But you can also use custom routes in your plugin with plenty of options.
Hope that answers your question—if not, comment.