In symfony 2 documentation, they talked about adding ACLs but how can I remove them? When users or objects gets removed for example?
UPDATE
I was looking at the source Symfony\Component\Security\Acl\Dbal\AclProvider, but I didn't find functions like updateAcl, so perhaps thats not the class? Where can I find outr what class Symfony uses and use the approperiate function to remove ACE?
I recently wrote up a small blog post on this with a simple ACL Manager class to help with the ACL layer.
Check it out at http://blog.codingninja.com.au/2011/12/revoke-acl-permissions-in-symfony/
The class shuld be Symfony\Component\Security\Acl\Dbal\MutableAclProvider. The delete method is public void deleteAcl(ObjectIdentityInterface $oid)
http://api.symfony.com/2.0/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.html#method_deleteAcl
Related
I have a rest api on a symfony project using FOSRest and JMSSerializer.
I want to exclude one of the properties of the objects in the cgetObjectAction (api/my-objects) method but leave it on the single get endpoint (api/my-objects/1).
I've been reading and I came accross the possibility to use groups for the JMS Serializer https://jmsyst.com/libs/serializer/master/reference/annotations (I'm already familiar with the possibility of excluding/exposing a var in every method)
But my question is, how can I specify in the cgetObjectAction method to use the group I define (i.e. collection and single).
Thanks in advance
I'm a bit late, but in case someone needs an answer, here is some help.
To specify the group you want to use, you need to add this in the View annotation of your controller :
#JMS\View(serializerGroups={"YOUR_GROUP_NAME"})
And don't forget to add the use statement :
use FOS\RestBundle\Controller\Annotations as JMS;
This seems like it should be the most basic thing to do, but I cannot find any info on it. If bundle defines multiple services, how can I override single service with my own?
For example if I have one bundle with defined service, which is being used by another services of that bundle, because it implements certain interface:
myapp_user.user.factory:
class: MyApp\UserBundle\User\UserFactory
arguments: ["#myapp_user.user.config_manager"]
I would like to override this service with my own, like that:
myapp_user.user.factory:
class: MyApp2\UserBundle\User\UserFactory
arguments: ["#myapp_user.user.config_manager"]
I thought that it should be very simple, isn't the whole container idea about - being able to easily switch services/dependencies? However I cannot find any information on it. There is information about creating "parent" bundle, and overriding "file with definition of services", but nothing about single services. Am I missing something? I really don't want to use "parent bundle" thing for replacing just one service with my own.
Thanks to Raphaƫl MaliƩ I figured out the answer. The problem was indeed with the order of imports of files with declared services. Silly me :) .
Here is the context :
Each user of my application belongs to a company.
Parameters for each company are defined inside "company.yml" configuration files, all of them sharing the exact same structure.
These parameters are then used to tweak the application behavior.
It may sound trivial, but all I'm looking for is the proper way to load these specific YAML files.
From what I understood so far, using an Extension class isn't possible, since it has no knowledge about current user.
Using a custom service to manage these configurations rather than relying on Symfony's parameters seems more appropriate, but I can't find how to implement validation (using a Configuration class) and caching.
Any help would be greatly appreciated, thanks for your inputs!
Using the Yaml, Processor and Configuration components of Symfony2 should fit your needs.
http://symfony.com/doc/current/components/yaml/introduction.html
http://symfony.com/doc/current/components/config/definition.html
Define your "CompanyConfiguration" class as if you were in the DependencyInjection case
Create a new "CompanyLoader" service
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Config\Definition\Processor;
$companies = Yaml::parse('company.yml');
$processor = new Processor();
$configuration = new CompanyConfiguration();
$processor->processConfiguration($configuration, $companies);
Now you should be able to use your companies array to do what you want
Have a look at http://symfony.com/doc/current/cookbook/configuration/configuration_organization.html as well as http://symfony.com/doc/current/cookbook/configuration/environments.html. If that's not the correct answer you'll have to be more specific on what your company.yml configuration contains.
I'm working on a project and I'd like to ask for a clean/best way to override the steps in the
Sylius\Bundle\CoreBundle\Checkout\CheckoutProcessScenario
I'd like to preserve the custom mechanics of the whole process just add a custom step at the end and remove the finalize step.
$builder
->add('security', 'sylius_checkout_security')
->add('addressing', 'sylius_checkout_addressing')
->add('shipping', 'sylius_checkout_shipping')
->add('finalize', 'sylius_checkout_finalize')
->add('payment', 'sylius_checkout_payment')
->add('purchase', 'sylius_checkout_purchase')
;
What's the best form of doing so? If it's extending the bundle and overwriting it I'd like some help with that of at least some information to point me in the right direction - currently I'm not getting any results on my own.
I've read the docs on the bundle itself but it doesn't explain how to override the built in process.
I've also read the symfony cookbook on extending resources:
http://symfony.com/doc/2.0/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-translations-validation-etc
and:
http://symfony.com/doc/current/cookbook/bundles/override.html
If anyone has some experience on the topic and would like to share thier insights I'd be very gratefull. Thanks in advance.
You could change the service class to a custom one.
You can overwrite the parameter sylius.checkout_scenario.class.
app/config/config.yml:
<parameter key="sylius.checkout_scenario.class">
Your\Class
</parameter>
I've done it a bit different but still the point was good :)
What I've done is use the service compiler to override it with my own class and override the original file. The basics are explained here:
http://symfony.com/doc/current/cookbook/bundles/override.html
in the Services & Configuration section :)
Then I just had to include the compiler pass
// src/Acme/ShopBundle/AcmeShopBundle.php
namespace Acme\ShopBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Acme\ShopBundle\DependencyInjection\Compiler\CustomCompilerPass;
class AcmeMailerBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new CustomCompilerPass());
}
}
Inside the compiler pass I just extended the base file and overwrote the function I needed. Droppin it by in case anyone needs to pointed in the right direction.
I want to audit-trail all changes made to dataobjects. Say I have Event dataobject and I want to know who changed it, when changed, what is changed etc. (Similar to Pages).
Silverstripe site recommends the use of Verioned but I can't find any examples of implementation. It says the best example is Pages which is is already comes with Versioned implemented. The basic rule is to define an augmentDatabase() method on your decorator.
So, I want to use DataExtention for dataobject (extension) and then use the extended one for my Event dataobject. But is there any simple example?
Assuming you want to manage and monitor multiple versions of the event DataObject, you simply need to declare that you want to use the versioned extension for thatDataObject
Class Event extends DataObject{
static $extensions = array(
"Versioned('Stage', 'Live')"
);
...
}
Then run a dev/build
You should now have a Event, Event_Live, and Event_versions tables.
You can then have a look at the methods available in Versioned.php, and use them with Event, ie publish(). This should get you started.
"Versioning in SilverStripe is handled through the Versioned class. It's a DataExtension, which allow it to be applied to any DataObject subclass."
"Similarly, any subclass you create on top of a versioned base will trigger the creation of additional tables, which are automatically joined as required."
Here is link to read further with examples
Versioning of Database Content