本文整理汇总了PHP中PropelObjectCollection类的典型用法代码示例。如果您正苦于以下问题:PHP PropelObjectCollection类的具体用法?PHP PropelObjectCollection怎么用?PHP PropelObjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropelObjectCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例3: testTransformWithData
public function testTransformWithData()
{
$coll = new \PropelObjectCollection();
$coll->setData(array('foo', 'bar'));
$result = $this->transformer->transform($coll);
$this->assertTrue(is_array($result));
$this->assertCount(2, $result);
$this->assertEquals('foo', $result[0]);
$this->assertEquals('bar', $result[1]);
}
示例4: testSerializePropelObjectCollection
public function testSerializePropelObjectCollection()
{
$collection = new \PropelObjectCollection();
$collection->setData(array(new TestSubject('lolo'), new TestSubject('pepe')));
$json = $this->serializer->serialize($collection, 'json');
$data = json_decode($json, true);
$this->assertCount(2, $data);
//will fail if PropelCollectionHandler not loaded
foreach ($data as $testSubject) {
$this->assertArrayHasKey('name', $testSubject);
}
}
示例5: createBooks
protected function createBooks($nb = 15, $con = null)
{
BookQuery::create()->deleteAll($con);
$books = new PropelObjectCollection();
$books->setModel('Book');
for ($i = 0; $i < $nb; $i++) {
$b = new Book();
$b->setTitle('Book' . $i);
$books[] = $b;
}
$books->save($con);
}
示例6: testFromArray
public function testFromArray()
{
$author = new Author();
$author->setFirstName('Jane');
$author->setLastName('Austen');
$author->save();
$books = array(array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()));
$col = new PropelObjectCollection();
$col->setModel('Book');
$col->fromArray($books);
$col->save();
$nbBooks = PropelQuery::from('Book')->count();
$this->assertEquals(6, $nbBooks);
$booksByJane = PropelQuery::from('Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
$this->assertEquals(2, $booksByJane);
}
示例7: testConstruct
public function testConstruct()
{
$collection = new \PropelObjectCollection();
$collection->setModel('Propel\\Bundle\\PropelAclBundle\\Model\\Acl\\Entry');
$acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
$model = $this->createEntry();
$model->setAuditFailure(true);
$model->setSecurityIdentity(SecurityIdentity::fromAclIdentity($this->getRoleSecurityIdentity()));
$entry = new Entry($model, $acl);
$this->assertEquals($model->getMask(), $entry->getMask());
$this->assertEquals($model->getGranting(), $entry->isGranting());
$this->assertEquals($model->getGrantingStrategy(), $entry->getStrategy());
$this->assertEquals($model->getAuditFailure(), $entry->isAuditFailure());
$this->assertEquals($model->getAuditSuccess(), $entry->isAuditSuccess());
$this->assertEquals($this->getRoleSecurityIdentity(), $entry->getSecurityIdentity());
return $entry;
}
示例8: preremplirResponsables
/**
*
* Prérempli la notification avec des responsables (sans sauvegarder la notification).
* Si plusieurs responsables sont disponibles, un responsable 1 est pris en priorité pour remplir la notification,
* un responsable 2 est ajouté si l'adresse est la même que le premier
* Si trop de responsables sont disponibles, aucun choix arbitraire n'est fait et alors rien n'est rempli sur la notification
* Si aucun responsable n'est disponible, la notification n'est pas remplie
*
* @return boolean true ou false suivant que le remplissage a pu être effectué ou pas.
*
*/
public function preremplirResponsables() {
$traitement = $this->getAbsenceEleveTraitement();
if ($traitement === NULL) return false;
$responsable_1_coll = new PropelObjectCollection();
$responsable_2_coll = new PropelObjectCollection();
foreach ($traitement->getResponsablesInformationsSaisies() as $responsable_information) {
if ($responsable_information == null) continue;
if ($responsable_information->getNiveauResponsabilite() == '1') {
$responsable_1_coll->add($responsable_information->getResponsableEleve());
} else if ($responsable_information->getNiveauResponsabilite() == '2') {
$responsable_2_coll->add($responsable_information->getResponsableEleve());
}
//si on ne peut pas choisir les responsables, on retourne sans remplir
if ($responsable_1_coll->count() > 1) return false;
}
if ($responsable_1_coll->isEmpty() && $responsable_2_coll->count() != 1) {
//on ne peut pas choisir
return false;
}
$responsable_eleve1 = $responsable_1_coll->getFirst();
$responsable_eleve2 = $responsable_2_coll->getFirst();
if ($responsable_eleve1 != null) {
$this->setEmail($responsable_eleve1->getMel());
$this->setTelephone($responsable_eleve1->getTelPort());
$this->setAdresseId($responsable_eleve1->getAdresseId());
$this->addResponsableEleve($responsable_eleve1);
} else {
$this->setEmail($responsable_eleve2->getMel());
$this->setTelephone($responsable_eleve2->getTelPort());
$this->setAdresseId($responsable_eleve2->getAdresseId());
$this->addResponsableEleve($responsable_eleve2);
}
//on ajoute dans la liste des destinataires le resp 2 si il a la même adresse que le resp 1
if ($responsable_eleve2 != null && $responsable_eleve1 != null && $responsable_eleve2->getAdresseId() == $responsable_eleve1->getAdresseId()) {
$this->addResponsableEleve($responsable_eleve2);
}
return true;
}
示例9: addProductWhenAjaxChangeActive
public static function addProductWhenAjaxChangeActive($arg)
{
/* @var $model SProducts */
$models = $arg['model'];
/* @var $ci MY_Controller */
$ci =& get_instance();
if (!$models instanceof \PropelObjectCollection) {
$model = $models;
$models = new \PropelObjectCollection();
$models->append($model);
}
foreach ($models as $model) {
if ($model->getActive()) {
$ci->db->where('trash_url', 'shop/product/' . $model->getUrl())->delete('trash');
} else {
$array = array('trash_id' => $model->getCategoryId(), 'trash_url' => 'shop/product/' . $model->getUrl(), 'trash_redirect_type' => 'category', 'trash_type' => '302', 'trash_redirect' => shop_url('category/' . $model->getMainCategory()->getFullPath()));
$ci->db->insert('trash', $array);
}
}
}
示例10: removeFactura
/**
* @param Factura $factura The factura object to remove.
*/
public function removeFactura($factura)
{
if ($this->getFacturas()->contains($factura)) {
$this->collFacturas->remove($this->collFacturas->search($factura));
if (null === $this->facturasScheduledForDeletion) {
$this->facturasScheduledForDeletion = clone $this->collFacturas;
$this->facturasScheduledForDeletion->clear();
}
$this->facturasScheduledForDeletion[] = $factura;
$factura->setTipoPago(null);
}
}
示例11: removeUser
/**
* Remove a User object to this object
* through the user_skill cross reference table.
*
* @param User $user The UserSkill object to relate
* @return Skill The current object (for fluent API support)
*/
public function removeUser(User $user)
{
if ($this->getUsers()->contains($user)) {
$this->collUsers->remove($this->collUsers->search($user));
if (null === $this->usersScheduledForDeletion) {
$this->usersScheduledForDeletion = clone $this->collUsers;
$this->usersScheduledForDeletion->clear();
}
$this->usersScheduledForDeletion[] = $user;
}
return $this;
}
示例12: removeAgenda
/**
* @param Agenda $agenda The agenda object to remove.
*/
public function removeAgenda($agenda)
{
if ($this->getAgendas()->contains($agenda)) {
$this->collAgendas->remove($this->collAgendas->search($agenda));
if (null === $this->agendasScheduledForDeletion) {
$this->agendasScheduledForDeletion = clone $this->collAgendas;
$this->agendasScheduledForDeletion->clear();
}
$this->agendasScheduledForDeletion[] = $agenda;
$agenda->setAtencion(null);
}
}
示例13: removesfGuardUserPermission
/**
* @param sfGuardUserPermission $sfGuardUserPermission The sfGuardUserPermission object to remove.
*/
public function removesfGuardUserPermission($sfGuardUserPermission)
{
if ($this->getsfGuardUserPermissions()->contains($sfGuardUserPermission)) {
$this->collsfGuardUserPermissions->remove($this->collsfGuardUserPermissions->search($sfGuardUserPermission));
if (null === $this->sfGuardUserPermissionsScheduledForDeletion) {
$this->sfGuardUserPermissionsScheduledForDeletion = clone $this->collsfGuardUserPermissions;
$this->sfGuardUserPermissionsScheduledForDeletion->clear();
}
$this->sfGuardUserPermissionsScheduledForDeletion[] = $sfGuardUserPermission;
$sfGuardUserPermission->setsfGuardPermission(null);
}
}
示例14: removeTransaccion
/**
* @param Transaccion $transaccion The transaccion object to remove.
*/
public function removeTransaccion($transaccion)
{
if ($this->getTransaccions()->contains($transaccion)) {
$this->collTransaccions->remove($this->collTransaccions->search($transaccion));
if (null === $this->transaccionsScheduledForDeletion) {
$this->transaccionsScheduledForDeletion = clone $this->collTransaccions;
$this->transaccionsScheduledForDeletion->clear();
}
$this->transaccionsScheduledForDeletion[] = $transaccion;
$transaccion->setTipoTransaccion(null);
}
}
示例15: removesfGuardUserGroup
/**
* @param sfGuardUserGroup $sfGuardUserGroup The sfGuardUserGroup object to remove.
*/
public function removesfGuardUserGroup($sfGuardUserGroup)
{
if ($this->getsfGuardUserGroups()->contains($sfGuardUserGroup)) {
$this->collsfGuardUserGroups->remove($this->collsfGuardUserGroups->search($sfGuardUserGroup));
if (null === $this->sfGuardUserGroupsScheduledForDeletion) {
$this->sfGuardUserGroupsScheduledForDeletion = clone $this->collsfGuardUserGroups;
$this->sfGuardUserGroupsScheduledForDeletion->clear();
}
$this->sfGuardUserGroupsScheduledForDeletion[] = $sfGuardUserGroup;
$sfGuardUserGroup->setsfGuardGroup(null);
}
}