I built a project with Acl enabled - I used the CakePHP tutorial on their website to do this.
However, the project no longer needs this functionality.
I've removed all reference of Acl and Aco in my controllers, models and views (if fact I did the tutorial in reverse to remove everything) and I then deleted the three database tables that were generated in this process.
However, I still get the error:
Error: Database table acos for model Aco was not found.
On all of my controllers.
Did the acl baking process add some files I don't know about? How do I get rid of this functionality?
Try emptying your app/tmp/cache. Model relations may be caches there. After that, grep through your app directory for references to Aco and Aro. You may have missed one.
Edit: Also, make sure that your Auth component does not set Auth->authorize to actions (which uses ACL) but something else appropriate. See Auth::authorize in the CakePHP manual.
Related
I'm new to Symfony and am starting an app which includes an admin section. The general advice is pretty obvious - make an AdminBundle.
However, is that really the best practice? The Symfony documentation is saying that a bundle is intended to be a 'plugin' that can be distributed as is, and will work in another app. Doesn't the admin section need to be aware of all the models and things for the main app though? It's an admin section created to administer changes specifically to my app, so how would it be distributable or self-contained?
I feel like I'm missing something because if all the advice is to make an AdminBundle then I obviously don't understand something or haven't delved far enough into Symfony yet.
I'm just looking to get my app started with the correct structure going forward.
FYI, I created a project with the default AppBundle as well. I was just planning to make everything in there, but that doesn't seem right either as it will be harder to organise all the admin stuff separately.
I think it depeneds on tour needs and size of your project. Creating a special bundle to put there logic for of admin panel is a good practice. But if you have a small application with just couple of entities it's not necessary to create AdminBundle.
Symfony provides you any way you prefer to do what you need. You can create bundle or put all the admin panel business logic into special directory inside your main bundle controller directory or put all code into the same controllers and manage permissions to admin actions by setting up firewall.
I would suggest to use AdminBundle. It lets you keep your code cleaner: a client logic in one bundle, an admin logic is in another.
Bundle description taken from symfony official documentation isn't saying any opposite things. Because if you want you can use your AdminBundle in another app. Bundle is a way to keep different kind of business logic separated of each other.
currently I'm thinking on how to implement a plugin-feature for my symfony2 application.
My goals are as following:
Basically the plugin should be a bundle (at least service, event listener, routing, entities, migrations, views and controllers need to be registerable)
The AppKernel should not be touched in any way by the end user or the application
Plugins should provide meta information (title, description, screenshot/image, author etc)
plugins should be managed from the backend (activation, deactivation, installation, deletion, update etc)
plugins may come from different sources (Core, Community, Local as in shopware maybe) and should be seperated by save path
working autoload without running composer again
My problem would be something like: How to load a bundle after the Kernel is already loaded (since the information on which plugins are active should reside inside the database ideally and not inside some file on the hard disk but may be cached).
I did not found a bundle or a cook book entry on this topic. Is there a best practice managing something like this? Maybe I'm thinking in the wrong direction.
I hope there is someone who might have a helpful idea and the kind of knowledge on symfony2 which I do not have.
PS: There is no code yet since this is just some thinking on the concept on how to handle this.
The AppKernel returns the registered bundles as an array, so assuming that the storage method you're using to determine active plugins isn't tied to Symfony (i.e. you can access it before the application is fully bootstrapped), then it should be as easy as adding something like this to your AppKernel.php:
public function registerBundles()
{
...
...
$bundles = array_merge($bundles, MyApp\PluginManager::getPluginBundles());
...
return $bundles;
}
Providing the plugin metadata could be done in various ways (maybe just a defined location / directory in the plugin files that holds txt / image files), but loading all that should be easy once you have the plugin management stuff (and can easily get the installed plugins, etc) done.
I have a problem. My client wants to have a website in one symfony framework package and the CMS integrated in the other Symfony framework (Service Panel of the company).
So, we have Symfony A and B.
Now that there is a blog on the website (Symfony A) among a few other dynamic pages. All the Delete, add and update stuff needs to go into the service panel (Symfony B) with forms and such.
I know I can use multiple Entity Managers, but that'll only work if the website bundle is placed in the service panel framework (Symfony B), because of the mappings. I think it isn't possible, but they really want to have the CMS in their Service panel and the website in another symfony framework instance.
Is there a 'remote' solution, so that Symfony B (service panel) can change and manage the database of the website (Symfony A) without migrating the website bundle (Symfony A) into Symfony B? The website will run on the same machine as the service panel will. Only difference is they are completely separated of each other.
If I'm not clear enough, please tell me. I'm trying to be as clear as possible.
Hope somebody is able to help me with the issue.
So let's say we want to update a blog.
Symfony A would process these requests:
GET /blog/42 - Returns json rep of blog 42
PUT /blog/42 - Accepts and updates blog 42
Easy enough. FOSRestBundle and JMSSerializerBundle can help with some of the plumbing.
So Symfony B uses curl (probably) to GET /blog/42 and converts the json data to a php array.
At this point you have a major decision. If the entities are simple and stable the Symfony B could just use the array representation. Symfony forms accept arrays no problem. So this maybe all you need.
If however you want to convert the array data into a real Blog object that matches Symfony A then you need to make some more decisions. The Symfony A entities are really just plain objects. You could tweak Symfony B's autoload so it can see the Symfony A entities. So B can get the entities from A (and then map the array data to the entities) without having any direct links. Autoload just needs to know where the Symfony A entities live.
Or you could go one step further and make a BlogModelBundle in which the blog entities (without any doctrine stuff) are defined. You would then have both applications load this bundle. The A app would then extend the model and add the doctrine 2 stuff. The B app would just hydrate the models using json. This is probably the best approach for the long term.
Sorry if this is a noob question, I'm using the Simple ACL Controlled Application tutorial as a boilerplate and need to add (bake) a few more tables. If I create a new table then run "cake bake all" from the console, how would I go about updating the ACL as well, I believe I should only need to update the acos table, could be wrong? Is there a command I should use after the new models, views and controllers are generated?
Thanks in advance!
EDIT : I'm using the AclExtras plugin to to input all of my controllers and actions into the Acl.
To sync up your ACO using AclExtras, you would run something like this at the command line:
php "/cake/lib/Cake/Console/cake.php" AclExtras.AclExtras aco_sync
What is the a standard way of adding new model to my app built on Symfony + Doctrine while maintaining all previous models and their meta-data (like relationships).
What am I really looking for: A command / procedure that will be equivalent of ./script/generate model FooModel in Ruby on Rails (which does not have any sort of reset db / reset models while generating)
If these two are different things, and I am chasing the wrong ghost (I would like to think I am not), please let me know.
EDIT: Updated the question.
You shouldn't be overriding the base classes, as these will be mostly be auto-generated whenever you do build:all or doctrine:build-model etc. Use the classes generated in the lib/model directory eg YourModel.class.php if you want to add new methods etc. Then your new models will be generated alongside your existing ones.
Standard process is to add the new model and any relationships it requires to schema.yml
Then do ./symfony doctrine:build-all (or :build --all for symfony 1.3/1.4)
As richsage says, you shouldn't be editing the base classes, so this operation is totally non destructive.
Doctrine also has functionality for migrations so that you an update the database schema easily as you deploy the new code into production:
http://www.doctrine-project.org/documentation/cookbook/1_0/en/symfony-and-doctrine-migrations
Newer versions of doctrine (1.1 +, symfony 1.3+) include the generate-migrations-diff task, which can create migrations for you. This is covered very well here:
Extra changeColumns in Doctrine generate-migrations-diff
[edit: the author of the question above has copy/pasted it below as well now]
The generate-migrations-diff doesn't diff two different yaml files. It actually compares your models and your yaml file and then generates a migration based on the differences. If you start from a db that is in sync with your yaml and classes, your workflow to make schema changes should be:
Change yaml file
Run generate-migrations-diff to diff your current (changed) yaml with your (unchanged) models. This will generate a migrations file in your doctrine/migrations directory (or whatever migrations_path is set to in your doctrine config).
Run migrate to run the migration created in step 2 and modify your database
Run generate-models-yaml to generate new classes based on your yaml file. These go where you've specified your generated models go (models_path in your doctrine config).
Run generate-sql to generate a SQL file. This will go where your doctrine sql_path config is set to.