本文整理汇总了PHP中PropelObjectCollection::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP PropelObjectCollection::getModel方法的具体用法?PHP PropelObjectCollection::getModel怎么用?PHP PropelObjectCollection::getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropelObjectCollection
的用法示例。
在下文中一共展示了PropelObjectCollection::getModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
示例2: __construct
/**
* 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);
}