/** * Filter the query by a related \CustomerGroup\Model\CustomerGroup object * * @param \CustomerGroup\Model\CustomerGroup|ObjectCollection $customerGroup The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCustomerGroupAclQuery The current query, for fluid interface */ public function filterByCustomerGroup($customerGroup, $comparison = null) { if ($customerGroup instanceof \CustomerGroup\Model\CustomerGroup) { return $this->addUsingAlias(CustomerGroupAclTableMap::CUSTOMER_GROUP_ID, $customerGroup->getId(), $comparison); } elseif ($customerGroup instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(CustomerGroupAclTableMap::CUSTOMER_GROUP_ID, $customerGroup->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomerGroup() only accepts arguments of type \\CustomerGroup\\Model\\CustomerGroup or Collection'); } }
/** * @covers CustomerGroupAclTool::checkAcl() * * @param CustomerGroup $customerGroup Group to test. * @param Customer $customer Customer to use for the test. * @param array $expectedRessourceAccesses A map of [expected resource => [expected accesses...], ...]. */ protected function doTestCheckAclCustomerWithGroup(CustomerGroup $customerGroup, Customer $customer, $expectedRessourceAccesses) { // add the customer to the test group $addCustomerToGroupEvent = new AddCustomerToCustomerGroupEvent(); $addCustomerToGroupEvent->setCustomerId($customer->getId())->setCustomerGroupId($customerGroup->getId()); $this->dispatcher->dispatch(CustomerGroupEvents::ADD_CUSTOMER_TO_CUSTOMER_GROUP, $addCustomerToGroupEvent); // login the customer $this->dispatcher->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer)); // assert its accesses $this->assertGroupOnlyHasTheseAccesses($expectedRessourceAccesses); // assert it twice to also test the ACL checking cache $this->assertGroupOnlyHasTheseAccesses($expectedRessourceAccesses); }
/** * Declares an association between this object and a ChildCustomerGroup object. * * @param ChildCustomerGroup $v * @return \CustomerGroupAcl\Model\CustomerGroupAcl The current object (for fluent API support) * @throws PropelException */ public function setCustomerGroup(ChildCustomerGroup $v = null) { if ($v === null) { $this->setCustomerGroupId(NULL); } else { $this->setCustomerGroupId($v->getId()); } $this->aCustomerGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildCustomerGroup object, it will not be re-added. if ($v !== null) { $v->addCustomerGroupAcl($this); } return $this; }