/** * Constructor. * * @param \PropelObjectCollection $entries * @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $objectIdentity * @param \Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface $permissionGrantingStrategy * @param array $loadedSecurityIdentities * @param \Symfony\Component\Security\Acl\Model\AclInterface $parentAcl * @param bool $inherited */ public function __construct(\PropelObjectCollection $entries, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true) { if ($entries->getModel() !== $this->model) { throw new AclException(sprintf('The given collection does not contain models of class "%s" but of class "%s".', $this->model, $entries->getModel())); } foreach ($entries as $eachEntry) { if (null === $eachEntry->getFieldName() and null === $eachEntry->getObjectIdentityId()) { $this->classAces[] = new Entry($eachEntry, $this); } if (null !== $eachEntry->getFieldName() and null === $eachEntry->getObjectIdentityId()) { if (empty($this->classFieldAces[$eachEntry->getFieldName()])) { $this->classFieldAces[$eachEntry->getFieldName()] = array(); $this->updateFields($eachEntry->getFieldName()); } $this->classFieldAces[$eachEntry->getFieldName()][] = new FieldEntry($eachEntry, $this); } if (null === $eachEntry->getFieldName() and null !== $eachEntry->getObjectIdentityId()) { $this->objectAces[] = new Entry($eachEntry, $this); } if (null !== $eachEntry->getFieldName() and null !== $eachEntry->getObjectIdentityId()) { if (empty($this->objectFieldAces[$eachEntry->getFieldName()])) { $this->objectFieldAces[$eachEntry->getFieldName()] = array(); $this->updateFields($eachEntry->getFieldName()); } $this->objectFieldAces[$eachEntry->getFieldName()][] = new FieldEntry($eachEntry, $this); } } $this->objectIdentity = $objectIdentity; $this->permissionGrantingStrategy = $permissionGrantingStrategy; $this->parentAcl = $parentAcl; $this->inherited = $inherited; $this->loadedSecurityIdentities = $loadedSecurityIdentities; $this->fields = array_unique($this->fields); }
/** * Form constructor. * * Available options: * - embedded_form_class: The class name of the forms to embed. Uses the model name by default. * (a form based on a collection of Book objects embeds BookForm objects) * - item_pattern: The pattern used to name each embedded form. Defaults to '%index%'. * - add_delete: Whether to add a delete widget for each object. Defaults to true. * - delete_name: Name of the delete widget. Defaults to 'delete'. * - delete_widget: Optional delete widget object. If left null, uses a sfWidgetFormDelete instance. * - alert_text: The text of the Javascript alert to show * - hide_parent: Whether to hide the parent form when clicking the checkbox * - parent_level: The number of times parentNode must be called to reach the parent to hide. * Recommended values: 6 for embedded form, 7 for merged form * - remove_fields: The list of fields to remove from the embedded object forms * * @param PropelCollection $collection A collection of Propel objects * used to initialize default values * @param array $options An array of options * @param string $CSRFSecret A CSRF secret (false to disable CSRF protection, null to use the global CSRF secret) * * @see sfForm */ public function __construct($collection = null, $options = array(), $CSRFSecret = null) { $options = array_merge(array( 'item_pattern' => '%index%', 'add_delete' => false, 'delete_name' => 'delete', 'delete_widget' => null, 'remove_fields' => array(), ), $options); if (!$collection) { $this->model = $options['model']; $collection = new PropelObjectCollection(); $collection->setModel($this->model); $this->collection = $collection; } else { if (!$collection instanceof PropelObjectCollection) { throw new sfException(sprintf('The "%s" form only accepts a PropelObjectCollection object.', get_class($this))); } $this->collection = $collection; $this->model = $collection->getModel(); } $this->isEmpty = $this->getCollection()->isEmpty(); parent::__construct(array(), $options, $CSRFSecret); }